Subscribe to devices status changes


I’m not sure if this is the right category but here it goes:

I’m developing a physical “control panel” with a Raspberry Pi Pico where I want to show the current on/off status of some of my devices. Simply put: if the device is on, I want to light up a diode and turn it off when the status of the device is off.

My first idea was to poll the API, but that includes a lot of information, too much to parse effectively on the controller.

My next idea was to create a simple HTTP server/proxy that removes all unnecessary data and just returns a simple array if the diode should be on or off (e.g., [1, 0, 1, 1, …]), but I could not find a good way of creating such a server on the Home Assistant OS.

My next attempt was to use MQTT with animations. So I tried to create an animation that was triggered when a device changed status and then posted a message on MQTT, but the issue was that I could not find a way of making this generic. I would like to say: “when any device changes its status, publish the device ID and the new status on MQTT” otherwise do I have to add two (on and off) animations for every device I want to track.

My question is if anyone knows how I can make this work? i.e., subscribing to device status changes on a device with very limited resources.

According to MQTT - Home Assistant and Using The Mosquitto_pub and Mosquitto_sub MQTT Client Tools- Examples it’s possible to subscribe all topics. Maybe that could help you?