SecKatie / ha-wyzeapi

Home Assistant Integration for Wyze devices.
733 stars 112 forks source link

[Bug] Sensors are not working #78

Closed onlinegill closed 3 years ago

onlinegill commented 3 years ago

After updating none of sensors are updating. I can see them on wyze app that they are working otherwise I would think wyze server api is broken

mistersidd23 commented 3 years ago

Having the same issue since last update. I have motion and door sensors, but only motion affected for me.

Edit 0.53 update fixed this issue for me. Thank you!

rugene76 commented 3 years ago

I just updated to .53 and am experiencing some issues:

Everything is working as expected on the Wyze app.

I had 3 sensors that were already configured that continue to work and my lights still operate normally except that the motion sensor state is not updating reliably and goes to "unavailable" . Previously this was working fine.

My previously configured lock is no longer detected.

I've added several more sensors. All the new sensors are discovered but are not updating their states. Here's the reported parameters for one of the new sensors: state false available true mac 779027A7 battery level 89 rssi 32 device model DWS3U last action 2020-09-01T19:52:02+00:00

rugene76 commented 3 years ago

Here's some more data from the log related to the wyze switches and lock:

Note that "avaiable" is misspelled - should be "available"<<<<<< switch related: wyzeapi: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 335, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 454, in async_device_update await self.async_update() # type: ignore File "/config/custom_components/wyzeapi/switch.py", line 106, in async_update await self.client.update(self.switch) File "/config/custom_components/wyzeapi/wyzeapi/client.py", line 238, in update prop_map = device.prop_map() File "/config/custom_components/wyzeapi/wyzeapi/devices/switch.py", line 30, in prop_map "P5": self.avaliable, AttributeError: 'Switch' object has no attribute 'avaliable'

Lock related: wyzeapi: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 335, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 454, in async_device_update await self.async_update() # type: ignore File "/config/custom_components/wyzeapi/lock.py", line 127, in async_update await self.client.update(self.lock) File "/config/custom_components/wyzeapi/wyzeapi/client.py", line 238, in update prop_map = device.prop_map() File "/config/custom_components/wyzeapi/wyzeapi/devices/lock.py", line 20, in prop_map "P5": self.avaliable, AttributeError: 'Lock' object has no attribute 'avaliable'

SecKatie commented 3 years ago

@rugene76 that is super useful thank you! This seems to be related to #79

SecKatie commented 3 years ago

@onlinegill can you give more information. Just the other day v0.5.3 was working for you?

Thank you @rugene76 I have updated the lock and the switch code. v0.5.5 is available to download

onlinegill commented 3 years ago

@onlinegill can you give more information. Just the other day v0.5.3 was working for you?

Thank you @rugene76 I have updated the lock and the switch code. v0.5.5 is available to download

When you updated than I was able to see motion sensors which were missing but than I notice none of sensors are getting updated. All stays in close condition. I try to reinstall api multiple times but no luck.

rugene76 commented 3 years ago

Hi Joshua!

Thanks for all the fine work you are doing! I wish Wyze would officially support your work…..

Here’s what I see: available is misspelled in a few places.

In both lock.py and switch.py: @property def available(self): """Return the connection status of this switch""" return self.__switch.avaliable hope that helps

Gene

rugene76 commented 3 years ago

just downloaded and tested the code - lock.py still has the misspelling, sensors not updating.....

SecKatie commented 3 years ago

Ok v0.5.6 should have fixed the misspellings on the lock. I do not know what is happening with the sensors.

SecKatie commented 3 years ago

@rugene76 are there any logs for the sensors?

SecKatie commented 3 years ago

They should be polling every five seconds. @rugene76 or @onlinegill can one or both of you setup debug logging for me?

logger:
  default: warning
  logs:
    custom_components.wyzeapi: debug
rugene76 commented 3 years ago

I continue to have the issue that the sensor's state is not updating, so here's some more info that might be helpful: -I'm at the latest HA environment on a Raspberry PI 4 -Running wyzeapi ver. .56 installed with hacs -I have 1 lock (soon to be 5) , 4 lights, 5 cameras, 1 scale, 2 switches, 7 contact sensors, 2 motion sensors -I also have the latest wysesense integrations with 3 sensors connected that is working as expected -the wyze android app has all devices working as expected

-from ha/wyzeapi, the lights and switches work as expected. The sensors are discovered but never update status

-Logging is enabled, no wyseapi errors are reported on startup, here's a snippet of the log file that repeats every 5 seconds (maybe that's too fast and the wyze backend is blocking too frequent updates?) :

------------------------------------------------------------------------
2020-09-02 09:53:33 DEBUG (MainThread) [custom_components.wyzeapi] 
-------------------------------------------------------------------
Wyze Bulb and Switch Home Assistant Integration

Version: v0.5.6
This is a custom integration
If you have any issues with this you need to open an issue here:
https://github.com/JoshuaMulliken/ha-wyzeapi/issues
-------------------------------------------------------------------
2020-09-02 09:53:33 DEBUG (MainThread) [custom_components.wyzeapi] Creating new WyzeApi component
2020-09-02 09:53:33 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running login
2020-09-02 09:53:33 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __create_md5_md5
2020-09-02 09:53:33 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __create_payload
2020-09-02 09:53:33 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __post_to_server
2020-09-02 09:53:34 WARNING (MainThread) [homeassistant.components.asuswrt] Error [[Errno 111] Connect call failed ('10.0.0.1', 22)] connecting asuswrt to 10.0.0.1. Will retry in 60 seconds...
2020-09-02 09:53:37 WARNING (MainThread) [homeassistant.components.mobile_app.notify] Found duplicate device name SHT-W09
2020-09-02 09:53:37 WARNING (MainThread) [homeassistant.components.mobile_app.notify] Found duplicate device name SHT-W09
2020-09-02 09:53:37 DEBUG (MainThread) [custom_components.wyzeapi] Connected to Wyze account
2020-09-02 09:53:37 DEBUG (MainThread) [custom_components.wyzeapi] Starting WyzeApi components
2020-09-02 09:53:37 DEBUG (MainThread) [custom_components.wyzeapi] Starting WyzeApi Lights
2020-09-02 09:53:38 DEBUG (MainThread) [custom_components.wyzeapi] Starting WyzeApi switches
2020-09-02 09:53:38 DEBUG (MainThread) [custom_components.wyzeapi] Starting WyzeApi Sensors
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi] Starting WyzeApi lock
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.lock] Creating new WyzeApi Lock component
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running list_locks
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running get_devices
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __create_authenticated_payload
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __create_payload
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __post_to_server
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.light] Creating new WyzeApi light component
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running list_bulbs
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running get_devices
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.switch] Creating new WyzeApi switch component
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running list_switches
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running get_devices
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.binary_sensor] Creating new WyzeApi binary_sensor component
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running list_contact_sensors
2020-09-02 09:53:39 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running get_devices
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.lock] Binary Locks doing a update.
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __create_authenticated_payload
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __create_payload
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __post_and_recover
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __post_to_server
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running list_motion_sensors
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running get_devices
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __create_authenticated_payload
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __create_payload
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __post_and_recover
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __post_to_server
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __create_authenticated_payload
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __create_payload
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __post_and_recover
2020-09-02 09:53:42 DEBUG (MainThread) [custom_components.wyzeapi.wyzeapi.client] Running __post_to_server
rugene76 commented 3 years ago

more info: I changed the polling on the binary_sensor to 30 sec - no improvement.

I've noticed the first poll cycle reads the correct sensor state, after that , the states never get updated

I've noticed when checking the sensor entity parameters that the reported sensor state (bar) does not match the "open" sensor state This behavior is inconsistent across the sensors.

image

SecKatie commented 3 years ago

Hmm. I do not know what is happening... There isn't much here to go on. From your screenshot and log it looks like everything is working.

SecKatie commented 3 years ago

I am going to look into this tomorrow. There is something going on in the update logic I bet. I'll put some more logging and see if I can figure it out.

If it's not working for the sensors then it must not be working for any of them

SecKatie commented 3 years ago

Ok great news! I found some problems in my update code!! @everyone I will be pushing a new update in a few minutes.

SecKatie commented 3 years ago

@rugene76 @onlinegill A new update is available. It should work now!

onlinegill commented 3 years ago

Thanks I will check.

SecKatie commented 3 years ago

Great @onlinegill. Thank you for your help and issue submissions.

onlinegill commented 3 years ago

Great @onlinegill. Thank you for your help and issue submissions.

No problem do know what was wrong ? I was banging my head as i use this api for HA alarm system and temporary i was able to workaround by setting up getting webhook request from wyze through IFTTT than trigger alarm. Also i am working on zigbee devices but due to too much wifi interfere cant pair sensors so have no other choice than use to wyze sensors

rugene76 commented 3 years ago

I just tried the latest - seems to be working - well done. Thank you. I've got 2 motion sensors and 7 contact sensors that are responding as expected. My lock is also reporting correctly. I'd suggest changing the lock status to read "locked" and "unlocked". The current states imply action. Anyway, thanks for all your efforts.