Is it possible to setup a template sensor to know what scene is being used?
I’m using a touch screen display that can highlight when a button is pressed, but I can’t figure out how to make scene mode into a sensor (I’m fine with multiple single binary sensors, one for each scene).
Scenes are “stateless”, there is no “in use” state, just a timestamp of when the scene was last turned on.
It would be annoying to set up and maintain, especially for complex scenes, but you could build templates comparing all the key states and/or attributes of the entities in the scene and use those in a template binary sensor.
template:
- binary_sensor:
- name: Basement Half-Bright Scene Active
state:
{{ is_state('light.basement_near_lights_zha', 'on') and
is_state_attr('light.basement_near_lights_zha', 'brightness', 117) and
is_state_attr('light.basement_near_lights_zha', 'xy_color', (0.526, 0.387)) }}
Thanks, yes I did that, works surprisingly well, but I just need to remember to update it as things change.
The only issue I noticed was the devices show brightness as a number rather than a percentage, so some times 100% was 254, rather than 255. Easy to check in the developer controls, for anyone trying something similar.