romedtino / simple-wyze-vac

Home Assistant Custom Component for Wyze Vacuum
48 stars 8 forks source link

[BUG] Enabling Polling causes the wyzevac to become unavailable. #46

Closed surfrock66 closed 1 year ago

surfrock66 commented 1 year ago

Describe the bug Using this plugin, the integration works fine and I can see my vacuum, control it, and see the map. If I configure the integration and enable polling (00:00:60 or 1 minute), the entity for the main vac gets a red refresh arrow next to it with hovertext "restored" and clicking the entity provides the message "This entity is no longer being provided by the simple_wyze_vac integration. If the entity is no longer in use, delete it in settings."

The only way I have found to get the entity back is to delete and readd the integration, including going through the TOTP procedure again, which is a high amount of effort. Disabling polling does not bring the entity back.

To Reproduce Steps to reproduce the behavior:

  1. Go to "Settings" then "Devices and Services" and then "Integrations"
  2. Click on "Configure" on the "Simple Wyza Vac" card
  3. Check the box for polling, and enter the value "00:00:60" then click submit
  4. Click the entities list for that integration to see the vacuum unavailable.

Expected behavior I expect polling to be enabled and the device to remain available

Screenshots image image

Simple Wyze Vac Version

Wyze Vacuum Firmware Version

Home Assistant Version

surfrock66 commented 1 year ago

Oh additionally, I have tried:

romedtino commented 1 year ago

Hey, so I think the issue here is the way the time is verified 00:00:60 is essentially the same as 00:01:00. The method I use to verify if it is a valid time is a python library called voluptuous and the rules for time, specifically the seconds portion is that it has to be a number from 0 to 59. You should have seen something in your logs that throws that error, something like:

2022-10-10 22:17:03.512 ERROR (MainThread) [homeassistant.components.vacuum] Error while setting up simple_wyze_vac platform for vacuum
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/simple_wyze_vac/vacuum.py", line 77, in async_setup_entry
t = datetime.strptime(hass.data[WYZE_SCAN_INTERVAL],"%H:%M:%S")
File "/usr/local/lib/python3.10/_strptime.py", line 579, in _strptime_datetime
return cls(*args)
ValueError: second must be in 0..59

when you had input the value.

In short, to solve your issue, just change it from 00:00:60 to 00:01:00. Be warned though, I think that value is a bit low and you might get rate limited by Wyze servers.

surfrock66 commented 1 year ago

That fixed it. I set it to 10 minutes now, do you think they would throttle at 5 though?

romedtino commented 1 year ago

It's honestly hard to say because it's not public information and could be one of those things that work for a bit and suddenly stop working. If you're willing to take the risk, you can always set it to 5 and if you notice it stops working (or there's spam in your logs regarding Wyze vac not working) you can disable polling, wait for a bit and try a higher value in a few hours.

surfrock66 commented 1 year ago

I'll keep it at 10 for now, thanks!