tuya / tuya-home-assistant

Home Assistant integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, maintained by the Home Assistant Community and Tuya Developer Team.
MIT License
879 stars 207 forks source link

Wifi Light Switches not functioning correctly #382

Open almudawi opened 3 years ago

almudawi commented 3 years ago

Describe the bug I have 6 light switches that exhibit similar behaviors. Toggling the switches via home assistant turns on the lights, however, the switch goes back to off on the ui and the switch stops responding via hass ui. for example, turning the light on would turn the light on, the switch would go back to off on the ui and the device stops responding to hass. The only way to turn off the lights is through the physical buttons on the light switch.

Expected behavior Switch to turn on and off through ui while reporting the correct state

Home Assistant Version

**Device info { "active_time": 1621699073, "biz_type": 18, "category": "kg", "create_time": 1597332360, "icon": "smart/program_category_icon/kg.png", "id": "xxxxxxxxxxx", "ip": "xxxxxxxxxxx", "lat": "xxxxxxxxxxxxxxx", "local_key": "xxxxxxxxxxxx", "lon": "xxxxxxxxxxxx", "model": "SWITCH3", "name": "Entrance Lights", "online": true, "owner_id": "14938250", "product_id": "fwmrrplqzjxunvmm", "product_name": "SWITCH3", "status": [ { "code": "switch_1", "value": false }, { "code": "switch_2", "value": false }, { "code": "switch_3", "value": false }, { "code": "countdown_1", "value": 0 }, { "code": "countdown_2", "value": 0 }, { "code": "countdown_3", "value": 0 } ], "sub": false, "time_zone": "+03:00", "uid": "xxxxxxxxxxx", "update_time": 1629360412, "uuid": "xxxxxxxxxxxxxxx"

tomhash2 commented 3 years ago

Have you checked logs for clues?

I have similar behaviour with smart sockets and lights and my log reports:

2021-08-18 19:23:15 ERROR (Thread-16) [root] Uncaught thread exception Traceback (most recent call last): File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/local/lib/python3.9/threading.py", line 910, in run self._target(*self._args, **self._kwargs) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3452, in _thread_main self.loop_forever(retry_first_connection=True) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1779, in loop_forever rc = self.loop(timeout, max_packets) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1181, in loop rc = self.loop_read(max_packets) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1572, in loop_read rc = self._packet_read() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 2310, in _packet_read rc = self._packet_handle() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 2936, in _packet_handle return self._handle_publish() File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3216, in _handle_publish self._handle_on_message(message) File "/usr/local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3444, in _handle_on_message self.on_message(self, self._userdata, message) File "/usr/local/lib/python3.9/site-packages/tuya_iot/openmq.py", line 157, in _on_message listener(msgDict) File "/usr/local/lib/python3.9/site-packages/tuya_iot/device.py", line 175, in on_message self._on_device_report(data["devId"], data["status"]) File "/usr/local/lib/python3.9/site-packages/tuya_iot/device.py", line 196, in _on_device_report self.update_device(device) File "/usr/local/lib/python3.9/site-packages/tuya_iot/device.py", line 183, in update_device listener.update_device(device) File "/config/custom_components/tuya_v2/init.py", line 164, in update_device ha_device.schedule_update_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 604, in schedule_update_ha_state self.hass.add_job(self.async_update_ha_state(force_refresh)) # type: ignore AttributeError: 'NoneType' object has no attribute 'add_job'

tsutsuku commented 3 years ago

@almudawi Check this https://github.com/tuya/tuya-home-assistant/discussions/113

almudawi commented 3 years ago

@tsutsuku subscribing to the API seems to resolve the problem. Thank you. I am attaching the log file just in case due to some odd errors. Just in case its helpful: 2021-08-20 12:24:21 INFO (MainThread) [custom_components.tuya_v2] Tuya async setup conf None 2021-08-20 12:24:21 INFO (MainThread) [custom_components.tuya_v2] tuya.init.async_setup_entry-->{'o0o0o0': '0e1515065513fce76d5ccaef1f912b265b18e4a6cec04ac506baaf9cf29324c2cc25fbad000950143415917779bc3b97c61bf780d7fb6a8d695c74f8619725c0cb45ad5dfa02c1525271bee9e66de6427fa4de06d9ceacc3952e014f8fe754615910694007cc5bcba833ffad638515522310bf6d5085e2852f4a2913add212bc6d20e77f634f6d514812bd24a025a65f78e9aa4fe180425c97d12b3df4406a61a7a07a97f4b99069a4bacbe62a3067252338dccd689c1d12b0eb6a112ca74028b1c0b8cdaa24aed799fa498a9d1a0491b970c1bf5083a21054f049f2fd37fce9df9fddda0faa9020104b37006ee264b67a59aa79962296194f74930d424ac59ed884518ce227569b774eca5664e40ae8', '00oo00': 'UgIDB0dFDV1USgIZSERZC0UVJTsUBCIZA0JQAQQNEEU=', 'oo00oo': '6ae544f4502a105ccceef0b8a8646cd416ffe2234c958a315ce16a26d46135f1'} 2021-08-20 12:24:21 INFO (MainThread) [custom_components.tuya_v2] tuya.init.exist_xor_cache-->True 2021-08-20 12:24:21 DEBUG (SyncWorker_3) [tuya iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/iot-01/associated-users/actions/authorized-login, params = None, body = {'username': 'xxxxxxxxxx', 'password': '', 'country_code': '+973', 'schema': 'smartlife'}, t = 1629451461225 2021-08-20 12:24:22 DEBUG (SyncWorker_3) [tuya iot] Response: { "result": { "access_token": "", "expire_time": 7200, "platform_url": "https://openapi.tuyaeu.com", "refresh_token": "", "uid": "" }, "success": true, "t": 1629451462334 } 2021-08-20 12:24:27 DEBUG (MainThread) [tuya iot] start 2021-08-20 12:24:27 DEBUG (Thread-3) [tuya iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/iot-03/open-hub/access-config, params = None, body = {'uid': '', 'link_id': '', 'link_type': 'mqtt', 'topics': 'device', 'msg_encrypted_version': '1.0'}, t = 1629451467996 2021-08-20 12:24:27 DEBUG (SyncWorker_5) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/users/eu1597332261022ewbDj/devices, params = None, body = None, t = 1629451467999 2021-08-20 12:24:28 DEBUG (Thread-3) [tuya iot] Response: { "result": { "client_id": "", "expire_time": 7200, "password": "", "sink_topic": { "device": "cloud/token/out/{device_id}" }, "source_topic": { "device": "cloud/token/in/988a354575308b78f6674f178fbf8f8d" }, "url": "ssl://m1.tuyaeu.com:8883", "username": "xxxxxxx" }, "success": true, "t": 1629451468198 } 2021-08-20 12:24:28 DEBUG (Thread-3) [tuya iot] connecting ssl://m1.tuyaeu.com:8883 2021-08-20 12:24:28 DEBUG (SyncWorker_5) [tuya iot] Response: { "result": [ { "active_time": 1601478220, "biz_type": 18, "category": "kg", "create_time": 1601478220, "icon": "smart/program_category_icon/kg.png", "id": "35600340a4cf12e790ec", "ip": "", "lat": "", "local_key": "", "lon": "", "name": "Ground Floor Hallway", "online": true, "owner_id": "14938250", "product_id": "4nqs33emdwJxpQ8O", "product_name": "SWITCH1", "status": [ { "code": "switch_1", "value": true }, { "code": "countdown_1", "value": 0 } ], "sub": false, "time_zone": "+03:00", "uid": "", "update_time": 1629450509, "uuid": "xxxxxxx" }, { "active_time": 1629408550, "biz_type": 18, "category": "kg", "create_time": 1601471697, "icon": "smart/program_category_icon/kg.png", "id": "750338205002916c4233", "ip": "", "lat": "", "local_key": "", "lon": "", "name": "Living Room Lights", "online": true, "owner_id": "14938250", "product_id": "jo66vqjwss8zs8xc", "product_name": "SWITCH2", "status": [ { "code": "switch_1", "value": false }, { "code": "switch_2", "value": false }, { "code": "countdown_1", "value": 0 }, { "code": "countdown_2", "value": 0 } ], "sub": false, "time_zone": "+03:00", "uid": "", "update_time": 1629450388, "uuid": "xxxxxxxxxxx" }, { "active_time": 1598873839, "biz_type": 18, "category": "rqbj", "create_time": 1598873839, "icon": "smart/icon/ay1571730388400fkqnt/13a365f303f4c23805c3e71714904fa7.png", "id": "34563803500291d41661", "ip": "", "lat": "", "local_key": "", "lon": "", "model": "MKRQ901W", "name": "Gas sensor", "online": true, "owner_id": "14938250", "product_id": "b1iduscb4hzy36ne", "product_name": "Gas sensor", "status": [ { "code": "gas_sensor_state", "value": "2" }, { "code": "gas_sensor_value", "value": 0 }, { "code": "alarm_volume", "value": "high" }, { "code": "alarm_time", "value": 10 }, { "code": "self_checking", "value": false }, { "code": "checking_result", "value": "check_success" }, { "code": "preheat", "value": false }, { "code": "lifecycle", "value": true }, { "code": "alarm_switch", "value": true }, { "code": "muffling", "value": false } ], "sub": false, "time_zone": "+03:00", "uid": "", "update_time": 1629450380, "uuid": "xxxxxxxx" }, { "active_time": 1621699073, "biz_type": 18, "category": "kg", "create_time": 1597332360, "icon": "smart/program_category_icon/kg.png", "id": "51712807f4cfa2552853", "ip": "", "lat": "", "local_key": "", "lon": "", "model": "SWITCH3", "name": "Entrance Lights", "online": true, "owner_id": "14938250", "product_id": "fwmrrplqzjxunvmm", "product_name": "SWITCH3", "status": [ { "code": "switch_1", "value": false }, { "code": "switch_2", "value": false }, { "code": "switch_3", "value": false }, { "code": "countdown_1", "value": 0 }, { "code": "countdown_2", "value": 0 }, { "code": "countdown_3", "value": 0 } ], "sub": false, "time_zone": "+03:00", "uid": "", "update_time": 1629408523, "uuid": "xxxxxxxxx" }, { "active_time": 1601472347, "biz_type": 18, "category": "kg", "create_time": 1601472347, "icon": "smart/program_category_icon/kg.png", "id": "80035886ecfabc7f3c4b", "ip": "", "lat": "", "local_key": "", "lon": "", "name": "Hallway", "online": true, "owner_id": "14938250", "product_id": "jo66vqjwss8zs8xc", "product_name": "SWITCH2", "status": [ { "code": "switch_1", "value": false }, { "code": "switch_2", "value": false }, { "code": "countdown_1", "value": 0 }, { "code": "countdown_2", "value": 0 } ], "sub": false, "time_zone": "+03:00", "uid": "", "update_time": 1629398528, "uuid": "xxxxxxxxxxx" }, { "active_time": 1607273747, "biz_type": 18, "category": "kg", "create_time": 1597334007, "icon": "smart/icon/1557411708n4kq00z38bp_0.jpg", "id": "43300007bcddc267a8c6", "ip": "", "lat": "", "local_key": "", "lon": "", "model": "", "name": "Garage Lights", "online": true, "owner_id": "14938250", "product_id": "4j2hiriwhwhlsgmg", "product_name": "W602", "status": [ { "code": "switch_1", "value": false }, { "code": "switch_2", "value": false }, { "code": "countdown_1", "value": 0 }, { "code": "countdown_2", "value": 0 } ], "sub": false, "time_zone": "+03:00", "uid": "", "update_time": 1629398524, "uuid": "xxxxxxxx" } ], "success": true, "t": 1629451468768 } 2021-08-20 12:24:28 DEBUG (SyncWorker_5) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/devices/35600340a4cf12e790ec/specifications, params = None, body = None, t = 1629451468878 2021-08-20 12:24:29 DEBUG (SyncWorker_5) [tuya iot] Response: { "result": { "category": "kg", "functions": [ { "code": "switch_1", "type": "Boolean", "values": "{}" }, { "code": "countdown_1", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" } ], "status": [ { "code": "switch_1", "type": "Boolean", "values": "{}" }, { "code": "countdown_1", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" } ] }, "success": true, "t": 1629451469085 } 2021-08-20 12:24:29 DEBUG (SyncWorker_5) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/devices/750338205002916c4233/specifications, params = None, body = None, t = 1629451469197 2021-08-20 12:24:29 DEBUG (SyncWorker_5) [tuya iot] Response: { "result": { "category": "kg", "functions": [ { "code": "switch_1", "type": "Boolean", "values": "{}" }, { "code": "switch_2", "type": "Boolean", "values": "{}" }, { "code": "countdown_1", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "countdown_2", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" } ], "status": [ { "code": "switch_1", "type": "Boolean", "values": "{}" }, { "code": "switch_2", "type": "Boolean", "values": "{}" }, { "code": "countdown_1", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "countdown_2", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" } ] }, "success": true, "t": 1629451469364 } 2021-08-20 12:24:29 DEBUG (SyncWorker_5) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/devices/34563803500291d41661/specifications, params = None, body = None, t = 1629451469449 2021-08-20 12:24:29 DEBUG (Thread-3) [tuya iot] _on_log: Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'cloud_1899e854fc6a07bd40571bf4efedd5b8' 2021-08-20 12:24:29 DEBUG (SyncWorker_5) [tuya iot] Response: { "result": { "category": "rqbj", "functions": [ { "code": "alarm_volume", "type": "Enum", "values": "{\"range\":[\"low\",\"middle\",\"high\",\"mute\"]}" }, { "code": "alarm_time", "type": "Integer", "values": "{\"unit\":\"分钟\",\"min\":0,\"max\":60,\"scale\":0,\"step\":1}" }, { "code": "self_checking", "type": "Boolean", "values": "{}" }, { "code": "alarm_switch", "type": "Boolean", "values": "{}" }, { "code": "muffling", "type": "Boolean", "values": "{}" } ], "status": [ { "code": "gas_sensor_state", "type": "Enum", "values": "{\"range\":[\"1\",\"2\"]}" }, { "code": "gas_sensor_value", "type": "Integer", "values": "{\"unit\":\"%LEL\",\"min\":0,\"max\":20,\"scale\":0,\"step\":1}" }, { "code": "alarm_volume", "type": "Enum", "values": "{\"range\":[\"low\",\"middle\",\"high\",\"mute\"]}" }, { "code": "alarm_time", "type": "Integer", "values": "{\"unit\":\"分钟\",\"min\":0,\"max\":60,\"scale\":0,\"step\":1}" }, { "code": "self_checking", "type": "Boolean", "values": "{}" }, { "code": "checking_result", "type": "Enum", "values": "{\"range\":[\"checking\",\"check_success\",\"check_failure\",\"others\"]}" }, { "code": "preheat", "type": "Boolean", "values": "{}" }, { "code": "lifecycle", "type": "Boolean", "values": "{}" }, { "code": "alarm_switch", "type": "Boolean", "values": "{}" }, { "code": "muffling", "type": "Boolean", "values": "{}" } ] }, "success": true, "t": 1629451469604 } 2021-08-20 12:24:29 DEBUG (SyncWorker_5) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/devices/51712807f4cfa2552853/specifications, params = None, body = None, t = 1629451469693 2021-08-20 12:24:29 DEBUG (Thread-4) [tuya iot] _on_log: Received CONNACK (0, 0) 2021-08-20 12:24:29 DEBUG (Thread-4) [tuya iot] connect flags->{'session present': 0}, rc->0 2021-08-20 12:24:29 DEBUG (Thread-4) [tuya iot] _on_log: Sending SUBSCRIBE (d0, m1) [(b'cloud/token/in/988a354575308b78f6674f178fbf8f8d', 0)] 2021-08-20 12:24:29 DEBUG (SyncWorker_5) [tuya iot] Response: { "result": { "category": "kg", "functions": [ { "code": "switch_1", "type": "Boolean", "values": "{}" }, { "code": "switch_2", "type": "Boolean", "values": "{}" }, { "code": "switch_3", "type": "Boolean", "values": "{}" }, { "code": "countdown_1", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "countdown_2", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "countdown_3", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" } ], "status": [ { "code": "switch_1", "type": "Boolean", "values": "{}" }, { "code": "switch_2", "type": "Boolean", "values": "{}" }, { "code": "switch_3", "type": "Boolean", "values": "{}" }, { "code": "countdown_1", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "countdown_2", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "countdown_3", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" } ] }, "success": true, "t": 1629451469836 } 2021-08-20 12:24:29 DEBUG (SyncWorker_5) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/devices/80035886ecfabc7f3c4b/specifications, params = None, body = None, t = 1629451469935 2021-08-20 12:24:30 DEBUG (Thread-4) [tuya iot] _on_log: Received SUBACK 2021-08-20 12:24:30 DEBUG (Thread-4) [tuya iot] _on_subscribe: 1 2021-08-20 12:24:30 DEBUG (SyncWorker_5) [tuya iot] Response: { "result": { "category": "kg", "functions": [ { "code": "switch_1", "type": "Boolean", "values": "{}" }, { "code": "switch_2", "type": "Boolean", "values": "{}" }, { "code": "countdown_1", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "countdown_2", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" } ], "status": [ { "code": "switch_1", "type": "Boolean", "values": "{}" }, { "code": "switch_2", "type": "Boolean", "values": "{}" }, { "code": "countdown_1", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "countdown_2", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" } ] }, "success": true, "t": 1629451470106 } 2021-08-20 12:24:30 DEBUG (SyncWorker_5) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/devices/43300007bcddc267a8c6/specifications, params = None, body = None, t = 1629451470200 2021-08-20 12:24:30 DEBUG (SyncWorker_5) [tuya iot] Response: { "result": { "category": "kg", "functions": [ { "code": "switch_1", "type": "Boolean", "values": "{}" }, { "code": "switch_2", "type": "Boolean", "values": "{}" }, { "code": "countdown_1", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "countdown_2", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" } ], "status": [ { "code": "switch_1", "type": "Boolean", "values": "{}" }, { "code": "switch_2", "type": "Boolean", "values": "{}" }, { "code": "countdown_1", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" }, { "code": "countdown_2", "type": "Integer", "values": "{\"unit\":\"s\",\"min\":0,\"max\":86400,\"scale\":0,\"step\":1}" } ] }, "success": true, "t": 1629451470375 } 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] init support type->['binary_sensor', 'climate', 'cover', 'fan', 'humidifier', 'light', 'number', 'scene', 'select', 'sensor', 'switch', 'vacuum'] 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] tuya async platform-->binary_sensor 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] tuya async platform-->climate 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] tuya async platform-->cover 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] tuya async platform-->fan 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] tuya async platform-->humidifier 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] tuya async platform-->light 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] tuya async platform-->number 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] tuya async platform-->scene 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] tuya async platform-->select 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] tuya async platform-->sensor 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] tuya async platform-->switch 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2] tuya async platform-->vacuum 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.binary_sensor] binary sensor init 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.binary_sensor] binary sensor add->['34563803500291d41661'] 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.climate] climate init 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.climate] climate add->[] 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.cover] cover init 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.cover] cover add-> [] 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.fan] fan init 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.fan] fan add-> [] 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.light] light init 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.light] light add-> [] 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.scene] scenes init 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.sensor] sensor init 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.sensor] sensor add-> ['35600340a4cf12e790ec', '750338205002916c4233', '34563803500291d41661', '51712807f4cfa2552853', '80035886ecfabc7f3c4b', '43300007bcddc267a8c6'] 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.switch] switch init 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.switch] switch add-> ['35600340a4cf12e790ec', '750338205002916c4233', '51712807f4cfa2552853', '80035886ecfabc7f3c4b', '43300007bcddc267a8c6'] 2021-08-20 12:24:30 DEBUG (SyncWorker_5) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/users/eu1597332261022ewbDj/homes, params = None, body = None, t = 1629451470648 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.number] number init 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.number] number add-> [] 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.humidifier] humidifier init 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.humidifier] humidifier add-> [] 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.select] select init 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.select] select add-> [] 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.vacuum] vacuum init 2021-08-20 12:24:30 INFO (MainThread) [custom_components.tuya_v2.vacuum] vacuum add -> [] 2021-08-20 12:24:30 DEBUG (SyncWorker_5) [tuya iot] Response: { "result": [ { "geo_name": "المالكية Bahrain ", "home_id": 14938250, "lat": "", "lon": "", "name": "My Home ..", "role": "OWNER" } ], "success": true, "t": 1629451470798 } 2021-08-20 12:24:30 DEBUG (SyncWorker_5) [tuya iot] Request: method = GET, url = https://openapi.tuyaeu.com/v1.0/homes/14938250/scenes, params = None, body = None, t = 1629451470892 2021-08-20 12:24:31 DEBUG (SyncWorker_5) [tuya iot] Response: { "result": [], "success": true, "t": 1629451471025 } 2021-08-20 12:25:11 DEBUG (Thread-4) [tuya iot] _on_log: failed to receive on socket: [Errno 104] Connection reset by peer 2021-08-20 12:25:11 ERROR (Thread-4) [tuya iot] Unexpected disconnection.1 2021-08-20 12:25:13 DEBUG (Thread-4) [tuya iot] _on_log: Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'cloud_1899e854fc6a07bd40571bf4efedd5b8' 2021-08-20 12:25:13 DEBUG (Thread-4) [tuya iot] _on_log: Received CONNACK (0, 0) 2021-08-20 12:25:13 DEBUG (Thread-4) [tuya iot] connect flags->{'session present': 0}, rc->0 2021-08-20 12:25:13 DEBUG (Thread-4) [tuya iot] _on_log: Sending SUBSCRIBE (d0, m2) [(b'cloud/token/in/988a354575308b78f6674f178fbf8f8d', 0)] 2021-08-20 12:25:13 DEBUG (Thread-4) [tuya iot] _on_log: Received SUBACK 2021-08-20 12:25:13 DEBUG (Thread-4) [tuya iot] _on_subscribe: 2 2021-08-20 12:25:56 DEBUG (Thread-4) [tuya iot] _on_log: failed to receive on socket: [Errno 104] Connection reset by peer 2021-08-20 12:25:56 ERROR (Thread-4) [tuya iot] Unexpected disconnection.1 2021-08-20 12:25:58 DEBUG (Thread-4) [tuya iot] _on_log: Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'cloud_1899e854fc6a07bd40571bf4efedd5b8' 2021-08-20 12:25:58 DEBUG (Thread-4) [tuya iot] _on_log: Received CONNACK (0, 0) 2021-08-20 12:25:58 DEBUG (Thread-4) [tuya iot] connect flags->{'session present': 0}, rc->0 2021-08-20 12:25:58 DEBUG (Thread-4) [tuya iot] _on_log: Sending SUBSCRIBE (d0, m3) [(b'cloud/token/in/988a354575308b78f6674f178fbf8f8d', 0)] 2021-08-20 12:25:58 DEBUG (Thread-4) [tuya iot] _on_log: Received SUBACK 2021-08-20 12:25:58 DEBUG (Thread-4) [tuya iot] _on_subscribe: 3 2021-08-20 12:26:42 DEBUG (Thread-4) [tuya iot] _on_log: failed to receive on socket: [Errno 104] Connection reset by peer 2021-08-20 12:26:42 ERROR (Thread-4) [tuya iot] Unexpected disconnection.1 2021-08-20 12:26:43 DEBUG (Thread-4) [tuya iot] _on_log: Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'cloud_1899e854fc6a07bd40571bf4efedd5b8' 2021-08-20 12:26:44 DEBUG (Thread-4) [tuya iot] _on_log: Received CONNACK (0, 0) 2021-08-20 12:26:44 DEBUG (Thread-4) [tuya iot] connect flags->{'session present': 0}, rc->0 2021-08-20 12:26:44 DEBUG (Thread-4) [tuya iot] _on_log: Sending SUBSCRIBE (d0, m4) [(b'cloud/token/in/988a354575308b78f6674f178fbf8f8d', 0)] 2021-08-20 12:26:44 DEBUG (Thread-4) [tuya iot] _on_log: Received SUBACK 2021-08-20 12:26:44 DEBUG (Thread-4) [tuya iot] _on_subscribe: 4 2021-08-20 12:27:44 DEBUG (Thread-4) [tuya iot] _on_log: Sending PINGREQ 2021-08-20 12:27:44 DEBUG (Thread-4) [tuya iot] _on_log: failed to receive on socket: [Errno 104] Connection reset by peer 2021-08-20 12:27:44 ERROR (Thread-4) [tuya iot] Unexpected disconnection.1 2021-08-20 12:27:46 DEBUG (Thread-4) [tuya iot] _on_log: Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'cloud_1899e854fc6a07bd40571bf4efedd5b8' 2021-08-20 12:27:46 DEBUG (Thread-4) [tuya iot] _on_log: Received CONNACK (0, 0) 2021-08-20 12:27:46 DEBUG (Thread-4) [tuya iot] connect flags->{'session present': 0}, rc->0 2021-08-20 12:27:46 DEBUG (Thread-4) [tuya iot] _on_log: Sending SUBSCRIBE (d0, m5) [(b'cloud/token/in/988a354575308b78f6674f178fbf8f8d', 0)] 2021-08-20 12:27:46 DEBUG (Thread-4) [tuya iot] _on_log: Received SUBACK 2021-08-20 12:27:46 DEBUG (Thread-4) [tuya iot] _on_subscribe: 5 2021-08-20 12:27:47 DEBUG (SyncWorker_0) [tuya iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/devices/35600340a4cf12e790ec/commands, params = None, body = {'commands': [{'code': 'switch_1', 'value': False}]}, t = 1629451667410 2021-08-20 12:27:50 DEBUG (SyncWorker_0) [tuya iot] Response: { "result": true, "success": true, "t": 1629451670408 } 2021-08-20 12:27:50 DEBUG (Thread-4) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/988a354575308b78f6674f178fbf8f8d', ... (348 bytes) 2021-08-20 12:27:50 DEBUG (Thread-4) [tuya iot] payload-> b'{"data":"DGkSrZuBsfWeu1X668dS/+5qcOPVaIktLtEimTeuKwYIn1dmOTeZg6X53Ab/NGuJ3MMewJ1l0fQgJc/GYaTqyQ82uW5U/SLoPbhQ2MJje+Oo3wXU4dNdWUTgON9WvU019JUKAOpxo/wIt3X9CMqnL/RWZvflr92de1rBFoLZXxMqep88uYvv1xjwVWBcWjwJMinyeZ1/QSULF7LdfkOtrxBunKxyYEinXSYQqjnU7wYEJlAwzWmzOK02UG+hbLQf","protocol":4,"pv":"2.0","sign":"e948696929dcb3828ac3483516c2bb58","t":1629451670}' 2021-08-20 12:27:50 DEBUG (Thread-4) [tuya iot] on_message: {'data': {'dataId': 'bdf1154c-3152-45df-8a45-7e2dfcca0101', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': False, 'code': 'switch_1', 't': '1629451670', 'value': False}]}, 'protocol': 4, 'pv': '2.0', 'sign': 'e948696929dcb3828ac3483516c2bb58', 't': 1629451670} 2021-08-20 12:27:50 DEBUG (Thread-4) [tuya iot] mq receive-> {'data': {'dataId': 'bdf1154c-3152-45df-8a45-7e2dfcca0101', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': False, 'code': 'switch_1', 't': '1629451670', 'value': False}]}, 'protocol': 4, 'pv': '2.0', 'sign': 'e948696929dcb3828ac3483516c2bb58', 't': 1629451670} 2021-08-20 12:27:50 DEBUG (Thread-4) [tuya iot] mq _on_device_report-> [{'1': False, 'code': 'switch_1', 't': '1629451670', 'value': False}] 2021-08-20 12:27:50 DEBUG (Thread-4) [custom_components.tuya_v2] _update--><custom_components.tuya_v2._init_tuya_sdk..DeviceListener object at 0xac6520b8>;->>{'switch_1': False, 'countdown_1': 0} 2021-08-20 12:27:57 ERROR (stream_worker) [libav.rtsp] method DESCRIBE failed: 404 Not Found 2021-08-20 12:28:19 DEBUG (SyncWorker_0) [tuya iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/devices/35600340a4cf12e790ec/commands, params = None, body = {'commands': [{'code': 'switch_1', 'value': True}]}, t = 1629451699101 2021-08-20 12:28:19 DEBUG (SyncWorker_0) [tuya iot] Response: { "result": true, "success": true, "t": 1629451699255 } 2021-08-20 12:28:19 DEBUG (Thread-4) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/988a354575308b78f6674f178fbf8f8d', ... (348 bytes) 2021-08-20 12:28:19 DEBUG (Thread-4) [tuya iot] payload-> b'{"data":"A4ER5HgnbU8J6ATvTUcG2dOMRWyhD631OIfA8raJmlBAU8pmzkQOIJax3PybNmCj3MMewJ1l0fQgJc/GYaTqyQ82uW5U/SLoPbhQ2MJje+Oo3wXU4dNdWUTgON9WvU019JUKAOpxo/wIt3X9CMqnLyOROO5ygS7wsl+CoshzmqVGQwLRKfjutSCKb/jduqeTYUv//7xOweLIeo46k3u5jtnZ/JUI/xyMgjMde4vYeeqPf6DtgIeaOxGrHT1/oTUT","protocol":4,"pv":"2.0","sign":"5026df416aed51466d39b8ce1f01c501","t":1629451698}' 2021-08-20 12:28:19 DEBUG (Thread-4) [tuya iot] on_message: {'data': {'dataId': 'c5cfd164-3264-41c2-b1e2-d3b5715af4b0', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': True, 'code': 'switch_1', 't': '1629451698', 'value': True}]}, 'protocol': 4, 'pv': '2.0', 'sign': '5026df416aed51466d39b8ce1f01c501', 't': 1629451698} 2021-08-20 12:28:19 DEBUG (Thread-4) [tuya iot] mq receive-> {'data': {'dataId': 'c5cfd164-3264-41c2-b1e2-d3b5715af4b0', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': True, 'code': 'switch_1', 't': '1629451698', 'value': True}]}, 'protocol': 4, 'pv': '2.0', 'sign': '5026df416aed51466d39b8ce1f01c501', 't': 1629451698} 2021-08-20 12:28:19 DEBUG (Thread-4) [tuya iot] mq _on_device_report-> [{'1': True, 'code': 'switch_1', 't': '1629451698', 'value': True}] 2021-08-20 12:28:19 DEBUG (Thread-4) [custom_components.tuya_v2] _update--><custom_components.tuya_v2._init_tuya_sdk..DeviceListener object at 0xac6520b8>;->>{'switch_1': True, 'countdown_1': 0} 2021-08-20 12:28:23 ERROR (stream_worker) [libav.rtsp] method DESCRIBE failed: 404 Not Found 2021-08-20 12:28:27 DEBUG (SyncWorker_0) [tuya iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/devices/35600340a4cf12e790ec/commands, params = None, body = {'commands': [{'code': 'switch_1', 'value': False}]}, t = 1629451707545 2021-08-20 12:28:27 DEBUG (SyncWorker_0) [tuya iot] Response: { "result": true, "success": true, "t": 1629451707668 } 2021-08-20 12:28:28 DEBUG (Thread-4) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/988a354575308b78f6674f178fbf8f8d', ... (348 bytes) 2021-08-20 12:28:28 DEBUG (Thread-4) [tuya iot] payload-> b'{"data":"K8gOHzkAtPjn8q0pZnYX9LJGyFC1zQwvW9hdUuh7Y/Ipv9Tgt+gO2yZqYHYkJXfw3MMewJ1l0fQgJc/GYaTqyQ82uW5U/SLoPbhQ2MJje+Oo3wXU4dNdWUTgON9WvU019JUKAOpxo/wIt3X9CMqnL/RWZvflr92de1rBFoLZXxMqep88uYvv1xjwVWBcWjwJMinyeZ1/QSULF7LdfkOtrwsAK6f7noxAbYrXuMuj9DQEJlAwzWmzOK02UG+hbLQf","protocol":4,"pv":"2.0","sign":"cb70877e4a5f35b78d20a4ab1cbd1b61","t":1629451707}' 2021-08-20 12:28:28 DEBUG (Thread-4) [tuya iot] on_message: {'data': {'dataId': '9d79687d-0cc1-434a-84ed-c5bd5e48c899', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': False, 'code': 'switch_1', 't': '1629451707', 'value': False}]}, 'protocol': 4, 'pv': '2.0', 'sign': 'cb70877e4a5f35b78d20a4ab1cbd1b61', 't': 1629451707} 2021-08-20 12:28:28 DEBUG (Thread-4) [tuya iot] mq receive-> {'data': {'dataId': '9d79687d-0cc1-434a-84ed-c5bd5e48c899', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': False, 'code': 'switch_1', 't': '1629451707', 'value': False}]}, 'protocol': 4, 'pv': '2.0', 'sign': 'cb70877e4a5f35b78d20a4ab1cbd1b61', 't': 1629451707} 2021-08-20 12:28:28 DEBUG (Thread-4) [tuya iot] mq _on_device_report-> [{'1': False, 'code': 'switch_1', 't': '1629451707', 'value': False}] 2021-08-20 12:28:28 DEBUG (Thread-4) [custom_components.tuya_v2] _update--><custom_components.tuya_v2._init_tuya_sdk..DeviceListener object at 0xac6520b8>;->>{'switch_1': False, 'countdown_1': 0} 2021-08-20 12:28:30 DEBUG (SyncWorker_0) [tuya iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/devices/35600340a4cf12e790ec/commands, params = None, body = {'commands': [{'code': 'switch_1', 'value': True}]}, t = 1629451710503 2021-08-20 12:28:30 DEBUG (SyncWorker_0) [tuya iot] Response: { "result": true, "success": true, "t": 1629451710655 } 2021-08-20 12:28:31 DEBUG (Thread-4) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/988a354575308b78f6674f178fbf8f8d', ... (348 bytes) 2021-08-20 12:28:31 DEBUG (Thread-4) [tuya iot] payload-> b'{"data":"69T88GbDYQ7VIkPp59G6Iv16Di/VByLStf3EdDOAQC05hXoL88eoQ1XaVaJZyZrs3MMewJ1l0fQgJc/GYaTqyQ82uW5U/SLoPbhQ2MJje+Oo3wXU4dNdWUTgON9WvU019JUKAOpxo/wIt3X9CMqnLyOROO5ygS7wsl+CoshzmqVGQwLRKfjutSCKb/jduqeTYUv//7xOweLIeo46k3u5jhtvUxXyFiXRjHknjPWZVOqPf6DtgIeaOxGrHT1/oTUT","protocol":4,"pv":"2.0","sign":"eb4b71cb1a1db7408186711b12441bc8","t":1629451710}' 2021-08-20 12:28:31 DEBUG (Thread-4) [tuya iot] on_message: {'data': {'dataId': 'f4940909-0f8e-4aed-86a5-544d7dfb69c8', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': True, 'code': 'switch_1', 't': '1629451710', 'value': True}]}, 'protocol': 4, 'pv': '2.0', 'sign': 'eb4b71cb1a1db7408186711b12441bc8', 't': 1629451710} 2021-08-20 12:28:31 DEBUG (Thread-4) [tuya iot] mq receive-> {'data': {'dataId': 'f4940909-0f8e-4aed-86a5-544d7dfb69c8', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': True, 'code': 'switch_1', 't': '1629451710', 'value': True}]}, 'protocol': 4, 'pv': '2.0', 'sign': 'eb4b71cb1a1db7408186711b12441bc8', 't': 1629451710} 2021-08-20 12:28:31 DEBUG (Thread-4) [tuya iot] mq _on_device_report-> [{'1': True, 'code': 'switch_1', 't': '1629451710', 'value': True}] 2021-08-20 12:28:31 DEBUG (Thread-4) [custom_components.tuya_v2] _update--><custom_components.tuya_v2._init_tuya_sdk..DeviceListener object at 0xac6520b8>;->>{'switch_1': True, 'countdown_1': 0} 2021-08-20 12:28:32 DEBUG (SyncWorker_0) [tuya iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/devices/35600340a4cf12e790ec/commands, params = None, body = {'commands': [{'code': 'switch_1', 'value': False}]}, t = 1629451712913 2021-08-20 12:28:33 DEBUG (SyncWorker_0) [tuya iot] Response: { "result": true, "success": true, "t": 1629451713074 } 2021-08-20 12:28:33 DEBUG (Thread-4) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/988a354575308b78f6674f178fbf8f8d', ... (348 bytes) 2021-08-20 12:28:33 DEBUG (Thread-4) [tuya iot] payload-> b'{"data":"x/7pDwx+zSuhX1FsPePaGE68k4StKf9/T0I3pgjtJPrAX2s23w5MWzvUsLlAiktZ3MMewJ1l0fQgJc/GYaTqyQ82uW5U/SLoPbhQ2MJje+Oo3wXU4dNdWUTgON9WvU019JUKAOpxo/wIt3X9CMqnL/RWZvflr92de1rBFoLZXxMqep88uYvv1xjwVWBcWjwJMinyeZ1/QSULF7LdfkOtr0zSvT24YQrNGAZiUk8DCAYEJlAwzWmzOK02UG+hbLQf","protocol":4,"pv":"2.0","sign":"fb7394cac50a56ab58cf2ae9b6d6aceb","t":1629451712}' 2021-08-20 12:28:33 DEBUG (Thread-4) [tuya iot] on_message: {'data': {'dataId': '6874cbcd-b7a5-4078-9850-a6d897e1ecd4', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': False, 'code': 'switch_1', 't': '1629451712', 'value': False}]}, 'protocol': 4, 'pv': '2.0', 'sign': 'fb7394cac50a56ab58cf2ae9b6d6aceb', 't': 1629451712} 2021-08-20 12:28:33 DEBUG (Thread-4) [tuya iot] mq receive-> {'data': {'dataId': '6874cbcd-b7a5-4078-9850-a6d897e1ecd4', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': False, 'code': 'switch_1', 't': '1629451712', 'value': False}]}, 'protocol': 4, 'pv': '2.0', 'sign': 'fb7394cac50a56ab58cf2ae9b6d6aceb', 't': 1629451712} 2021-08-20 12:28:33 DEBUG (Thread-4) [tuya iot] mq _on_device_report-> [{'1': False, 'code': 'switch_1', 't': '1629451712', 'value': False}] 2021-08-20 12:28:33 DEBUG (Thread-4) [custom_components.tuya_v2] _update--><custom_components.tuya_v2._init_tuya_sdk..DeviceListener object at 0xac6520b8>;->>{'switch_1': False, 'countdown_1': 0} 2021-08-20 12:28:46 DEBUG (Thread-4) [tuya iot] _on_log: Sending PINGREQ 2021-08-20 12:28:46 DEBUG (Thread-4) [tuya iot] _on_log: Received PINGRESP 2021-08-20 12:28:56 DEBUG (SyncWorker_0) [tuya iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/devices/35600340a4cf12e790ec/commands, params = None, body = {'commands': [{'code': 'switch_1', 'value': True}]}, t = 1629451736888 2021-08-20 12:28:57 DEBUG (SyncWorker_0) [tuya iot] Response: { "result": true, "success": true, "t": 1629451737090 } 2021-08-20 12:28:57 DEBUG (Thread-4) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/988a354575308b78f6674f178fbf8f8d', ... (348 bytes) 2021-08-20 12:28:57 DEBUG (Thread-4) [tuya iot] payload-> b'{"data":"V+Y9qk6Jb28N1PFbMs951GRZZeoD4SJrE0+LveXYuCm+fvD7bm8LdWtuYuK95e3c3MMewJ1l0fQgJc/GYaTqyQ82uW5U/SLoPbhQ2MJje+Oo3wXU4dNdWUTgON9WvU019JUKAOpxo/wIt3X9CMqnLyOROO5ygS7wsl+CoshzmqVGQwLRKfjutSCKb/jduqeTYUv//7xOweLIeo46k3u5jsdYmKGvTJXSF/KDzB08OLCPf6DtgIeaOxGrHT1/oTUT","protocol":4,"pv":"2.0","sign":"25e705d903421fffaf26c6e0a6322f24","t":1629451736}' 2021-08-20 12:28:57 DEBUG (Thread-4) [tuya iot] on_message: {'data': {'dataId': '4ad116bb-e6b8-4b5b-bb3b-74e90813c8c3', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': True, 'code': 'switch_1', 't': '1629451736', 'value': True}]}, 'protocol': 4, 'pv': '2.0', 'sign': '25e705d903421fffaf26c6e0a6322f24', 't': 1629451736} 2021-08-20 12:28:57 DEBUG (Thread-4) [tuya iot] mq receive-> {'data': {'dataId': '4ad116bb-e6b8-4b5b-bb3b-74e90813c8c3', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': True, 'code': 'switch_1', 't': '1629451736', 'value': True}]}, 'protocol': 4, 'pv': '2.0', 'sign': '25e705d903421fffaf26c6e0a6322f24', 't': 1629451736} 2021-08-20 12:28:57 DEBUG (Thread-4) [tuya iot] mq _on_device_report-> [{'1': True, 'code': 'switch_1', 't': '1629451736', 'value': True}] 2021-08-20 12:28:57 DEBUG (Thread-4) [custom_components.tuya_v2] _update--><custom_components.tuya_v2._init_tuya_sdk..DeviceListener object at 0xac6520b8>;->>{'switch_1': True, 'countdown_1': 0} 2021-08-20 12:29:07 DEBUG (SyncWorker_0) [tuya iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/devices/35600340a4cf12e790ec/commands, params = None, body = {'commands': [{'code': 'switch_1', 'value': False}]}, t = 1629451747820 2021-08-20 12:29:08 DEBUG (SyncWorker_0) [tuya iot] Response: { "result": true, "success": true, "t": 1629451747941 } 2021-08-20 12:29:08 DEBUG (Thread-4) [tuya iot] _on_log: Received PUBLISH (d0, q0, r0, m0), 'cloud/token/in/988a354575308b78f6674f178fbf8f8d', ... (348 bytes) 2021-08-20 12:29:08 DEBUG (Thread-4) [tuya iot] payload-> b'{"data":"kpdLUpLC7fGsVw26+LjXGmLA83zgVzfn49e5IoUlpBUeciNszoGGCoHIY53G1aqn3MMewJ1l0fQgJc/GYaTqyQ82uW5U/SLoPbhQ2MJje+Oo3wXU4dNdWUTgON9WvU019JUKAOpxo/wIt3X9CMqnL/RWZvflr92de1rBFoLZXxMqep88uYvv1xjwVWBcWjwJMinyeZ1/QSULF7LdfkOtr6P7CjDDzdlnc61GJl+63DgEJlAwzWmzOK02UG+hbLQf","protocol":4,"pv":"2.0","sign":"d6a85fa04cf59f5df1d6d79b4d44edb0","t":1629451747}' 2021-08-20 12:29:08 DEBUG (Thread-4) [tuya iot] on_message: {'data': {'dataId': 'df050b74-6ae7-418d-a001-428e85c0275a', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': False, 'code': 'switch_1', 't': '1629451747', 'value': False}]}, 'protocol': 4, 'pv': '2.0', 'sign': 'd6a85fa04cf59f5df1d6d79b4d44edb0', 't': 1629451747} 2021-08-20 12:29:08 DEBUG (Thread-4) [tuya iot] mq receive-> {'data': {'dataId': 'df050b74-6ae7-418d-a001-428e85c0275a', 'devId': '35600340a4cf12e790ec', 'productKey': '4nqs33emdwJxpQ8O', 'status': [{'1': False, 'code': 'switch_1', 't': '1629451747', 'value': False}]}, 'protocol': 4, 'pv': '2.0', 'sign': 'd6a85fa04cf59f5df1d6d79b4d44edb0', 't': 1629451747} 2021-08-20 12:29:08 DEBUG (Thread-4) [tuya iot] mq _on_device_report-> [{'1': False, 'code': 'switch_1', 't': '1629451747', 'value': False}] 2021-08-20 12:29:08 DEBUG (Thread-4) [custom_components.tuya_v2] _update--><custom_components.tuya_v2._init_tuya_sdk..DeviceListener object at 0xac6520b8>;->>{'switch_1': False, 'countdown_1': 0} 2021-08-20 12:29:47 DEBUG (Thread-4) [tuya iot] _on_log: Sending PINGREQ 2021-08-20 12:29:47 DEBUG (Thread-4) [tuya iot] _on_log: Received PINGRESP

almudawi commented 3 years ago

I've been receiving the following error

Logger: tuya iot Source: /usr/local/lib/python3.9/site-packages/tuya_iot/openmq.py:121 First occurred: 12:25:11 PM (219 occurrences) Last logged: 3:34:11 PM

Unexpected disconnection.1

The detailed log is very long, here is a sample

2021-08-20 14:55:26 ERROR (Thread-94) [tuya iot] Unexpected disconnection.1 2021-08-20 14:55:28 DEBUG (Thread-94) [tuya iot] _on_log: Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'cloud_1899e854fc6a07bd40571bf4efedd5b8' 2021-08-20 14:55:28 DEBUG (Thread-94) [tuya iot] _on_log: Received CONNACK (0, 0) 2021-08-20 14:55:28 DEBUG (Thread-94) [tuya iot] connect flags->{'session present': 0}, rc->0 2021-08-20 14:55:28 DEBUG (Thread-94) [tuya iot] _on_log: Sending SUBSCRIBE (d0, m40) [(b'cloud/token/in/988a354575308b78f6674f178fbf8f8d', 0)] 2021-08-20 14:55:28 DEBUG (Thread-94) [tuya iot] _on_log: Received SUBACK 2021-08-20 14:55:28 DEBUG (Thread-94) [tuya iot] _on_subscribe: 40 2021-08-20 14:56:11 DEBUG (Thread-94) [tuya iot] _on_log: failed to receive on socket: [Errno 104] Connection reset by peer 2021-08-20 14:56:11 ERROR (Thread-94) [tuya iot] Unexpected disconnection.1 2021-08-20 14:56:13 DEBUG (Thread-94) [tuya iot] _on_log: Sending CONNECT (u1, p1, wr0, wq0, wf0, c1, k60) client_id=b'cloud_1899e854fc6a07bd40571bf4efedd5b8' 2021-08-20 14:56:13 DEBUG (Thread-94) [tuya iot] _on_log: Received CONNACK (0, 0) 2021-08-20 14:56:13 DEBUG (Thread-94) [tuya iot] connect flags->{'session present': 0}, rc->0 2021-08-20 14:56:13 DEBUG (Thread-94) [tuya iot] _on_log: Sending SUBSCRIBE (d0, m41) [(b'cloud/token/in/988a354575308b78f6674f178fbf8f8d', 0)] 2021-08-20 14:56:13 DEBUG (Thread-94) [tuya iot] _on_log: Received SUBACK 2021-08-20 14:56:13 DEBUG (Thread-94) [tuya iot] _on_subscribe: 41 2021-08-20 14:56:56 DEBUG (Thread-94) [tuya iot] _on_log: failed to receive on socket: [Errno 104] Connection reset by peer 2021-08-20 14:56:56 ERROR (Thread-94) [tuya iot] Unexpected disconnection.1

zraken commented 3 years ago

I was having the same issue and simply re-starting HA did not fix the problem. I was also correctly subscribed to device notifications already. Anyway, I deleted the integration and re-setup Tuya and restarted HA, now it works. Note that after re-setting up the integration the devices and entities showed up but the problem persisted with the UI not updating with the correct status until I restarted HA.

zraken commented 3 years ago

Looks like I am back to having the same problem as described in the original post. One more thing I noticed is that when I (say) turn on a switch from HA UI the switch status goes back to off state even though the switch turned on. Now if I try to turn on the switch again from the UI the UI status quickly resets back to the off position. However, if I am able to click the UI again very quickly before it goes back to off status then I am able to turn off the switch. The leads me to believe that the problem is related to the switch state not being reflected correctly, I observe the same effect if I externally control the switch - in this case also the updated state is not reflected in the UI. I do have "device status notification" subscription enabled at Tuya:Cloud/My Services/All Services.