Adding in Legacy Sensors - Part 1
Those Eaton Home Heartbeat sensors, mentioned in post #2 from May 2014, are still working!So, it'd be nice to get them feeding data into my new Home Assistant system. After reading and researching, my current (as of September 2022) thought is to use "MQTT Device Discovery."
MQTT Device Discovery, in Home Assistant, is the ability to add sensors using carefully formatted MQTT messages sent to the broker. I've already got an MQTT integration into Home Assistant, and I'm using zigbee2mqtt to feed sensor data to Home Assistant. zigbee2mqtt uses MQTT Device Discovery -- so I'll try it too.
Reading and Sniffing
A little reading, and a little "eavesdropping" of the messages that zigbee2mqtt sends and I'm able to come upwith a prototype.For a device, I'm going to start with a non-zigbee sensor, my Tuya WiFi Air Quality Monitor. I've already got Python code that logs into the Tuya IoT cloud, pulls the sensor data and sends it out via MQTT packets to my broker.
The thought is, to leave that code as is, and just modify the MQTT payload so it matches Home Assistant's MQTT Device Discovery format.
Treat each sensor individually
The format is documented, but I'll share the approach I've taken. First an architectural issue of note. This Air Quality monitor has six sensors (temperature, humidity, carbon dioxide, formaldehyde, particulate matter 2.5, and volatile organic compounds).
Current Best Practice is to treat this one unit as six separate sensors. Don't try to lump them together, yet.
Two MQTT Messages
Configuration - Craft the Root MQTT Topic
MQTT Device Discovery starts with publishing configuration messages to topics, topics that Home Assistant is already subscribed to. The topic format I'm using starts with:
homeassistant/sensor/<device ID>
"homeassistant" is the default root topic.
"sensor" is a component that has to match one of the known Home Assistant MQTT component types. See here.
And <device ID> is the unique way of identifying this sensor (or group of sensors). In my case, I'm using the unique device ID assigned to my Air Quality sensor from the Tuya IoT cloud.
One Config Message Per Sensor
homeassistant/sensor/eb0b-05a81/temperature/config
homeassistant/sensor/eb0b-05a81/humidity/config
homeassistant/sensor/eb0b-05a81/carbon_dioxide/config
homeassistant/sensor/eb0b-05a81/formaldehyde/config
homeassistant/sensor/eb0b-05a81/particulate_matter_2_5/config
homeassistant/sensor/eb0b-05a81/volatile_organic_compounds/config
No comments :
Post a Comment