Raspberry Pi MQTT JSON Multisensor for Home Assistant. Supported sensors include the AM312 PIR, DHT11/22 temperature/humidity sensors.
- paho-mqtt (install using pip)
- Adafruit_DHT (install via their git repo)
- gpiozero (installed by default on Raspi - link to docs)
Under the 'Configuration' section of the script replace the appropriate variables. If you don't use authentication with a private MQTT server just leave it with null information. Using a DHT11 instead of a DHT22? Just change line 43.
You can simply run the file with ./multisensor.py
(after configuring) in a terminal and go on your merry way or run it as a service.
- Copy rpi-sensor.service to
/etc/systemd/system/
- Run (as root)
systemctl enable rpi-sensor.service
- Run (as root)
systemctl start rpi-sensor.service