Also tried this:
- service: homeassistant.turn_off
data_template:
entity_id: >
{%- set light_remove = [ light_id ] %}
{%- set all_lights = ['switch.bedroom_ceiling_light_switch' , 'switch.family_room_ceiling_light_switch', 'switch.office_lights_switch_2' ] %}
{%- for light in all_lights if (light not in light_remove) %}
- {{light}}
{%- endfor -%}
Which produces the following YAML:
- service: homeassistant.turn_off
data_template:
entity_id: >
- switch.bedroom_ceiling_light_switch
- switch.family_room_ceiling_light_switch
- switch.office_lights_switch_2
And the following error log:
Oct 02 19:40:21 HomeControl hass[19978]: 2017-10-02 19:40:21 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service=turn_off, service_call_id=1973313712-1964, service_data=entity_id=- switch.bedroom_ceiling_light_switch
Oct 02 19:40:21 HomeControl hass[19978]: - switch.family_room_ceiling_light_switch
Oct 02 19:40:21 HomeControl hass[19978]: - switch.office_lights_switch_2, domain=homeassistant>
Oct 02 19:40:21 HomeControl hass[19978]: 2017-10-02 19:40:21 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service=turn_off, service_call_id=1973313712-1965, service_data=entity_id=['- switch.bedroom_ceiling_light_switch\n - switch.family_room_ceiling_light_switch\n - switch.office_lights_switch_2'], domain=- switch>
Oct 02 19:40:21 HomeControl hass[19978]: 2017-10-02 19:40:21 WARNING (MainThread) [homeassistant.core] Unable to find service - switch/turn_off
Nothing works …
But if I just hardcode this YAML:
- service: switch.turn_off
data_template:
entity_id:
- switch.bedroom_ceiling_light_switch
- switch.family_room_ceiling_light_switch
- switch.office_lights_switch_2
It works perfectly with the following log:
Oct 02 20:13:54 HomeControl hass[19978]: 2017-10-02 20:13:54 INFO (MainThread) [homeassistant.helpers.script] Script follow_me_lights_on: Executing step call service
Oct 02 20:13:54 HomeControl hass[19978]: 2017-10-02 20:13:54 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service=turn_off, service_call_id=1973313712-2162, service_data=entity_id=['switch.bedroom_ceiling_light_switch', 'switch.family_room_ceiling_light_switch', 'switch.office_lights_switch_2'], domain=switch>
So the key difference is that in all previous cases, it takes all 3 light_ids as one string… But in the working sample, it sees each switch as separate entity…