One of the hassles of ISY scenes is that you often use multiple lights in multiple scenes. For instance, I have two scenes in the ISY called “Family Room Main” and “Movie”. They each control a light with the HA entity_id called light.two2frb4_fr_spotlight
, however the Movie scene sets this value at 12% and the other 55%. So by creating multiple binary sensors with the exact name of the corresponding scene switch (scenes come in from the ISY as a switch) you can set the logic to determine when each scene is on. Below I used logic if the actual brightness is within 5 points of the target value. You could make these more complex if you want.
The glance card below displays the sensors, and when tapped call script sensor_source_toggle
which passes in the sensor and converts that to a switch (which is why the names need to match) and will toggle the switch based upon the sensor value.
binary sensors
family_room_main:
value_template: >-
{% set pct = ((states.light.two2frb4_fr_spotlight.attributes.brightness | float / 255) | abs )%}
{% set ret = (0.5 <= pct) and (pct <= 0.6) %}
{{ ret }}
movie:
value_template: >-
{% set pct = ((states.light.two2frb4_fr_spotlight.attributes.brightness | float / 255) | abs )%}
{% set ret = (0.07 <= pct) and (pct <= 0.17) %}
{{ ret }}
script
sensor_source_toggle:
sequence:
- service_template: >
{% if is_state(entity_id, 'on') %}
switch.turn_off
{% else %}
switch.turn_on
{% endif %}
data_template:
entity_id: >-
{% set entity = (entity_id | replace("binary_sensor.","switch.")) %}
{{entity}}
glance card
entities:
- entity: binary_sensor.family_room_main
icon: 'mdi:sofa'
name: Living Room
tap_action:
action: call-service
service: script.sensor_source_toggle
service_data:
entity_id: binary_sensor.family_room_main
- entity: binary_sensor.movie
icon: 'mdi:movie-open'
tap_action:
action: call-service
service: script.sensor_source_toggle
service_data:
entity_id: binary_sensor.movie
type: glance