h4 / LYWSD02-home-assistant

Home-Assistant sensor for LYWSD02 Thermometer
75 stars 12 forks source link

No temp/humid data #4

Closed szogi closed 4 years ago

szogi commented 5 years ago

I started using your code (thx!) yesterday, but I got none/none for temp/humid:

{'temperature': None, 'humidity': None, 'time': datetime.datetime(2019, 8, 25, 16, 30, 15)}

Also in log: 2019-08-25 16:34:16 ERROR (MainThread) [custom_components.lywsd02] Could not update data - Failed to connect to peripheral 3F:59:XXXXXXXX, addr type: public

AND

Aug 25 16:43:28 ln-assistant hass[27050]: 2019-08-25 16:43:28 ERROR (MainThread) [custom_components.lywsd02] Could not update data - Failed to connect to peripheral 3F:59:XXXXXXXXXX, addr type: public Aug 25 16:43:28 ln-assistant hass[27050]: 2019-08-25 16:43:28 ERROR (MainThread) [homeassistant.components.sensor] lywsd02: Error on device update! Aug 25 16:43:28 ln-assistant hass[27050]: Traceback (most recent call last): Aug 25 16:43:28 ln-assistant hass[27050]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 291, in _async_add_entity Aug 25 16:43:28 ln-assistant hass[27050]: await entity.async_device_update(warning=False) Aug 25 16:43:28 ln-assistant hass[27050]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 417, in async_device_update Aug 25 16:43:28 ln-assistant hass[27050]: await self.async_update() Aug 25 16:43:28 ln-assistant hass[27050]: File "/home/homeassistant/.homeassistant/custom_components/lywsd02/sensor.py", line 33, in async_update Aug 25 16:43:28 ln-assistant hass[27050]: updated = self.hass.data[DOMAIN_DATA]["data"] Aug 25 16:43:28 ln-assistant hass[27050]: KeyError: 'data'

When HA trying to query the device, the BT indicator on the device light up. Also, another BT device (xiaomi BT LCD temp/humid sensor) working in HA, so BT config might be OK.

jintytam commented 5 years ago

I encountered the same problem, homeassistant version==0.97.2,It's working properly before upgrading.

h4 commented 5 years ago

@szogi try to locate thermometer closer to you're HA Hub, this Thermo has different hardware from xiaomi BT LCD and looks like it has lower power BT.

@jintytam I use HA v0.97.0 right now and everything is OK. I'm going to upgrade my HA and check connection problem as soon as I'll return from my vacation, on 15th September.

devaux commented 4 years ago

Same here. I only get time. No temp or humidity. Latest firmware with Home Assistant 0.98.5.

jintytam commented 4 years ago

Same here. I only get time. No temp or humidity. Latest firmware with Home Assistant 0.98.5.

This problem was solved after h4 upgraded lwsd02 First, upgrade the lywsd02 version:pip install --upgrade lywsd02 Then, you need to modify the file ". homeassistant / custom_components / lywsd02 / manifest. JSON}" {"requirements": ["lywsd02==0.0.2"]}change to {"requirements": ["lywsd02==0.0.3"]} Finally, delete the folder ".homeassistant/custom_components/lywsd02/pycache" and reboot HA. Good Luck!

devaux commented 4 years ago

Thank you very much! Solved with changing the manifest and updating to lywsd02 0.0.3. Works flawlessly with homeassistant 0.99.3 so far :)

h4 commented 4 years ago

I've just updated manifest.json so this component should work out of the box.