Some of the device I have integrated into my smart home use MQTT to communicate to Home Assistant. Since MQTT is a widely used protocol, utilities exist for most existing systems. While I still don't understand completely the underlying protocol of MQTT, it seemed like the best route to setup a custom sensor to get feedback from a script on my Linux system for ripping backups of discs.
I simply had to mosquitto_pub entries to the the existing shell script that automates the process in order to know the status of process. Since I only really care to know when I need to get up to swap a fresh disc into the system I simply report 1 when the tray is open and 0 when the ripping is in progress.
On the Home Assistant side it was simple to add a binary sensor to subscribe to the topic and messages I specified in the shell script. This allowed me add an automation to flash my WLED bias lighting on my desk with a specific color scheme for a minute to let me know it has completed.
Additionally I decided to try something new by using this to add tracking data for this process in Home Assistant. To track the number of discs ripped I added a counter helper to store the data. The automation that I created for the notification light was adjusted to call the counter increment function to track the number of discs I have ripped. I will be manually setting the current count to reflect discs that were ripped before this was integrated.
No comments:
Post a Comment