diff --git a/nohup.out b/nohup.out deleted file mode 100644 index 43fa8f3..0000000 --- a/nohup.out +++ /dev/null @@ -1,329 +0,0 @@ -Connected -Subscribed OK -Received on topic: foobar/oben/licht Message: b'2' -Received on topic: foobar/oben/licht Message: b'' -No valid value -Received on topic: foobar/oben/licht Message: b'7' -Received on topic: foobar/oben/licht Message: b'' -No valid value -Received on topic: foobar/oben/licht Message: b'99' -Received on topic: foobar/oben/licht Message: b'' -No valid value -Received on topic: foobar/oben/licht Message: b'1' -Received on topic: foobar/oben/licht Message: b'' -No valid value -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'' -No valid value -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'' -No valid value -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'' -No valid value -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' -Received on topic: foobar/oben/licht Message: b'8' \ No newline at end of file diff --git a/power_mqtt1.py b/power_mqtt1.py index e2008af..05d218b 100755 --- a/power_mqtt1.py +++ b/power_mqtt1.py @@ -21,7 +21,7 @@ def on_connect(mosq, obj, foo ,bar ): print( "Connected" ) def on_message(mosq, obj, msg): - print( "Received on topic: " + msg.topic + " Message: "+str(msg.payload) ); + #print( "Received on topic: " + msg.topic + " Message: "+str(msg.payload) ); msgs(msg.payload) def on_subscribe(mosq, obj, mid, granted_qos): @@ -43,75 +43,56 @@ def init_mqtt(): -o1 = 0 -o2 = 0 - #Funktion Setze Bit in Variable / Function Set Bit in byte def set_bit(value, bit): - #print(value | (1< 7: - o2 = set_bit(o2, i-8) - bus.write_byte(0x21,255-o2) - else: - o1 = set_bit(o1, i) - bus.write_byte(0x3f,255-o1) - -def off(i): - global o1 - global o2 -# Change I2C Output-Card - if i > 7: - o2 = clear_bit(o2, i-8) - bus.write_byte(0x21,255-o2) - else: - o1 = clear_bit(o1, i) - bus.write_byte(0x3f,255-o1) - def switch(i,speed=0.5): - on(i) - time.sleep(speed) - off(i) + o = 0 + if i > 7: + o = set_bit(o,i-8) + bus.write_byte(0x21,255-o) + time.sleep(speed) + o = clear_bit(o,i) + bus.write_byte(0x21,255-o) + else: + o = set_bit(o, i) + bus.write_byte(0x3f,255-o) + time.sleep(speed) + o = clear_bit(o,i) + bus.write_byte(0x21,255-o) + commands = { "flur" : 0, "baellebad" : 1, "lounge-front": 2, "lounge-back" : 3,"baellebad-ein" : 4, "lounge-ein" : 5, "cantina-ein" : 6, "zentral-aus" : 7, "flur-strobo": 100, "cantina" : 8, "cantina-strobo": 99} def msgs(inp): c = inp.decode("utf-8") l = len(c) - + # supporting number commands if l < 3: try: msg = int(inp) + switch(msg) except ValueError: print ( "No valid value") return - #if (msg == 9): - # for i in range(1000): - # switch(0, speed=0.05) - # time.sleep(0.06) - #elif (msg == 99): - # for i in range(50): - # switch(8, speed=0.05) - # time.sleep(0.06) - #else: - switch(msg) + #supporting string commmands else: + cmds = c.split(",") - print ( cmds[0], len(cmds) ) + print ( "Command:", cmds[0], "Number of Parameters:", len(cmds) ) + + #suporting string commands with an arg separated by ',' if len(cmds) == 2: + + #error checking try: command = commands[cmds[0]] except KeyError: @@ -120,14 +101,19 @@ def msgs(inp): arg = int (cmds[1]) except ValueError: return - switch(command,speed = 3*arg/100+0.7 ) + + #strobo if ( command == 100 or command == 99 ): if arg < 100: for i in range(arg): switch((100-command)*8, speed=0.05) time.sleep(0.06) - + + #command with parameter used for dimming + else: + switch(command,speed = 3*arg/100+0.7 ) + #single string command without parameter else: try: switch(commands[c])