I have some custom devices that are auto-discovered though MQTT. Once discovered by Home Assistant, I use the UI to set the device’s area.
I would like Home Assistant to automatically send the area to the device. Is it possible to catch when a device’s area has been changed and send a message via MQTT?
In one browser window I opened Developer tools > Events, and set Listen to Events to listen to all events (*).
In a second browser window, I opened Configuration > Devices, selected a device and, using the gear icon, set the device’s area to “Kitchen” then clicked Update.
I returned to the first browser window and saw that it recorded a device_registry_updated event. However, the information the event contained didn’t refer to either the device or the area by name. It simply contained the device’s device_id (long alphanumeric string) and the time and date the event occurred. In other words, the device’s information was updated but what exactly got updated isn’t mentioned.
That’s all the information you’ll get when you change a device’s area.
Thanks again, @123! First, the “how you did that” has helped a lot on its own. Obviously I need to read the developer docs a bit more…
Receiving the device_id may be all I need. The lack of information associated with that event is enough to identify a time to send an area update the device. My test case is with a switch, and an event associated with toggling that switch clearly shows the state change. Obviously those events shouldn’t trigger an area update.
So, in the worst case and without filtering those events, I’d be sending area updates out more frequently that needed. It will do the job, though.