I have an Ardunio using the MQTT PubSubClient library. It interacts with Hass Switches and Covers via MQTT (and works very well). The Ardunio also controls a cooling fan in my automation control panel. If the fan fails (I monitor the fan’s tach line), MQTT publishes the topic ‘control/fan/failure’. Can some recommend the best way to have Hass subscribe to my topic and notify (trigger) one of my SMTP notifications upon fan failure?
I think the only way to subscribe in HA is through sensors. You would create an MQTT binary_sensor that subscribes to your topic. However, I am not sure if it would work without a payload indicating “on” or “off”, I have never looked in to that. You may have to modify the arduino code to add a payload.
Once the sensor is created you need to create an automation triggered when the sensor is on.
Finally, you need to make sure the sensor is off, by sending a payload when the fan starts correctly.
You can react to MQTT events on the bus using appdaemon, without using a payload, although you still need a sensor to do the subscription.
You can trigger on mqtt payloads without a sensor.
Worked it out. Created a MQTT Binary Sensor and used an Alert (found in Automation Components) to send my notify when the fan fails. Thank you for pointing me in the right direction!