topic = message.topic
payload = message.publish_packet.payload.data
- logger.info('In message: {}\n{}'.format(topic, payload))
+ logger.info('In message: {} -> {}'.format(topic, payload.decode('utf-8')))
if topic.startswith(self.read_topic):
subtopic = topic[len(self.read_topic)+1:]
channel = None
id = None
command = command.lower()
+ id = id.upper()
print("%s: %s (%s)" % (command,channel,id))
if command == "on":
- if id == '.':
+ if id == '.' or id == 'TX-F':
mtrf_command = { "mode": 2, "ch": channel, "cmd": 2, "ctr": 1 }
elif id:
mtrf_command = { "mode": 2, "ch": channel, "cmd": 2, "id0": int(id[0:2],16), "id1": int(id[2:4],16), "id2": int(id[4:6],16), "id3": int(id[6:8],16), "ctr": 8 }
+ elif id == 'TX':
+ mtrf_command = { "mode": 0, "ch": channel, "cmd": 2 }
else:
mtrf_command = { "mode": 0, "ch": channel, "cmd": 2 }
elif command == "off":
- if id == '.':
+ if id == '.' or id == 'TX-F':
mtrf_command = { "mode": 2, "ch": channel, "cmd": 0, "ctr": 1 }
elif id:
mtrf_command = { "mode": 2, "ch": channel, "cmd": 0, "id0": int(id[0:2],16), "id1": int(id[2:4],16), "id2": int(id[4:6],16), "id3": int(id[6:8],16), "ctr": 8 }
+ elif id == 'TX':
+ mtrf_command = { "mode": 0, "ch": channel, "cmd": 0 }
else:
mtrf_command = { "mode": 0, "ch": channel, "cmd": 0 }
elif command == "brightness":
brightness = int(payload)
- if id == '.':
+ if id == '.' or id == 'TX-F':
mtrf_command = { "mode": 2, "ch": channel, "cmd": 6, "d0": brightness, "ctr": 1 }
elif id:
mtrf_command = { "mode": 2, "ch": channel, "cmd": 6, "d0": brightness, "id0": int(id[0:2],16), "id1": int(id[2:4],16), "id2": int(id[4:6],16), "id3": int(id[6:8],16), "ctr": 8 }
+ elif id == 'TX':
+ mtrf_command = { "mode": 0, "ch": channel, "cmd": 6, "d0": brightness }
else:
mtrf_command = { "mode": 0, "ch": channel, "cmd": 6, "d0": brightness }
elif command == "state":
- if id == '.':
+ if id == '.' or id == 'TX-F':
mtrf_command = { "mode": 2, "ch": channel, "cmd": 128, "ctr": 1 }
elif id:
mtrf_command = { "mode": 2, "ch": channel, "cmd": 128, "id0": int(id[0:2],16), "id1": int(id[2:4],16), "id2": int(id[4:6],16), "id3": int(id[6:8],16), "ctr": 8 }
elif command == "load_preset":
- if id == '.':
+ if id == '.' or id == 'TX-F':
mtrf_command = { "mode": 2, "ch": channel, "cmd": 7, "ctr": 1 }
elif id:
mtrf_command = { "mode": 2, "ch": channel, "cmd": 7, "id0": int(id[0:2],16), "id1": int(id[2:4],16), "id2": int(id[4:6],16), "id3": int(id[6:8],16), "ctr": 8 }
+ elif id == 'TX':
+ mtrf_command = { "mode": 0, "ch": channel, "cmd": 7 }
else:
mtrf_command = { "mode": 0, "ch": channel, "cmd": 7 }
elif command == "save_preset":
- if id == '.':
+ if id == '.' or id == 'TX-F':
mtrf_command = { "mode": 2, "ch": channel, "cmd": 8, "ctr": 1 }
elif id:
mtrf_command = { "mode": 2, "ch": channel, "cmd": 8, "id0": int(id[0:2],16), "id1": int(id[2:4],16), "id2": int(id[4:6],16), "id3": int(id[6:8],16), "ctr": 8 }
+ elif id == 'TX':
+ mtrf_command = { "mode": 0, "ch": channel, "cmd": 8 }
else:
mtrf_command = { "mode": 0, "ch": channel, "cmd": 8 }
elif command == "temp_on":
delay = (int(payload) + 3)//5
d0 = delay % 256
d1 = delay // 256
- if id == '.':
+ if id == '.' or id == 'TX-F':
mtrf_command = { "mode": 2, "ch": channel, "cmd": 25, "fmt": 6, "d0": d0, "d1": d1, "ctr": 1 }
elif id:
mtrf_command = { "mode": 2, "ch": channel, "cmd": 25, "fmt": 6, "d0": d0, "d1": d1, "id0": int(id[0:2],16), "id1": int(id[2:4],16), "id2": int(id[4:6],16), "id3": int(id[6:8],16), "ctr": 8 }
+ elif id == 'TX':
+ mtrf_command = { "mode": 0, "ch": channel, "cmd": 25, "fmt": 6, "d0": d0, "d1": d1 }
else:
mtrf_command = { "mode": 0, "ch": channel, "cmd": 25, "fmt": 6, "d0": d0, "d1": d1 }
elif command == "bind":
- if id == 'tx-f':
+ if id == 'TX-F':
mtrf_command = { "mode": 2, "ch": channel, "cmd": 15 }
- elif id == 'tx':
+ elif id == 'TX':
mtrf_command = { "mode": 0, "ch": channel, "cmd": 15 }
- elif id == 'rx':
+ elif id == 'RX':
mtrf_command = { "mode": 1, "ch": channel, "cmd": 15 }
- elif id == 'rx-f':
+ elif id == 'RX-F':
mtrf_command = { "mode": 3, "ch": channel, "cmd": 15 }
else:
mtrf_command = { "mode": 0, "ch": channel, "cmd": 15 }
elif command == "unbind":
- if id == '.' or id == 'tx-f':
+ if id == '.' or id == 'TX-F':
mtrf_command = { "mode": 2, "ch": channel, "cmd": 9 }
- elif id == 'tx':
+ elif id == 'TX':
mtrf_command = { "mode": 0, "ch": channel, "cmd": 9 }
- elif id == 'rx':
+ elif id == 'RX':
mtrf_command = { "mode": 1, "ch": channel, "cmd": 9, "ctr": 5 }
- elif id == 'rx-f':
+ elif id == 'RX-F':
mtrf_command = { "mode": 3, "ch": channel, "cmd": 9, "ctr": 5 }
else:
mtrf_command = { "mode": 0, "ch": channel, "cmd": 9 }
elif command == "service":
- if id == '.':
+ if id == '.' or id == 'TX-F':
mtrf_command = { "mode": 2, "ch": channel, "cmd": 131, "d0": 1 }
elif id:
mtrf_command = { "mode": 2, "ch": channel, "cmd": 131, "d0": 1, "id0": int(id[0:2],16), "id1": int(id[2:4],16), "id2": int(id[4:6],16), "id3": int(id[6:8],16), "ctr": 8 }
last_command_send_time = time.time()
async def input_serial_data(self, command):
- logger.info('Pub command: {}'.format(command))
command = self.noolite_response_to_payload(command.to_list())
+ logger.info('Pub command: {}'.format(command))
try:
topic = "%s/%s/%s" % (self.write_topic, command['ch'], command['id'])
except: