rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.85k stars 546 forks source link

Deactivated device are still polled #1418

Open GaPhi opened 1 year ago

GaPhi commented 1 year ago

The problem

I have many Tuya devices and not all are used 100% of the time. I then deactivate them but Localtuya still tries to connect to them filling logs up...

Environment

Steps to reproduce

  1. Unplug a device tuya
  2. Deactivate the device in Home Assistant
  3. Check the logs

DP dump

N/A

Provide Home Assistant traceback/logs

2023-06-02 23:09:36.159 WARNING (MainThread) [custom_components.localtuya.common] [512...da4] Failed to connect to 192.168.1.81: [Errno 113] Connect call failed ('192.168.1.81', 6668)
2023-06-02 23:09:36.164 WARNING (MainThread) [custom_components.localtuya.common] [308...71f] Failed to connect to 192.168.1.84: [Errno 113] Connect call failed ('192.168.1.84', 6668)
2023-06-02 23:09:36.168 WARNING (MainThread) [custom_components.localtuya.common] [bff...hk1] Failed to connect to 192.168.1.77: [Errno 113] Connect call failed ('192.168.1.77', 6668)

Additional information

boheme61 commented 1 year ago

Same for me, for quite awhile( several months ), ... very annoying, and beside log fills with these attempt ( alot 1000-30000 and more ), it basically means CPU usage and disk-writing :( And same goes for (not even for disabled devices) , but if i "unplug" some plugs/switches (which i do on regular basis) , or runs "Home-Scheme" ( Turn of certain Cams/sensors, by turning of plugs/Switches )

donburch888 commented 1 year ago

Same. I have a couple of devices which I am not currently using, so have disabled them through the GUI. Shouldn't be necessary to delete them, then add again when I next want to use them.

But they still generate errors in the log, which means I find I am ignoring other devices which might have gone unavailable; as well as wasting CPU and wi-fi bandwidth.

boheme61 commented 1 year ago

@rospogrigio

Could you please have a look at this, i guess there are many who have devices either unplugged/disconnected or disabled, And it's a quite alot "ERRNO 113" several each minute Atleast you could commend or suggest how we can avoid this, as it not only filling the logs but also writes to disk, for no reason, removing/unplugging a device should not cause this behavior(repeatedly eternally) , i'm not a programmer/dev but i've not experience other integrations causing this, by unplugging an IP device(Not repeatedly eternally) for days/weeks/month

Edit: Most people restart HA each month(during monthly update, or othervice), IF a Device in LocalTuya is not "available" after certain attempts (or cording to device_tracker/ -or similar) then issue a warning, and forget about it, until next restart of integration/HA , ... or simply don't issue this "Warning" in the logs, people will notice if a device is not "plugged in" or not working, and this particular "Warning" doesn't give the users "meat" in/for trouble-shooting purposes anyway.

16 08 2023_17 54 36_REC

16 08 2023_17 59 18_REC

boheme61 commented 1 year ago

Working Workaround ( for me )

In configuration.yaml set logger for LocalTuya to "Critical"

logger:
  default: error
  logs:
    custom_components.localtuya.common: critical

Cording to suggestion from HA-Community: https://community.home-assistant.io/t/repeated-errors-on-disabled-device/533393/4?u=boheme61