await self.commands_to_send_queue.put(payload)
else:
try:
+ mtrf_command = None
address = subtopic.split('/')
if len(address)==2:
channel = int(address[0])
print("%s: %s (%s)" % (command,channel,id))
if command == "on":
if id == '.':
- mtrf_command = { "mode": 2, "ch": channel, "cmd": 2 }
+ 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 }
else:
mtrf_command = { "mode": 0, "ch": channel, "cmd": 2 }
elif command == "off":
if id == '.':
- mtrf_command = { "mode": 2, "ch": channel, "cmd": 0 }
+ 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 }
else:
elif command == "brightness":
brightness = int(payload)
if id == '.':
- mtrf_command = { "mode": 2, "ch": channel, "cmd": 6, "d0": brightness }
+ 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 }
else:
mtrf_command = { "mode": 0, "ch": channel, "cmd": 6, "d0": brightness }
elif command == "state":
if id == '.':
- mtrf_command = { "mode": 2, "ch": channel, "cmd": 128 }
+ 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 == '.':
- mtrf_command = { "mode": 2, "ch": channel, "cmd": 7 }
+ 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 }
else:
mtrf_command = { "mode": 0, "ch": channel, "cmd": 7 }
elif command == "save_preset":
if id == '.':
- mtrf_command = { "mode": 2, "ch": channel, "cmd": 8 }
+ 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 }
else:
d0 = delay % 256
d1 = delay // 256
if id == '.':
- mtrf_command = { "mode": 2, "ch": channel, "cmd": 25, "fmt": 6, "d0": d0, "d1": d1 }
+ 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 }
else:
mtrf_command = { "mode": 0, "ch": channel, "cmd": 25, "fmt": 6, "d0": d0, "d1": d1 }
+ elif command == "bind":
+ if id == 'tx-f':
+ mtrf_command = { "mode": 2, "ch": channel, "cmd": 15 }
+ elif id == 'tx':
+ mtrf_command = { "mode": 0, "ch": channel, "cmd": 15 }
+ elif id == 'rx':
+ mtrf_command = { "mode": 1, "ch": channel, "cmd": 15 }
+ 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':
+ mtrf_command = { "mode": 2, "ch": channel, "cmd": 9 }
+ elif id == 'tx':
+ mtrf_command = { "mode": 0, "ch": channel, "cmd": 9 }
+ elif id == 'rx':
+ mtrf_command = { "mode": 1, "ch": channel, "cmd": 9, "ctr": 5 }
+ 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 == '.':
+ 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 }
- await self.commands_to_send_queue.put(mtrf_command)
+ if mtrf_command:
+ await self.commands_to_send_queue.put(mtrf_command)
except Exception as e:
logger.exception(e)