DHT Sensor - custom_components

Yes.
Very sad

I’m always astounded by how strictly this “open source community” project is locked down to suite the blinkered goals of a few senior developers and prevent tinkering by the people using it. The usual line being that they don’t like having to offer support for projects people are hacking together, as if all such support would be on them, which is never true in a community project.
Yes, we should absolutely be able and allowed to install our own python packages. Though I note the python and pip commands are not accessible on the terminal. The packages are surely running somewhere though so we must be able to find the pip binary and ask it to install the relevant stuff we wish to import.
If anyone knows how to access Python or Pip from the hass terminal, please say so, because the official hass administration seems to be going down the same no-right-to-repair path as apple these days of saying “sure, go ahead and make changes, but we’re going to make it as hard as possible to do.” ¬_¬

Okay, so I’ve been poking around and just taking some notes as I go.

  1. Install the community add on “SSH & Web Terminal”
    i) Ensure it is “SSH & Web Terminal” and not the more “official” one called “Terminal & SSH”. Yes they look and sound identical, but this makes a huge difference.
    ii) Before starting the add on, click its “Configuration” tab and add a password (a key would be better but I’m keeping this simple for now).
    iii) Back on the Info tab, where you set it to start on boot etc, turn off the stupid switch for “Protection Mode”. This causes it to hide actually useful parts of the sytem from you if it’s on, such as Python, Pip, Docker, etc.
    iv) Start the addon and go to its web ui or login over an SSH terminal, however you prefer.
  2. In the now “unprotected” terminal, run pip3 install adafruit-circuitpython-dht (oh look, it does exist after all ¬_¬)
  3. Oh yes, the powers that be decided the primary benefit of using a Raspberry Pi over literally any other computer (it’s damned GPIO pins!) wasn’t important anymore, so we’d best install that too. pip3 install RPi.GPIO
  4. reboot

This is where I’m a bit stumped, after rebooting, nothing has changed and in fact if I run pip3 list the installed packages have now vanished.

However, I did notice that where my manifest file listed “RPi.GPIO==0.7.1a4” and “adafruit-circuitpython-dht==3.7.0”, what I’m seeing in my pip3 freeze is showing “RPi-GPIO==0.7.1” and “adafruit-circuitpython-dht==3.7.7” so I’m going to see what happens if I update the DHT custom component to use these newer versions…

1 Like

No luck I’m afraid. I still get, like @lpt2007, the infinite spinning configuration check.
Though curiously, I cannot see where @lpt2007 found their error lines regarding the packages not installing. I’ve checked the log section but all I see there is the usual moaning warnings about custom components not being official enough for their liking.

2 Likes

I’m running Homeassistant Core v2022.10.3 and DHT is not working, tried to update adafruit-circuitpython-dht and rpi.gpio and changed the requirements in the dht component, but the sensor is still not working and giving ‘unknown’ instead of the temperature and humidity values.

Updating Homeassistant
Looking in links: /tmp/tmp1kia4_s8
Requirement already satisfied: setuptools in ./lib/python3.9/site-packages (44.1.1)
Processing /tmp/tmp1kia4_s8/setuptools-44.1.1-py2.py3-none-any.whl
Requirement already satisfied: pip in ./lib/python3.9/site-packages (22.2.2)
Processing /tmp/tmp1kia4_s8/pip-20.3.4-py2.py3-none-any.whl
Requirement already satisfied: pkg_resources in ./lib/python3.9/site-packages (0.0.0)
Processing /tmp/tmp1kia4_s8/pkg_resources-0.0.0-py2.py3-none-any.whl
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pip in ./lib/python3.9/site-packages (22.2.2)
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: hass-configurator in ./lib/python3.9/site-packages (0.5.1)
Requirement already satisfied: homeassistant in ./lib/python3.9/site-packages (2022.10.3)
Requirement already satisfied: onkyo-eiscp in ./lib/python3.9/site-packages (1.2.7)
Requirement already satisfied: adafruit-circuitpython-dht in ./lib/python3.9/site-packages (3.7.0)
Collecting adafruit-circuitpython-dht
  Downloading adafruit_circuitpython_dht-3.7.7-py3-none-any.whl (7.8 kB)
Requirement already satisfied: RPi.GPIO in ./lib/python3.9/site-packages (0.7.1a4)
Collecting RPi.GPIO
  Using cached https://www.piwheels.org/simple/rpi-gpio/RPi.GPIO-0.7.1-cp39-cp39-linux_armv7l.whl (66 kB)
Requirement already satisfied: pyotp in ./lib/python3.9/site-packages (from hass-configurator) (2.7.0)
Requirement already satisfied: gitpython in ./lib/python3.9/site-packages (from hass-configurator) (3.1.28)
Requirement already satisfied: ifaddr==0.1.7 in ./lib/python3.9/site-packages (from homeassistant) (0.1.7)
Requirement already satisfied: jinja2==3.1.2 in ./lib/python3.9/site-packages (from homeassistant) (3.1.2)
Requirement already satisfied: home-assistant-bluetooth==1.3.0 in ./lib/python3.9/site-packages (from homeassistant) (1.3.0)
Requirement already satisfied: yarl==1.8.1 in ./lib/python3.9/site-packages (from homeassistant) (1.8.1)
Requirement already satisfied: pyyaml==6.0 in ./lib/python3.9/site-packages (from homeassistant) (6.0)
Requirement already satisfied: python-slugify==4.0.1 in ./lib/python3.9/site-packages (from homeassistant) (4.0.1)
Requirement already satisfied: voluptuous-serialize==2.5.0 in ./lib/python3.9/site-packages (from homeassistant) (2.5.0)
Requirement already satisfied: certifi>=2021.5.30 in ./lib/python3.9/site-packages (from homeassistant) (2022.9.24)
Requirement already satisfied: httpx==0.23.0 in ./lib/python3.9/site-packages (from homeassistant) (0.23.0)
Requirement already satisfied: typing-extensions<5.0,>=4.4.0 in ./lib/python3.9/site-packages (from homeassistant) (4.4.0)
Requirement already satisfied: ciso8601==2.2.0 in ./lib/python3.9/site-packages (from homeassistant) (2.2.0)
Requirement already satisfied: attrs==21.2.0 in ./lib/python3.9/site-packages (from homeassistant) (21.2.0)
Requirement already satisfied: PyJWT==2.5.0 in ./lib/python3.9/site-packages (from homeassistant) (2.5.0)
Requirement already satisfied: voluptuous==0.13.1 in ./lib/python3.9/site-packages (from homeassistant) (0.13.1)
Requirement already satisfied: bcrypt==3.1.7 in ./lib/python3.9/site-packages (from homeassistant) (3.1.7)
Requirement already satisfied: awesomeversion==22.9.0 in ./lib/python3.9/site-packages (from homeassistant) (22.9.0)
Requirement already satisfied: async-timeout==4.0.2 in ./lib/python3.9/site-packages (from homeassistant) (4.0.2)
Requirement already satisfied: lru-dict==1.1.8 in ./lib/python3.9/site-packages (from homeassistant) (1.1.8)
Requirement already satisfied: atomicwrites-homeassistant==1.4.1 in ./lib/python3.9/site-packages (from homeassistant) (1.4.1)
Requirement already satisfied: requests==2.28.1 in ./lib/python3.9/site-packages (from homeassistant) (2.28.1)
Requirement already satisfied: orjson==3.7.11 in ./lib/python3.9/site-packages (from homeassistant) (3.7.11)
Requirement already satisfied: astral==2.2 in ./lib/python3.9/site-packages (from homeassistant) (2.2)
Requirement already satisfied: aiohttp==3.8.1 in ./lib/python3.9/site-packages (from homeassistant) (3.8.1)
Requirement already satisfied: pip<22.3,>=21.0 in ./lib/python3.9/site-packages (from homeassistant) (22.2.2)
Requirement already satisfied: cryptography==38.0.1 in ./lib/python3.9/site-packages (from homeassistant) (38.0.1)
Requirement already satisfied: frozenlist>=1.1.1 in ./lib/python3.9/site-packages (from aiohttp==3.8.1->homeassistant) (1.3.1)
Requirement already satisfied: multidict<7.0,>=4.5 in ./lib/python3.9/site-packages (from aiohttp==3.8.1->homeassistant) (6.0.2)
Requirement already satisfied: charset-normalizer<3.0,>=2.0 in ./lib/python3.9/site-packages (from aiohttp==3.8.1->homeassistant) (2.1.1)
Requirement already satisfied: aiosignal>=1.1.2 in ./lib/python3.9/site-packages (from aiohttp==3.8.1->homeassistant) (1.2.0)
Requirement already satisfied: pytz in ./lib/python3.9/site-packages (from astral==2.2->homeassistant) (2022.4)
Requirement already satisfied: six>=1.4.1 in ./lib/python3.9/site-packages (from bcrypt==3.1.7->homeassistant) (1.16.0)
Requirement already satisfied: cffi>=1.1 in ./lib/python3.9/site-packages (from bcrypt==3.1.7->homeassistant) (1.15.1)
Requirement already satisfied: bleak>=0.14.3 in ./lib/python3.9/site-packages (from home-assistant-bluetooth==1.3.0->homeassistant) (0.18.1)
Requirement already satisfied: httpcore<0.16.0,>=0.15.0 in ./lib/python3.9/site-packages (from httpx==0.23.0->homeassistant) (0.15.0)
Requirement already satisfied: sniffio in ./lib/python3.9/site-packages (from httpx==0.23.0->homeassistant) (1.3.0)
Requirement already satisfied: rfc3986[idna2008]<2,>=1.3 in ./lib/python3.9/site-packages (from httpx==0.23.0->homeassistant) (1.5.0)
Requirement already satisfied: MarkupSafe>=2.0 in ./lib/python3.9/site-packages (from jinja2==3.1.2->homeassistant) (2.1.1)
Requirement already satisfied: text-unidecode>=1.3 in ./lib/python3.9/site-packages (from python-slugify==4.0.1->homeassistant) (1.3)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./lib/python3.9/site-packages (from requests==2.28.1->homeassistant) (1.26.12)
Requirement already satisfied: idna<4,>=2.5 in ./lib/python3.9/site-packages (from requests==2.28.1->homeassistant) (3.4)
Requirement already satisfied: netifaces in ./lib/python3.9/site-packages (from onkyo-eiscp) (0.11.0)
Requirement already satisfied: docopt>=0.4.1 in ./lib/python3.9/site-packages (from onkyo-eiscp) (0.6.2)
Requirement already satisfied: Adafruit-Blinka in ./lib/python3.9/site-packages (from adafruit-circuitpython-dht) (8.5.0)
Requirement already satisfied: rpi-ws281x>=4.0.0 in ./lib/python3.9/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (4.3.4)
Requirement already satisfied: adafruit-circuitpython-typing in ./lib/python3.9/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (1.8.2)
Requirement already satisfied: pyftdi>=0.40.0 in ./lib/python3.9/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (0.54.0)
Requirement already satisfied: sysv-ipc>=1.1.0 in ./lib/python3.9/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (1.1.0)
Requirement already satisfied: Adafruit-PlatformDetect>=3.13.0 in ./lib/python3.9/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (3.31.0)
Requirement already satisfied: Adafruit-PureIO>=1.1.7 in ./lib/python3.9/site-packages (from Adafruit-Blinka->adafruit-circuitpython-dht) (1.1.9)
Requirement already satisfied: gitdb<5,>=4.0.1 in ./lib/python3.9/site-packages (from gitpython->hass-configurator) (4.0.9)
Requirement already satisfied: dbus-fast<2.0.0,>=1.4.0 in ./lib/python3.9/site-packages (from bleak>=0.14.3->home-assistant-bluetooth==1.3.0->homeassistant) (1.33.0)
Requirement already satisfied: pycparser in ./lib/python3.9/site-packages (from cffi>=1.1->bcrypt==3.1.7->homeassistant) (2.21)
Requirement already satisfied: smmap<6,>=3.0.1 in ./lib/python3.9/site-packages (from gitdb<5,>=4.0.1->gitpython->hass-configurator) (5.0.0)
Requirement already satisfied: h11<0.13,>=0.11 in ./lib/python3.9/site-packages (from httpcore<0.16.0,>=0.15.0->httpx==0.23.0->homeassistant) (0.12.0)
Requirement already satisfied: anyio==3.* in ./lib/python3.9/site-packages (from httpcore<0.16.0,>=0.15.0->httpx==0.23.0->homeassistant) (3.6.1)
Requirement already satisfied: pyusb!=1.2.0,>=1.0.0 in ./lib/python3.9/site-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-dht) (1.2.1)
Requirement already satisfied: pyserial>=3.0 in ./lib/python3.9/site-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-dht) (3.5)
Requirement already satisfied: adafruit-circuitpython-requests in ./lib/python3.9/site-packages (from adafruit-circuitpython-typing->Adafruit-Blinka->adafruit-circuitpython-dht) (1.12.8)
Requirement already satisfied: adafruit-circuitpython-busdevice in ./lib/python3.9/site-packages (from adafruit-circuitpython-typing->Adafruit-Blinka->adafruit-circuitpython-dht) (5.2.3)
Installing collected packages: RPi.GPIO, adafruit-circuitpython-dht
  Attempting uninstall: RPi.GPIO
    Found existing installation: RPi.GPIO 0.7.1a4
    Uninstalling RPi.GPIO-0.7.1a4:
      Successfully uninstalled RPi.GPIO-0.7.1a4
  Attempting uninstall: adafruit-circuitpython-dht
    Found existing installation: adafruit-circuitpython-dht 3.7.0
    Uninstalling adafruit-circuitpython-dht-3.7.0:
      Successfully uninstalled adafruit-circuitpython-dht-3.7.0
Successfully installed RPi.GPIO-0.7.1 adafruit-circuitpython-dht-3.7.7
Starting Homeassistant...

Also tried this custom_component: GitHub - richardzone/homeassistant-dht: Support for Adafruit DHT temperature and humidity sensor and still the same errors.

I got it working using a hardware ‘hack’ using the 5v instead of the 3.3v of the raspberry pi and now getting values for humidity and temperature, using above custom_component.

How did you do working???
Regards

Hi,
The verison of RPi.GPIO requested by dht is 0.7.1a4, while its version in rpi_GPIO is v0.7.1. The system needs gcc to compile the python wheel of RPi.GPIO v0.7.1a4. But you can simply use the same version of it in dht library. Just remove “a4” from the manifest.json of dht library.
It worked for home assistant os on raspberry pi.

1 Like

Hi - can you be slightly more expansive on this please? I removed a4 but am assuming there is another library I need to add as it’s not go things working…

Ok. It’s working now!
Simple instruction:

  1. Remove the dht directory in \config\custom_components
  2. (As suggest by @megapearl ) Add this repository to HACS GitHub - richardzone/homeassistant-dht: Support for Adafruit DHT temperature and humidity sensor and install the component.
  3. (As suggest by @jiawku ) Edit the file \config\custom_components\dht\manifest.json and remove “a4” from the “0.7.1a4”.
  4. Reboot Home Assistant.
  5. Add the code in your .yaml file.
  6. Check config (it should pass now) and reboot.
5 Likes

Thanks, I’ve followed the instruction but now my config.yaml won’t pass before restart…will have to tinker a little more

You have to restart Home Assistant before adding the configuration lines in the config.yaml. After the DHT integration is installed, then Home Assistant will pass you configuration code if it’s correctly formed. You can also restart the host, via settings, system, hardware if Home Assistant isn’t allowing to restart.

However I am personnaly struggling to get the DHT sensor on the Raspberry GPIOs working as well. Restarting and adding the code is working, but no values yet on the sensor.

Here’s my log:

Logger: custom_components.dht.sensor
Source: custom_components/dht/sensor.py:193
Integration: dht (documentation, issues)
First occurred: 19:17:30 (16 occurrences)
Last logged: 19:21:09

Finished call to 'custom_components.dht.sensor.DHTClient.read_retry' after 0.376(s), this was the 1st time calling it.
Finished call to 'custom_components.dht.sensor.DHTClient.read_retry' after 0.373(s), this was the 1st time calling it.
1 Like

Maybe changing the pins?

perfect! working again…

after add the code, the config check wont pass… I had reboot manually… but after that it works fine.

I managed to make the sensor work with fer4droid’s tips, but my log is full of errors.

Any idea?

2022-12-04 00:35:28.623 WARNING (SyncWorker_4) [custom_components.dht.sensor] Finished call to 'custom_components.dht.sensor.DHTClient.read_retry' after 0.352(s), this was the 1st time calling it.
2022-12-04 00:35:28.979 WARNING (SyncWorker_1) [custom_components.dht.sensor] Finished call to 'custom_components.dht.sensor.DHTClient.read_retry' after 0.352(s), this was the 1st time calling it.
2022-12-04 00:35:58.625 WARNING (SyncWorker_3) [custom_components.dht.sensor] Finished call to 'custom_components.dht.sensor.DHTClient.read_retry' after 0.352(s), this was the 1st time calling it.
2022-12-04 00:35:58.981 WARNING (SyncWorker_8) [custom_components.dht.sensor] Finished call to 'custom_components.dht.sensor.DHTClient.read_retry' after 0.351(s), this was the 1st time calling it.
2022-12-04 00:36:28.979 WARNING (SyncWorker_3) [custom_components.dht.sensor] Finished call to 'custom_components.dht.sensor.DHTClient.read_retry' after 0.352(s), this was the 1st time calling it.
2022-12-04 00:36:58.981 WARNING (SyncWorker_3) [custom_components.dht.sensor] Finished call to 'custom_components.dht.sensor.DHTClient.read_retry' after 0.352(s), this was the 1st time calling it.
2022-12-04 00:37:28.628 WARNING (SyncWorker_5) [custom_components.dht.sensor] Finished call to 'custom_components.dht.sensor.DHTClient.read_retry' after 0.352(s), this was the 1st time calling it.
2022-12-04 00:37:28.984 WARNING (SyncWorker_0) [custom_components.dht.sensor] Finished call to 'custom_components.dht.sensor.DHTClient.read_retry' after 0.352(s), this was the 1st time calling it.

Well, I thought my DHT is working, but it isn’t. I think it is because of the library installed.
I installed a deprecated library (AdaFruit_Python_DHT) … when I check the temp and hum, it returns data correctly:
image
Looking at the manifest.json, its reference is “AdaFruit_CircuitPython_DHT”:

ok… I installed this one too… but I cannot see the temp and hum (maybe im using a wrong command?)
nothing happens…
image
Also, checking the example py… it says to check the wires… but as tested before…the wires are ok…
image

Whar am I doing wrong? if I cannot check the temperature and humidity using the terminal, I will never be able to check using home assistant :frowning: ]

thank you!

Yeah, 2 line of log every 30 seconds is very annoying…
I “work around” the problem by editing the file sensor.py and changing the line 183 deleting the last parameter, so the line now look like this:
@retry(reraise = True, retry = retry_if_exception_type(RuntimeError), stop = stop_after_attempt(15))

For those of you who’s sensor doesn’t work.
Remember that non only DHT is deprecated but also the GPIO.
So try to install also the unofficial GPIO support on HACS:

My work around was to raise the custom_components.dht.sensor log to error instead of warning

So the workaround makes the custom component to work?
Thanks