I’m using this code to change an icon on my main home status page. I’m in no way a template expert but feel this can’t be the optimal way. Wondering if I can use the value_template result to trigger the icon state?
binary_sensor:
- platform: template
sensors:
lights_on:
friendly_name: "Lights are On"
device_class: light
value_template: >-
{{ is_state('switch.buffet_receptacl_switch', 'on')
or is_state('switch.coach_lights_switch', 'on')
or is_state('switch.lanai_fan_switch', 'on')
or is_state('switch.kitchen_counter_lights_switch', 'on') }}
icon_template: >-
{% if is_state('switch.buffet_receptacl_switch', 'on')
or is_state('switch.coach_lights_switch', 'on')
or is_state('switch.lanai_fan_switch', 'on')
or is_state('switch.kitchen_counter_lights_switch', 'on') %}
mdi:lightbulb-on
{% else %}
mdi:lightbulb-outline
{% endif %}