ollo69 / ha_tuya_custom

Tuya Custom Component for testing
Apache License 2.0
39 stars 18 forks source link

Lights works perfect but Switches have random delay #25

Open Zkaning opened 3 years ago

Zkaning commented 3 years ago

Tested to install a fresh setup on both RaspPi3b+ and Virtual machine running Linux on a Laptop. Everything is the latest version, including tuya_custom. Get the same problem on both. Smartlife app is instant and I have a 100Gb fiber with a netgear nighthawk router. The Lights are working instant! but the switches are randomly delayed up to 30s. The logfile: "Updating tuya_custom switch took longer than the scheduled update interval 0:00:15" Any ide on what can cause this and am I the only one with this problem?

ollo69 commented 3 years ago

The Tuya API Cloud not always respond, this is an issue not related to the component. To better investigate you should enable debug and post here your log file. Please provide also some additional detail:

Zkaning commented 3 years ago

I put this in config file: " logger: default: info logs: custom_components.tuya: debug "

After 15min I got this in the logger: Updating tuya_custom switch took longer than the scheduled update interval 0:00:15 3:14:13 PM – Switch (WARNING) - message first occurred at 2:57:13 PM and shows up 35 times Error doing job: Task exception was never retrieved 3:11:48 PM – components/discovery/init.py (ERROR) You are using a custom integration for tuya which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant. 2:58:14 PM – loader.py (WARNING) - message first occurred at 2:58:14 PM and shows up 2 times

I have 35 switches connected but they all works instant when using smartlife app. If I disconnect 25 of them the same problem is still showing. The delay is variating between 3s to 30s The response is sometimes instant (as in the smartlife app) and sometimes delayed as described above, it is random :(

Thanks for you reply!! // Fredrik

ollo69 commented 3 years ago

To have right debug log you should put this line (with right indentation):

logger:
  default: info
  logs:
    custom_components.tuya_custom: debug

Anyway consider that the problem is related to the Cloud API dedicated to HA, that from some months are limited in number of possible requests. Considering the number of switchs, you can consider a delay of 30s a good result, will be very hard to have better result, also because this component use cloud poll and so you will never have a real time status refresh. Consider as alternative option to flash your device with Tasmota (if applicable) and control them locally using MQTT. Remote control should be managed using Alexa and Tasmota Hue emulation.

Shaman2 commented 3 years ago

May you can try TuyaGateway, I try to use it one week and this addon work without any delay, work as localtuya, but faster. More difficult to set up, but the only component for HA that works without delay. I use it parallel with tuya_custom for testing

Zkaning commented 3 years ago

Ok, I actually used that indentation, just forgot the ".tuya_custom: debug" instead of ".tuya: debug" Unfortunaly I dont find many of my tuya devices in the library for tasmota :( Will try it again today, but, do you have any experience of using "TuyaGateway" @ollo69 ? https://github.com/TradeFace/tuyagateway

Zkaning commented 3 years ago

May you can try TuyaGateway, I try to use it one week and this addon work without any delay, work as localtuya, but faster. More difficult to set up, but the only component for HA that works without delay. I use it parallel with tuya_custom for testing

Thanks for the tip, I would really like to try this! But I get stuck because my limited knowledge in coding but I found the addon now so will test that!

Zkaning commented 3 years ago

May you can try TuyaGateway, I try to use it one week and this addon work without any delay, work as localtuya, but faster. More difficult to set up, but the only component for HA that works without delay. I use it parallel with tuya_custom for testing

@shaman2 How do I run this? npm i @tuyapi/cli -g

Shaman2 commented 3 years ago

May you can try TuyaGateway, I try to use it one week and this addon work without any delay, work as localtuya, but faster. More difficult to set up, but the only component for HA that works without delay. I use it parallel with tuya_custom for testing

@Shaman2 How do I run this? npm i @tuyapi/cli -g

no, install addon for home assistant https://github.com/sjthespian/addon-tuyagateway

for get localkey I uses LDPlayer4, where install Packet Capture and TuyaSmart (old version 3.11). Its very simple for me without command line

Zkaning commented 3 years ago

@Shaman2 Thanks for the tip! When retrieving the packages, how did you find the localkey?