Ok, with the additional explanation and the code you wrote I think it’s now clear what you want to do. I.e., when the click happens, turn all the lights in the group on if the overhead lights are off, and turn all the lights in the group off if the overhead lights are on. Is that it? If so, then what you have will work, but it can be simplified a little:
- alias: 'Ryan`s Office External Light Switch'
trigger:
platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d0001b86a10
click_type: single
action:
service_template: >
{% if is_state('switch.ryans_office_overhead_lights_switch', 'off') %}
homeassistant.turn_on
{% else %}
homeassistant.turn_off
{% endif %}
entity_id: group.ryans_office_lights
Regarding the toggle service, yes, it will toggle each entity, whether you list it individually or it’s in a group. So all that were off will go on, and all that are on will go off. Now that I understand (I think) what you’re trying to do, that is not the right service to use in this case.
@BrendanMoran, yes, the service template could be re-factored like you say, but I think what you wrote is the reverse of what the OP is looking for.