DHT Sensor - custom_components

Hello community, I use HA for a year and now I read that the integration DHT22 will be dropped. I have studied a bit in this forum and now I wanted to ask how I can keep the integration. I have read many articles about “custom_components”. Is it really that simple? Can I just copy the files from GIT to this directory and everything will work again? I am using a RPI and this is my configuration - so simple that I don’t want to move to ESPHome :slight_smile: :

sensor:
  - platform: dht
    sensor: DHT22
    pin: 2
    monitored_conditions:
      - temperature
      - humidity

Thank you in advance for your help!

Yes. Just one caveat: you have to add a “version” entry in the manifest.json. Content does not matter as long as it looks like a version, e.g. “1.0” or “2022.2.3”

Hi @koying , sorry - I was stupid - I got it now :slight_smile:
Custom integration changes | Home Assistant Developer Docs (home-assistant.io)

Thank you so much for your help! Will the component survive now even if HA removes it?

What about this import. What will happen if they remove this lib?
grafik

1 Like

Each custom component (or any component) describes its dependencies and these dependencies will be loaded into HAz don’t worry on this.

Thanks for the tip! For anyone about to follow the same path, I am linking the latest version of the dht integration before deprecation:

And the breaking commit: Remove deprecated DHT Sensor integration by frenck · Pull Request #67276 · home-assistant/core · GitHub

3 Likes

Hello, I just installed the 2002.4 HA and I lost my DHT sensor :frowning:
I copied all 3 dht files under custom_components/dht folder but still HA refused to start
Logger: homeassistant.components.hassio
Source: components/hassio/init.py:663
Integration: Home Assistant Supervisor (documentation, issues)
First occurred: 23:30:03 (3 occurrences)
Last logged: 23:38:15

The system cannot restart because the configuration is not valid: Platform error sensor.dht - Integration ‘dht’ not found.

1 Like

You have to comment first the dht related lines in your configuration.yaml.

sensor:
#  - platform: dht
#    sensor: AM2302
#    pin: 27
#    monitored_conditions:
#      - temperature
#      - humidity 

Click “Check Configuration” button and only then RESTART.
After it has restarted, uncomment the lines, recheck configuration and restart again.

2 Likes

Thank you so much!
Now everything works like before.
Daniele

how we will add version to manifest.json ? Help for a newbie :slight_smile:
i mean how we will write the code ?

answer to my question. i changed to that.

{
  "domain": "dht",
  "name": "DHT Sensor",
  "documentation": "https://www.home-assistant.io/integrations/dht",
  "version": "1.0.0",
  "requirements": [
    "adafruit-circuitpython-dht==3.7.0",
    "RPi.GPIO==0.7.1a4"
  ],
  "codeowners": [
    "@thegardenmonkey"
  ],
  "iot_class": "local_polling"
}
2 Likes

I’ve tried all of the above but still the same error: The system cannot restart because the configuration is not valid: Platform error sensor.dht - Integration ‘dht’ not found.

Any ideas?

You have to:

  • Or reboot
  • Or restart with the custom component but without the DHT definition, first, then only add the DHT to your HA.

See How to create a custom component from one removed from HA itself

2 Likes

Thanks, not quite sure why it didn’t work the first time so I deleted the dht folder and started again from that guide, and now working :slight_smile:

Not working again…

1 Like

After update to 2022.7.x not working again…

2 Likes

Any idea of if this integration is going to work again?

2 Likes

I just setup HA Core, I added DHT sensor and it is working.

Check if you have the folder dht inside custom_components folder and restart HA twice. That works to me.

You used python 3.9 in your venv, I presume?
I bet the component is broken when using python 3.10

The env is a raspberry pi 3.

I also think that the component is not compatible with python 9…. :frowning:

Hi, i have the same issue,
After updating to 2022.7.x (and thus python 3.10) the dht sensor is no longer working.
Should we wait for an update of the custom component dht to make it complient with python 3.10?