I am building an automation that handles click, hold and release events from a switch of a specific hardware model. For the action part, the automation just fires a new click or hold events, attaching the entity_id of the sensor entity that clicked the button as event data. This approach gives me an abstraction layer between the buttons and the lights that they will ultimately control.
To make the automation more flexible, I would like a piece of template Jinja code that will get a list of all sensor entities that belong to devices of a given model. This will allow me to add new switches to the system by just assigning an area to them.
In this post I found a clever little piece of code by @Troon that finds devices of a given model. I’m kinda new to Jinja so I haven’t been able to figure out how to modify it to get the sensor entities that belong to these devices.
Any help would be greately appreciated. Thanks