home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.49k stars 30.33k forks source link

DHT 22 error while updating #15847

Closed besgum closed 5 years ago

besgum commented 6 years ago

Home Assistant release with the issue: Version 0.75.1

Operating environment (Hass.io/Docker/Windows/etc.):

Raspberry pi 3b+, Hass.io supervisor 123

Description of problem: DHT22 sensor is connected to the GPIO 18, 3.3V and ground. Home assistant cant update the sensor.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

sensor:
# DHT22 sensor
  - platform: dht
    sensor: DHT22
    pin: 18
    monitored_conditions:
    - temperature
    - humidity

Traceback (if applicable):

Log Details (ERROR)
Sun Aug 05 2018 11:17:45 GMT-0400 (Chile Standard Time)

dht: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 322, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/dht.py", line 122, in update
    self.dht_client.update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/dht.py", line 157, in update
    self.sensor, self.pin)
  File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 94, in read_retry
    humidity, temperature = read(sensor, pin, platform)
  File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 80, in read
    platform = get_platform()
  File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 63, in get_platform
    raise RuntimeError('Unknown platform.')
RuntimeError: Unknown platform.

Additional information: I have try with different DHT22 sensor, but the same happen

encor50 commented 6 years ago

Same problem here

RssFra97 commented 6 years ago

Good Morning, I have this problem too

2018-08-05 07:51:58 ERROR (MainThread) [homeassistant.components.sensor] dht: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 322, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/dht.py", line 122, in update
    self.dht_client.update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 325, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/dht.py", line 157, in update
    self.sensor, self.pin)
  File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 94, in read_retry
    humidity, temperature = read(sensor, pin, platform)
  File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 80, in read
    platform = get_platform()
  File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 63, in get_platform
    raise RuntimeError('Unknown platform.')
RuntimeError: Unknown platform.

my config

sensor:
    - platform: dht
      sensor: DHT11
      pin: 24
      monitored_conditions:
         - temperature
         - humidity
kaiomatico commented 6 years ago

So I took a look at the source code from adafruit DHT on github. The following code is used to determine the platform: https://github.com/adafruit/Adafruit_Python_DHT/blob/master/Adafruit_DHT/platform_detect.py from there have a look at def pi_version. Using cat /proc/cpuinfo the "Hardware" tab is being searched. Loging in via ssh to my hassIO on hassOS does not output the information this function is searching for. This is my output: image

This is what it is searching for: # Match a line like 'Hardware : BCM2709' match = re.search('^Hardware\s+:\s+(\w+)$', cpuinfo, flags=re.MULTILINE | re.IGNORECASE)

kaiomatico commented 6 years ago

If someone can tell me how to break out of the hassOS container and modify the file /usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py maybe we could easily fix it and push the changes to the adafruit github

kaiomatico commented 6 years ago

Just a quick update, I hope I don't spam too much: Moving my installation to hassbian makes the DHT Sensor work. So it is just a problem with hassIO / hassOS.

RssFra97 commented 6 years ago

ok, but none of the developers hear the problem or are they trying to fix it?

kaiomatico commented 6 years ago

@RWGaMeR I created an issue in the hassOS github repository but that got closed by the developer. Maybe it is not hassOS specific but hassIO specific. In the hassIO repository there is still an open issue about the DHT sensors, but they are trying to focus more on the build itself (using the correct pip and gcc versions). Here is the link, there has not been much activity in the last 2 weeks: https://github.com/home-assistant/hassio/issues/624

So because my issue was closed I guess the issue must be hassIO specific (not hassOS and not home-assistant specific and not Adafruit-DHT specific). So I don't know if they are trying to fix it.

RssFra97 commented 6 years ago

ok, thanks for info

RssFra97 commented 6 years ago

@kaiomatico

besgum commented 6 years ago

Hi, any news regarding this issue? it's been a month and I haven't been able to fix this. If someone could give me a hint to make the DHT22 component work again would be great

RssFra97 commented 6 years ago

@besgum In the new beta 0.78.0b0 they have updated to 1.3.4 only that from the same problems

2018-09-11 18:46:35 ERROR (SyncWorker_17) [homeassistant.util.package] Unable to install package Adafruit-DHT==1.3.4: Failed building wheel for Adafruit-DHT
wirelesstagpy 0.3.0 has requirement colorlog==3.0.1, but you'll have colorlog 3.1.4 which is incompatible.
waterfurnace 0.7.0 has requirement websocket-client>=0.47, but you'll have websocket-client 0.37.0 which is incompatible.
upsmychoice 1.0.6 has requirement beautifulsoup4==4.5.1, but you'll have beautifulsoup4 4.6.3 which is incompatible.
upsmychoice 1.0.6 has requirement python-dateutil==2.6.0, but you'll have python-dateutil 2.7.3 which is incompatible.
upsmychoice 1.0.6 has requirement requests==2.12.4, but you'll have requests 2.19.1 which is incompatible.
toonlib 1.0.2 has requirement cachetools==2.0.0, but you'll have cachetools 2.0.1 which is incompatible.
toonlib 1.0.2 has requirement requests==2.13.0, but you'll have requests 2.19.1 which is incompatible.
temperusb 1.5.3 has requirement pyusb>=1.0.0rc1, but you'll have pyusb 1.0.0b1 which is incompatible.
spotcrime 1.0.3 has requirement requests==2.12.4, but you'll have requests 2.19.1 which is incompatible.
skybellpy 0.1.2 has requirement colorlog==3.0.1, but you'll have colorlog 3.1.4 which is incompatible.
python-velbus 2.0.19 has requirement pyserial==3.3, but you'll have pyserial 3.1.1 which is incompatible.
python-jose-cryptodome 1.3.2 has requirement pycryptodome<3.4.0,>=3.3.1, but you'll have pycryptodome 3.6.6 which is incompatible.
pysma 0.2.0 has requirement aiohttp<3,>2, but you'll have aiohttp 3.4.4 which is incompatible.
pysma 0.2.0 has requirement async-timeout<3,>2, but you'll have async-timeout 3.0.0 which is incompatible.
pymysensors 0.17.0 has requirement pyserial>=3.4, but you'll have pyserial 3.1.1 which is incompatible.
pymonoprice 0.3 has requirement pyserial>=3.4, but you'll have pyserial 3.1.1 which is incompatible.
pymata 2.14 has requirement pyserial==2.7, but you'll have pyserial 3.1.1 which is incompatible.
pyicloud 0.9.1 has requirement keyring<9.0,>=8.0, but you'll have keyring 15.0.0 which is incompatible.
pyicloud 0.9.1 has requirement keyrings.alt<2.0,>=1.0, but you'll have keyrings-alt 3.1 which is incompatible.
pyblackbird 0.5 has requirement pyserial>=3.4, but you'll have pyserial 3.1.1 which is incompatible.
nad-receiver 0.0.9 has requirement pyserial==3.2.1, but you'll have pyserial 3.1.1 which is incompatible.
myusps 1.3.2 has requirement beautifulsoup4==4.6.0, but you'll have beautifulsoup4 4.6.3 which is incompatible.
myusps 1.3.2 has requirement python-dateutil==2.6.0, but you'll have python-dateutil 2.7.3 which is incompatible.
myusps 1.3.2 has requirement requests==2.12.4, but you'll have requests 2.19.1 which is incompatible.
myusps 1.3.2 has requirement selenium==2.53.6, but you'll have selenium 3.14.0 which is incompatible.
mycroftapi 2.0 has requirement websocket-client==0.44.0, but you'll have websocket-client 0.37.0 which is incompatible.
motorparts 1.0.2 has requirement beautifulsoup4==4.5.1, but you'll have beautifulsoup4 4.6.3 which is incompatible.
motorparts 1.0.2 has requirement requests==2.12.4, but you'll have requests 2.19.1 which is incompatible.
magicseaweed 1.0.0 has requirement requests==2.12.4, but you'll have requests 2.19.1 which is incompatible.
locationsharinglib 2.0.11 has requirement beautifulsoup4==4.6.0, but you'll have beautifulsoup4 4.6.3 which is incompatible.
libsoundtouch 0.7.2 has requirement websocket-client>=0.40.0, but you'll have websocket-client 0.37.0 which is incompatible.
insteonplm 0.13.1 has requirement pyserial==3.2.0, but you'll have pyserial 3.1.1 which is incompatible.
hipnotify 1.0.8 has requirement requests==2.9.1, but you'll have requests 2.19.1 which is incompatible.
gearbest-parser 1.0.7 has requirement beautifulsoup4==4.6.0, but you'll have beautifulsoup4 4.6.3 which is incompatible.
fedexdeliverymanager 1.0.6 has requirement beautifulsoup4==4.5.1, but you'll have beautifulsoup4 4.6.3 which is incompatible.
fedexdeliverymanager 1.0.6 has requirement python-dateutil==2.6.0, but you'll have python-dateutil 2.7.3 which is incompatible.
discord-py 0.16.12 has requirement aiohttp<1.1.0,>=1.0.0, but you'll have aiohttp 3.4.4 which is incompatible.
crimereports 1.0.0 has requirement requests==2.12.4, but you'll have requests 2.19.1 which is incompatible.
broadlink 0.9 has requirement pycryptodome==3.4.11, but you'll have pycryptodome 3.6.6 which is incompatible.
alarmdecoder 1.13.2 has requirement pyserial==2.7, but you'll have pyserial 3.1.1 which is incompatible.
abodepy 0.13.1 has requirement colorlog==3.0.1, but you'll have colorlog 3.1.4 which is incompatible.
Command "/usr/local/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-vmmkqee6/Adafruit-DHT/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-3d573dmv/install-record.txt --single-version-externally-managed --prefix  --compile --user --prefix=" failed with error code 1 in /tmp/pip-install-vmmkqee6/Adafruit-DHT/
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
2018-09-11 18:46:35 ERROR (MainThread) [homeassistant.requirements] Not initializing sensor.dht because could not install requirement Adafruit-DHT==1.3.4
2018-09-11 18:46:35 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.dht: Could not install all requirements.
TracKer commented 6 years ago

Got the same issue on v0.80.0

TracKer commented 5 years ago

Updated to v0.80.1 and got error on update:

2018-10-16 22:28:58 ERROR (MainThread) [homeassistant.components.sensor] dht: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 251, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/dht.py", line 122, in update
    self.dht_client.update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 324, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/dht.py", line 157, in update
    self.sensor, self.pin)
  File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 94, in read_retry
    humidity, temperature = read(sensor, pin, platform)
  File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 80, in read
    platform = get_platform()
  File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 63, in get_platform
    raise RuntimeError('Unknown platform.')
RuntimeError: Unknown platform.
2018-10-16 22:28:58 ERROR (MainThread) [homeassistant.components.sensor] dht: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 251, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/dht.py", line 122, in update
    self.dht_client.update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 324, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/dht.py", line 157, in update
    self.sensor, self.pin)
  File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 94, in read_retry
    humidity, temperature = read(sensor, pin, platform)
  File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 80, in read
    platform = get_platform()
  File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 63, in get_platform
    raise RuntimeError('Unknown platform.')
RuntimeError: Unknown platform.
fabaff commented 5 years ago

See https://github.com/adafruit/Adafruit_Python_DHT/pull/104 for 3b+ support

InFlames82 commented 5 years ago

I have also the same problem in version 0.84.3 on an Raspberry Pi Zero w with a new installation of hassIO. The sensor is a DHT22. My log:

2018-12-20 07:49:08 ERROR (MainThread) [homeassistant.components.sensor] dht: Error on device update! Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update await self.hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/dht.py", line 121, in update self.dht_client.update() File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 324, in wrapper result = method(*args, **kwargs) File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/dht.py", line 156, in update self.sensor, self.pin) File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 94, in read_retry humidity, temperature = read(sensor, pin, platform) File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 80, in read platform = get_platform() File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/common.py", line 55, in get_platform from . import Raspberry_Pi_2 File "/usr/local/lib/python3.6/site-packages/Adafruit_DHT/Raspberry_Pi_2.py", line 22, in <module> from . import Raspberry_Pi_2_Driver as driver ImportError: cannot import name 'Raspberry_Pi_2_Driver'

I'm wondering because of the "cannot import name Rapsberry Pi_2_Driver"-> I'm using a Raspberry Pi Zero

InFlames82 commented 5 years ago

Ahh, it is a bug in Adafruit_Python_DHT

The Pi Zero is not supportet yet.

https://github.com/adafruit/Adafruit_Python_DHT/issues/79