Symptoms:
sometimes you don’t get the correct status of a light
digging into the debug logs, you can see that sometimes a POST is done to Tuya with a wrong token, a new token will be generated, but the POST action is not repeated (thus light will not be turned on in my case)
typical log:
2022-09-19 15:32:48.845 DEBUG (Thread-10 (_thread_main)) [tuya_iot] _on_log: Sending PINGREQ
2022-09-19 15:32:48.873 DEBUG (Thread-10 (_thread_main)) [tuya_iot] _on_log: Received PINGRESP
2022-09-19 15:33:21.383 DEBUG (SyncWorker_10) [tuya_iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/devices/bf9f25b49af00347bf85fj/commands, params = None, body = {'commands': [{'code': <DPCode.SWITCH_LED: 'switch_led'>, 'value': True}]}, t = 1663594401383
2022-09-19 15:33:21.625 DEBUG (SyncWorker_10) [tuya_iot] Response: {
"code": 1010,
"msg": "token invalid",
"success": false,
"t": 1663594400802,
"tid": "a09b01a3381f11ed81b21613c76f6213"
}
2022-09-19 15:33:21.626 DEBUG (SyncWorker_10) [tuya_iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/iot-01/associated-users/actions/authorized-login, params = None, body = {'username': '[email protected] ', 'password': '***', 'country_code': '32', 'schema': 'tuyaSmart'}, t = 1663594401626
2022-09-19 15:33:21.788 DEBUG (SyncWorker_10) [tuya_iot] Response: {
"result": {
"access_token": "***",
"expire_time": 7200,
"platform_url": "https://openapi.tuyaeu.com",
"refresh_token": "***",
"uid": "***"
},
"success": true,
"t": 1663594400933,
"tid": "a0a49990381f11eda6de1a46e4e2cc74"
}
2022-09-19 15:33:48.943 DEBUG (Thread-10 (_thread_main)) [tuya_iot] _on_log: Sending PINGREQ
2022-09-19 15:33:48.971 DEBUG (Thread-10 (_thread_main)) [tuya_iot] _on_log: Received PINGRESP
2022-09-19 15:34:49.048 DEBUG (Thread-10 (_thread_main)) [tuya_iot] _on_log: Sending PINGREQ
2022-09-19 15:34:49.079 DEBUG (Thread-10 (_thread_main)) [tuya_iot] _on_log: Received PINGRESP
Does anybody experience the same problem with the TUYA Cloud integration?
kind regards,
Bart Plessers
See also
opened 01:41PM - 19 Sep 22 UTC
bug
**Describe the bug**
The symptoms are clearly described in https://github.com… /tuya/tuya-home-assistant/issues/844, but I will repeat it here again because both are different issues.
Symptoms:
- sometimes you don't get the correct status of a light
- digging into the debug logs, you can see that sometimes a POST is done to Tuya with a wrong token, a new token will be generated, but the POST action is not repeated (thus light will not be turned on in my case)
typical log:
```
2022-09-19 15:32:48.845 DEBUG (Thread-10 (_thread_main)) [tuya_iot] _on_log: Sending PINGREQ
2022-09-19 15:32:48.873 DEBUG (Thread-10 (_thread_main)) [tuya_iot] _on_log: Received PINGRESP
2022-09-19 15:33:21.383 DEBUG (SyncWorker_10) [tuya_iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/devices/bf9f25b49af00347bf85fj/commands, params = None, body = {'commands': [{'code': <DPCode.SWITCH_LED: 'switch_led'>, 'value': True}]}, t = 1663594401383
2022-09-19 15:33:21.625 DEBUG (SyncWorker_10) [tuya_iot] Response: {
"code": 1010,
"msg": "token invalid",
"success": false,
"t": 1663594400802,
"tid": "a09b01a3381f11ed81b21613c76f6213"
}
2022-09-19 15:33:21.626 DEBUG (SyncWorker_10) [tuya_iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/iot-01/associated-users/actions/authorized-login, params = None, body = {'username': '[email protected] ', 'password': '***', 'country_code': '32', 'schema': 'tuyaSmart'}, t = 1663594401626
2022-09-19 15:33:21.788 DEBUG (SyncWorker_10) [tuya_iot] Response: {
"result": {
"access_token": "***",
"expire_time": 7200,
"platform_url": "https://openapi.tuyaeu.com",
"refresh_token": "***",
"uid": "***"
},
"success": true,
"t": 1663594400933,
"tid": "a0a49990381f11eda6de1a46e4e2cc74"
}
2022-09-19 15:33:48.943 DEBUG (Thread-10 (_thread_main)) [tuya_iot] _on_log: Sending PINGREQ
2022-09-19 15:33:48.971 DEBUG (Thread-10 (_thread_main)) [tuya_iot] _on_log: Received PINGRESP
2022-09-19 15:34:49.048 DEBUG (Thread-10 (_thread_main)) [tuya_iot] _on_log: Sending PINGREQ
2022-09-19 15:34:49.079 DEBUG (Thread-10 (_thread_main)) [tuya_iot] _on_log: Received PINGRESP
```
**Expected behavior**
- Tuya integration works with correct token
- or original webservice request will be repeated after receiving a correct token
**Additional context**
I noticed that -when debugging https://github.com/tuya/tuya-home-assistant/issues/844, it had to do with 2 instances of Home Assistant running on my network, both with the Tuya integration: server `RPI-86` and server `RPI-87`
It seems that if I reload the Tuya integration on `RPI-87`, the status is correctly displayed and updated on this instance for a while, but not correct anymore on `RPI-86`.
Same the other way: if I reload the Tuya integration on `RPI-86`, things will work correct there, but the Home Assistant instance running on `RPI-87` does not show status updates.
Apparently, you can't run 2 instances of HA with Tuya integration on the same time.
However, on the tuya app on my phone (configured with same user), everythings works fine, together with (one of my instances of) Home Assistant, so concurrent use most be possible.
Any help is appreciated!
kind regards,
Bart
opened 03:12PM - 09 Sep 22 UTC
bug
**Description**
I use home assistant with tuya integration.
Everything works… well, but I noticed that in the morning, I can turn ON my light, but I can’t turn it OFF anymore.
This is because my automation TOGGLE's the light:
```
# -----------------------------------------------
- id: '0x00158d000428fb20_action_single_right'
alias: (S09) switch action single_right
initial_state: true
trigger:
- entity_id: sensor.my_n01_p03_switch_s09_wandschakelaar_action
platform: state
to: single_right
action:
- entity_id: light.group_n01_p03_wastafel
service: light.toggle
# -----------------------------------------------
```
and apparently the new STATUS of the light is not recognized.
So what happens:
- light is off
- toggle command turns it on
- but status (in hass) seems to remain off
If I push my switch again,
- light is on (but hass thinks its off)
- hass sends command to turn it on (but it is already on)
If I just reload my Tuya automations, things works perfect for “a while”. Don’t know for witch period, but it I notice that in the morning it has above behavior
Does anybody has the same experience?
Resolution?
kind regards,
Bart
**Expected behavior**
The status of Tuya devices is correctly displayed in HASS
**Diagnostics for integrations and devices**
see
[config_entry-tuya-179341e4676b8c0e6284065b58a431f9.json.txt](https://github.com/tuya/tuya-home-assistant/files/9536583/config_entry-tuya-179341e4676b8c0e6284065b58a431f9.json.txt)
**Home Assistant Version**
Home Assistant 2022.9.1
**Device info (please complete the following information, which can be found in [log]
"name": "Badkamer - Wastafel ",
"model": "ST2776G Wifi+\u84dd\u7259BLE",
"category": "dj",
"product_id": "0xmtemznyuvx7iim",
"product_name": "Up/Down Light RGB+CCT",
"online": true,
"sub": false,
(for more details, see attached file)
Toby1
(Toby)
December 18, 2022, 11:37pm
2
I had the same problem and took me ages to work out the cause was my two HA instances. To fix it, you can create two projects in tuya cloud. You then need to make sure the smartlife app in tuya cloud is linked to each project. You now have client credentials specific to each project and so now you can use per instance when setting up the tuya integration in HA.
1 Like