diff --git a/tools/can2coil.py b/tools/can2coil.py index 1d3a050..644cad7 100755 --- a/tools/can2coil.py +++ b/tools/can2coil.py @@ -28,10 +28,10 @@ coil_map = { 'SCH': [ 0x01, 0x08 ], 'B1': [ 0x01, 0x01 ], 'B2': [ 0x01, 0x02 ], - 'ROL_EZ_G_DOWN': [0x03, 0x05, -1], - 'ROL_EZ_G_UP': [0x03,0x04, -1], - 'ROL_EZ_N_DOWN': [0x03, 0x06, -2], - 'ROL_EZ_N_UP': [0x03,0x08, -2], + 'ROL_EZ_G_DOWN': [0x03, 0x05], + 'ROL_EZ_G_UP': [0x03,0x04], + 'ROL_EZ_N_DOWN': [0x03, 0x06], + 'ROL_EZ_N_UP': [0x03,0x08], 'EG1': [ 0x02, 0x09 ], 'EG2': [ 0x03, 0x09 ], 'OG': [ 0x01, 0x09 ], @@ -86,6 +86,7 @@ def main(): mcp_mqtt.user_data_set(canbus) mcp_mqtt.connect("mcp", 1883, 60) + mcp_mqtt.publish("coil/welcome", "1" , retain=0) try: while True: msg = canbus.recv(1) diff --git a/tools/coil2can.py b/tools/coil2can.py index 9554719..c53a349 100755 --- a/tools/coil2can.py +++ b/tools/coil2can.py @@ -139,10 +139,21 @@ def main(): mcp_mqtt.on_message = on_message mcp_mqtt.user_data_set(bus) mcp_mqtt.connect("mcp", 1883, 60) -# mcp_mqtt.loop_start() + mcp_mqtt.loop_start() + try: while True: - mcp_mqtt.loop() + msg = bus.recv(1) + if msg is not None: + de=decon(msg.arbitration_id) + m= { "prio": hex(de[0]), "type": hex(de[1]), "dst": hex(de[2]), "src": hex(de[3]), "cmd": hex(de[4]), "action": hex(msg.data[0]) } + if de[2]==0 and de[4] == 6: + print("received state: ", hex(de[3]), hex(msg.data[0]), hex(msg.data[1])) + for key in coil_map: + address=coil_map[key] + if address[0] == de[3] and address[1] == msg.data[0]+1: + print("coil/"+key+" changed to "+str(msg.data[1])) + mcp_mqtt.publish("coil/"+key+"/state", msg.data[1] , retain=1) except KeyboardInterrupt: pass finally: diff --git a/tools/shutter2can.py b/tools/shutter2can.py index a8efd13..cc54cc4 100755 --- a/tools/shutter2can.py +++ b/tools/shutter2can.py @@ -30,7 +30,7 @@ event_map = { coil_map = { # up , down 'EZ_G': [ 0x03, 0x04 , 0x03, 0x05 ], - 'EZ_N': [ 0x03, 0x06 , 0x03, 0x08 ], + 'EZ_N': [ 0x03, 0x08 , 0x03, 0x06 ], 'WZ1': [ 0x00, 0x01 , 0x00, 0x01 ], 'WZ2': [ 0x00, 0x01 , 0x00, 0x01 ], 'WZ3': [ 0x00, 0x01 , 0x00, 0x01 ],