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
880 stars 207 forks source link

Switch goes back to off regardless of toggling it on or off. #546

Open mmatus1112 opened 3 years ago

mmatus1112 commented 3 years ago

I have a smart power strip with 6 smart plugs. I can see them in HA, however, they all show as toggled off. If I toggle them on, the device comes on, the toggle comes back off immediately but the plug remains on. To turn it off, I have to toggle on and toggle off quickly. So, I think the problem is that HA is not showing the current state of the devices.

de3pkeeper commented 3 years ago

Same thing happening here since the official release of the integration. The device is a 5KW, 32A electrical switch - model designation L821X. All 6 required API authorizations are added to the cloud account project. The Home Assistant representation of the entity does not retain the current status of the device.

This affects not only the visual representation, but also HA state history and Automations that use the switch state as condition/trigger.

Example:

Starting from states:

Action Sequence Performed Actions Physical Switch State Cloud Device State Home Assistant Representation State
1 Human operates physical switch: OFF --> ON ON ON Remains OFF
2 Human toggles Switch representation in HA UI: OFF --> ON ON ON Toggles to ON, 2 seconds pass, returns back to OFF
3 Human rapidly toggles Switch's visual representation in HA UI (within <2 seconds): OFF --> ON --> OFF OFF OFF OFF
4 Automation_1 runs and toggles switch: OFF --> ON ON ON OFF
5 Automation_2 runs and uses condition: If the switch is ON, then turn it OFF Remains ON Remains ON Has remained OFF and has caused the condition check to eval to false
6 Automation_3 runs: if time(now) == 13:00: turn switch --> OFF OFF OFF OFF
7 Automation_3 runs: if time(now) == 15:00: turn switch --> ON ON ON OFF
shorenster commented 3 years ago

Facing the same issue here with all my tuya devices. I already double checked and im corretly subscribed into device status API on IOT plataform.

I'am using HA supervised, core updated to last version. Tuya V2 in the last release v 1.50

thomo55 commented 3 years ago

Same for me, updated to lated ha version, created tuya iot project added 25 devices and now the toggle is not working properly. Any fixes yet, before I delete tuya integration?

cjackson234 commented 3 years ago

Same here. Hoping for a fix soon.

henriquelssantiago commented 3 years ago

All my tuya devices is facing the same issue. I realized that HA gets only the state of the device when HA starts. After that, the status doesn't change anymore, and when I toggle something, the status changes, but goes back to what it was before

for example: ezgif com-gif-maker

in that example, we can see different values to energy monitoring:

4c9f008d-d032-4c42-8c50-5a55f92dad5e

Sem título

33mA was the value exactly at the time when HA started.

Plargio commented 3 years ago

I am also having the same issues describe in the thread. Everything updated to latest versions

Plargio commented 3 years ago

I was able to resolve my issue by doing the following

1) making sure that I had Device Status Notification added in My Services in the Tuya IoT Platform 2) making sure that my project was added to the Device Status Notification service image 3) a new Access ID/Client ID and Access Secret/Client Secret were generated after I added the Device Status Notification, so I had to update them in my Home Assistant Tuya setup.

And now the switches toggle properly and stay on the correct setting.

Step 2 is very important, because it looks like the project is not automatically added when the service is added; it has to be manually added.

Hope this helps so of you.

thomo55 commented 3 years ago

thank you so much my tuya devices now responding ok.

On Thu, Oct 14, 2021 at 7:01 AM Plargio @.***> wrote:

I was able to resolve my issue by doing the following

  1. making sure that I had Device Status Notification added in My Services in the Tuya IoT Platform
  2. making sure that my project was added to the Device Status Notification service [image: image] https://user-images.githubusercontent.com/34261031/137203987-da561f69-7270-4456-af70-44cd3dd178f9.png 3)a new Access ID/Client ID and Access Secret/Client Secret were generated after I added the Device Status Notification, so I had to update them in my Home Assistant Tuya setup.

And now the switched toggle properly and stay on the correct setting.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tuya/tuya-home-assistant/issues/546#issuecomment-942673458, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKLZAPYORLZX7JHRJRS2J2LUGXQQDANCNFSM5FV4REQQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

de3pkeeper commented 3 years ago

For my case I had to create a new Cloud project and make sure that ALL 6 authorizations (including Device Status Notification) were added during the project creation wizard. With the original project it did not matter whether I removed or added authorizations, removed or added SmartLife/Tuya app accounts - the device status would not update.

kevegabi commented 3 years ago

hello!

same problem here. core-2021.10.4, supervisor-2021.10.0, Home Assistant OS 6.5 tuya_v2: 1.6.0

When HA start, it show the device correct status, but later, not changed anything. When i try to change the status by hand, nothing happend. The log, after HA started: 2021-10-15 21:54:33 DEBUG (Thread-4) [tuya iot] _on_log: Sending PINGREQ 2021-10-15 21:54:33 DEBUG (Thread-4) [tuya iot] _on_log: Received PINGRESP 2021-10-15 21:55:33 DEBUG (Thread-4) [tuya iot] _on_log: Sending PINGREQ 2021-10-15 21:55:34 DEBUG (Thread-4) [tuya iot] _on_log: Received PINGRESP 2021-10-15 21:56:34 DEBUG (Thread-4) [tuya iot] _on_log: Sending PINGREQ 2021-10-15 21:56:34 DEBUG (Thread-4) [tuya iot] _on_log: Received PINGRESP

But nothing else. If i turn on the tuya powered switch: 2021-10-15 21:57:46 DEBUG (SyncWorker_7) [tuya iot] Request: method = POST, url = https://openapi.tuyaeu.com/v1.0/devices/xxxxxxxxxxxxxxxxxxxx/commands, params = None, body = {'commands': [{'code': 'switch_1', 'value': True}]}, t = XXXXXXXX66236 2021-10-15 21:57:46 DEBUG (SyncWorker_7) [tuya iot] Response: { "result": true, "success": true, "t": XXXXXXXX66704 }

But the switch stay off in HA.

josephus commented 3 years ago

I'm also having similar control issues with a Tuya thermostate.

By the way, what happens after the 1 month trial period expires in Tuya IOT? The device connection API subscription costs $5000.

Seems to me that we are gonna have to revert to a custom integration from this bloated ransomware

bockelaar commented 3 years ago

same here, all latest, new tuya project created. On restart HA picks up state well, toggling switch to off turns off the light but keeps the HA toggle to on. Toggling HA again the light turns on again. State seems to only update at HA restart.

zviratkos commented 3 years ago

For my case I had to create a new Cloud project and make sure that ALL 6 authorizations (including Device Status Notification) were added during the project creation wizard. With the original project it did not matter whether I removed or added authorizations, removed or added SmartLife/Tuya app accounts - the device status would not update.

Hello,

thanx, same procedure helped on my side - it was needed to create new project and add all 5 (!) authorizations and after removal (!) of Tuya integration and re-adding it again it started to work as expected. Before removal I tried only simple change of tuya auth parameters and restart HA, but still it was not working.