kevinvincent / ha-wyzesense

A Home Assistant Component to interface with the WYZE Sense hub and sensor system
370 stars 100 forks source link

Error while setting up wyzesense platform for binary_sensor #150

Open rwlove opened 4 years ago

rwlove commented 4 years ago

Home Assistant 0.110.5 INFO:homeassistant.util.package:Attempting install of wyzesense==0.0.4

2020-06-08 18:50:05 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up wyzesense platform for binary_sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for return fut.result() File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/wyzesense/binary_sensor.py", line 116, in setup_platform ws = beginConn() File "", line 2, in beginConn File "/usr/local/lib/python3.7/site-packages/retry/api.py", line 74, in retry_decorator logger) File "/usr/local/lib/python3.7/site-packages/retry/api.py", line 33, in retry_internal return f() File "/config/custom_components/wyzesense/binary_sensor.py", line 114, in beginConn return Open(config[CONF_DEVICE], on_event) File "/config/custom_components/wyzesense/wyzesense_custom.py", line 563, in Open return Dongle(device, event_handler) File "/config/custom_components/wyzesense/wyzesense_custom.py", line 297, in init__ self._Start() File "/config/custom_components/wyzesense/wyzesense_custom.py", line 494, in _Start self._Inquiry() File "/config/custom_components/wyzesense/wyzesense_custom.py", line 400, in _Inquiry resp = self._DoSimpleCommand(Packet.Inquiry()) File "/config/custom_components/wyzesense/wyzesense_custom.py", line 395, in _DoSimpleCommand self._DoCommand(pkt, cmd_handler, timeout) File "/config/custom_components/wyzesense/wyzesense_custom.py", line 381, in _DoCommand self._SendPacket(pkt) File "/config/custom_components/wyzesense/wyzesense_custom.py", line 331, in _SendPacket pkt.Send(self.__fd) File "/config/custom_components/wyzesense/wyzesense_custom.py", line 106, in Send ss = os.write(fd, pkt) OSError: [Errno 22] Invalid argument

The sensor was previously working and now is in a blinking blue/amber pattern.

jamescadd commented 4 years ago

I've had this issue in the past, but now its nearly constant. Sometimes rebooting helps but lately that seems to be less common. Appears it may be an issue related to how the config is loaded, I wonder if the semi-recent Python update in HA caused this?

2020-06-15 15:51:20 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up wyzesense platform for binary_sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT) File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for return fut.result() File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/wyzesense/binary_sensor.py", line 78, in setup_platform _LOGGER.debug("Attempting to open connection to hub at " + config[CONF_DEVICE]) TypeError: can only concatenate str (not "NoneType") to str

rwlove commented 4 years ago

If I don't specify the wyze device and I use the 'auto' functionally then wyzesense loads.

The below patch fixed the problem for me.

diff --git a/config_files/binary_sensors/wyzesense.yaml b/config_files/binary_sensors/wyzesense.yaml
index 2738a8ae..23b59dc3 100644
--- a/config_files/binary_sensors/wyzesense.yaml
+++ b/config_files/binary_sensors/wyzesense.yaml
@@ -1,2 +1,2 @@
 - platform: wyzesense
-  device: /dev/wyzesense
+  device: auto
jamescadd commented 4 years ago

@rwlove I take it this is in your configuration.yaml, and you have the file split up. I have been using auto for quite awhile and still see the issue. My guess would be if you reboot the host or restart HA enough time the issue may come back. @kevinvincent any way I can help debug this? The issue happens frequently enough that I can't depend on the sensors to work. I did set the logger to the recommended settings for creating an issue but had the same info as shown above.

rwlove commented 4 years ago

@jamescadd You're right. I import the files in binary_sensors/ as binary sensors. Here's the line from my configuration.yaml

binary_sensor: !include_dir_merge_list binary_sensors/

My environment is a bit convoluted.

I have a udev rule to create a symlink to /dev/wyzesense on my host.

I run my instance of Home Assistant in a Docker container and I map /dev/wyzesense on the host to /dev/wyze in the container. I should be consistent in my names, there's no need for a different name.

Code snippits from my run.sh script that calls docker run.

WYZE_DEV="/dev/wyzesense"
-v ${WYZE_DEV}:/dev/wyze \

Then inside the container is the above referenced configuration.yaml and binary_sensors/wyzesense.yaml.

It is also inside that container where I can only seem to get device: auto to work.

MikeTannenbaum commented 4 years ago

I'm running into this exact same issue and cannot get HA to recognize the dongle; I also cannot see the wyzesense services in the developer tools section. I'm running HA in a VM on proxmox and can confirm the HA VM sees the dongle, but can't seem to get the component to surface its services. I installed through HACS (didn't know it was a part of it!

MikeTannenbaum commented 4 years ago

I'm running into this exact same issue and cannot get HA to recognize the dongle; I also cannot see the wyzesense services in the developer tools section. I'm running HA in a VM on proxmox and can confirm the HA VM sees the dongle, but can't seem to get the component to surface its services. I installed through HACS (didn't know it was a part of it!

ok I fixed it by reverting from 0.0.9 to 0.0.8

jamescadd commented 4 years ago

@MikeTannenbaum sometimes it seems to be a timing or number of reboots issue. Would be really interested to know if you hit it again. Bummer because it's really solid when it works but this issue crops up every couple of months for me. Are you running ProxMox or another virtualized environment with USB passthrough by any chance? Have been wondering if that's contributing to the issue.

MikeTannenbaum commented 4 years ago

@jamescadd if im running 0.0.9 I get the issue no matter how hard I try. Immediately upon switching to 0.0.8 it resolved itself.

I am running proxmox now but last week had the same issue w Ubuntu 16.04 on bare metal. Now I've got proxmox w docker and it repeats.

Glad it resolved with rolling back to the older version, but obviously would prefer the latest release.