flyte / mqtt-io

Expose GPIO modules (Raspberry Pi, Beaglebone, PCF8754, PiFace2 etc.) and digital sensors (LM75 etc.) to an MQTT server for remote control and monitoring.
MIT License
460 stars 157 forks source link

Adafruit_DHT (DHT22, ...) package is deprecated on Raspberry Pi #373

Open eMindFfM opened 2 weeks ago

eMindFfM commented 2 weeks ago

Adafruit_DHT (DHT22, ...) package is deprecated on Raspberry Pi and can not be installed any longer, thus the package can not run.

an alternative is package provided adafruit-circuitpython-dht

Source: https://github.com/adafruit/Adafruit_CircuitPython_DHT

Can you please update

mschlenstedt commented 2 weeks ago

Installed via apt or pip? Installation should still be possible via pip.

eMindFfM commented 2 weeks ago

with the "normal" pip it did not work at all. I found out that you can force manually the installation

pip3 install Adafruit_DHT --install-option="--force-pi"

This is only allowed in an virtual environment

Now I'm getting some strange "plattform" errors related to Adafruit_DHT and WebsocketWrapper

(venv) pi@Pi4MQTTtoHA:~/venv $ python3 -m mqtt_io config.yml 2024-06-20 11:15:15 mqtt_io.server [INFO] Connecting to MQTT... 2024-06-20 11:15:15 mqtt_io.server [ERROR] Exception in critical task: Traceback (most recent call last): File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 1380, in _main_loop await self._connect_mqtt() File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 707, in _connect_mqtt await self.mqtt.connect() File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/mqtt/asyncio_mqtt.py", line 51, in inner await func(*args, **kwargs) File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/mqtt/asyncio_mqtt.py", line 116, in connect await self._client.connect(timeout=timeout) File "/home/pi/venv/lib/python3.11/site-packages/asyncio_mqtt/client.py", line 82, in connect if not isinstance(client_socket, mqtt.WebsocketWrapper): ^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'paho.mqtt.client' has no attribute 'WebsocketWrapper' 2024-06-20 11:15:17 mqtt_io.server [INFO] Reconnecting to MQTT broker (infinite retries remaining) 2024-06-20 11:15:17 mqtt_io.server [INFO] Connecting to MQTT... 2024-06-20 11:15:17 mqtt_io.server [ERROR] Exception in critical task: Traceback (most recent call last): File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 1380, in _main_loop await self._connect_mqtt() File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 707, in _connect_mqtt await self.mqtt.connect() File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/mqtt/asyncio_mqtt.py", line 51, in inner await func(*args, **kwargs) File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/mqtt/asyncio_mqtt.py", line 116, in connect await self._client.connect(timeout=timeout) File "/home/pi/venv/lib/python3.11/site-packages/asyncio_mqtt/client.py", line 82, in connect if not isinstance(client_socket, mqtt.WebsocketWrapper): ^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'paho.mqtt.client' has no attribute 'WebsocketWrapper' 2024-06-20 11:15:19 mqtt_io.server [INFO] Reconnecting to MQTT broker (infinite retries remaining) 2024-06-20 11:15:19 mqtt_io.server [INFO] Connecting to MQTT... 2024-06-20 11:15:19 mqtt_io.server [ERROR] Exception in critical task: Traceback (most recent call last): File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 1380, in _main_loop await self._connect_mqtt() File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 707, in _connect_mqtt await self.mqtt.connect() File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/mqtt/asyncio_mqtt.py", line 51, in inner await func(*args, **kwargs) File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/mqtt/asyncio_mqtt.py", line 116, in connect await self._client.connect(timeout=timeout) File "/home/pi/venv/lib/python3.11/site-packages/asyncio_mqtt/client.py", line 82, in connect if not isinstance(client_socket, mqtt.WebsocketWrapper): ^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'paho.mqtt.client' has no attribute 'WebsocketWrapper' 2024-06-20 11:15:21 mqtt_io.server [INFO] Reconnecting to MQTT broker (infinite retries remaining) 2024-06-20 11:15:21 mqtt_io.server [INFO] Connecting to MQTT... 2024-06-20 11:15:21 mqtt_io.server [ERROR] Exception in critical task: Traceback (most recent call last): File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 1380, in _main_loop await self._connect_mqtt() File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 707, in _connect_mqtt await self.mqtt.connect() File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/mqtt/asyncio_mqtt.py", line 51, in inner await func(*args, **kwargs) File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/mqtt/asyncio_mqtt.py", line 116, in connect await self._client.connect(timeout=timeout) File "/home/pi/venv/lib/python3.11/site-packages/asyncio_mqtt/client.py", line 82, in connect if not isinstance(client_socket, mqtt.WebsocketWrapper): ^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'paho.mqtt.client' has no attribute 'WebsocketWrapper' 2024-06-20 11:15:23 mqtt_io.server [INFO] Reconnecting to MQTT broker (infinite retries remaining) 2024-06-20 11:15:23 mqtt_io.server [INFO] Connecting to MQTT... 2024-06-20 11:15:23 mqtt_io.server [ERROR] Exception in critical task: Traceback (most recent call last): File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 1380, in _main_loop await self._connect_mqtt() File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 707, in _connect_mqtt await self.mqtt.connect() File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/mqtt/asyncio_mqtt.py", line 51, in inner await func(*args, **kwargs) File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/mqtt/asyncio_mqtt.py", line 116, in connect await self._client.connect(timeout=timeout) File "/home/pi/venv/lib/python3.11/site-packages/asyncio_mqtt/client.py", line 82, in connect if not isinstance(client_socket, mqtt.WebsocketWrapper): ^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'paho.mqtt.client' has no attribute 'WebsocketWrapper' 2024-06-20 11:15:25 mqtt_io.server [ERROR] Exception when retrieving value from sensor 'temperature_solar': Traceback (most recent call last): File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 677, in poll_sensor value = await get_sensor_value() ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/backoff/_async.py", line 133, in retry ret = await target(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/backoff/_async.py", line 66, in retry ret = await target(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 672, in get_sensor_value return await sensor_module.async_get_value(sens_conf) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/modules/sensor/__init__.py", line 58, in async_get_value return await loop.run_in_executor(self.executor, self.get_value, sens_conf) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/modules/sensor/dht22.py", line 62, in get_value humidity, temperature = self.sensor.read_retry(self.sensor_type, self.pin) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/Adafruit_DHT/common.py", line 94, in read_retry humidity, temperature = read(sensor, pin, platform) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/Adafruit_DHT/common.py", line 80, in read platform = get_platform() ^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/Adafruit_DHT/common.py", line 63, in get_platform raise RuntimeError('Unknown platform.') RuntimeError: Unknown platform. 2024-06-20 11:15:25 mqtt_io.server [ERROR] Exception when retrieving value from sensor 'humidity_solar': Traceback (most recent call last): File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 677, in poll_sensor value = await get_sensor_value() ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/backoff/_async.py", line 133, in retry ret = await target(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/backoff/_async.py", line 66, in retry ret = await target(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 672, in get_sensor_value return await sensor_module.async_get_value(sens_conf) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/modules/sensor/__init__.py", line 58, in async_get_value return await loop.run_in_executor(self.executor, self.get_value, sens_conf) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/modules/sensor/dht22.py", line 62, in get_value humidity, temperature = self.sensor.read_retry(self.sensor_type, self.pin) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/Adafruit_DHT/common.py", line 94, in read_retry humidity, temperature = read(sensor, pin, platform) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/Adafruit_DHT/common.py", line 80, in read platform = get_platform() ^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/Adafruit_DHT/common.py", line 63, in get_platform raise RuntimeError('Unknown platform.') RuntimeError: Unknown platform. 2024-06-20 11:15:25 mqtt_io.server [ERROR] Exception when retrieving value from sensor 'temperature_zisterne': Traceback (most recent call last): File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 677, in poll_sensor value = await get_sensor_value() ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/backoff/_async.py", line 133, in retry ret = await target(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/backoff/_async.py", line 66, in retry ret = await target(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 672, in get_sensor_value return await sensor_module.async_get_value(sens_conf) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/modules/sensor/__init__.py", line 58, in async_get_value return await loop.run_in_executor(self.executor, self.get_value, sens_conf) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/modules/sensor/dht22.py", line 62, in get_value humidity, temperature = self.sensor.read_retry(self.sensor_type, self.pin) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/Adafruit_DHT/common.py", line 94, in read_retry humidity, temperature = read(sensor, pin, platform) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/Adafruit_DHT/common.py", line 80, in read platform = get_platform() ^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/Adafruit_DHT/common.py", line 63, in get_platform raise RuntimeError('Unknown platform.') RuntimeError: Unknown platform. 2024-06-20 11:15:25 mqtt_io.server [ERROR] Exception when retrieving value from sensor 'humidity': Traceback (most recent call last): File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 677, in poll_sensor value = await get_sensor_value() ^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/backoff/_async.py", line 133, in retry ret = await target(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/backoff/_async.py", line 66, in retry ret = await target(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/server.py", line 672, in get_sensor_value return await sensor_module.async_get_value(sens_conf) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/modules/sensor/__init__.py", line 58, in async_get_value return await loop.run_in_executor(self.executor, self.get_value, sens_conf) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/mqtt_io/modules/sensor/dht22.py", line 62, in get_value humidity, temperature = self.sensor.read_retry(self.sensor_type, self.pin) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/Adafruit_DHT/common.py", line 94, in read_retry humidity, temperature = read(sensor, pin, platform) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/Adafruit_DHT/common.py", line 80, in read platform = get_platform() ^^^^^^^^^^^^^^ File "/home/pi/venv/lib/python3.11/site-packages/Adafruit_DHT/common.py", line 63, in get_platform raise RuntimeError('Unknown platform.') RuntimeError: Unknown platform.

eMindFfM commented 2 weeks ago

The connection to the mqtt server seem to work image

This is my config file `mqtt: host: HOSTNAME topic_prefix: MQTTtoHA/Sensor/TempHum port: 1883

sensor_modules:

eMindFfM commented 1 week ago

Update ... The issue with the Websocket Wrapper can be soved by installing an old version of paho-mqtt

pip install paho-mqtt==1.6.1

eMindFfM commented 1 week ago

The Issue with RuntimeError: Unknown platform. remains