Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Template using multiple entity_ids

$
0
0

@epleypa wrote:

I’ve been working on developing a template to handle turning off groups of lights and switches when no motion has been detected for a certain amount of time. I’ve discovered that when using data_template and entity_id, you can only specify one entity.

My current code results in ERROR (MainThread) [homeassistant.components.homeassistant] homeassistant/turn_off cannot be called without entity_id when more than one entity is specified in the If/Elif logic

  action:
    - service: homeassistant.turn_off
      data_template: 
        entity_id: >
          {% if trigger.entity_id == 'binary_sensor.bedroom_motion' %}
            group.bedroom_lights
          {% elif trigger.entity_id == 'binary_sensor.livingroom_motion' %}
            group.living_room_lights, group.kitchen_lights, group.dining_room_lights
          {% endif %}

Adding quotes or forming a list results in homeassistant.exceptions.ServiceNotFound: Unable to find service - group/turn_off

  action:
    - service: homeassistant.turn_off
      data_template: 
        entity_id: >
          {% if trigger.entity_id == 'binary_sensor.bedroom_motion' %}
            - group.bedroom_lights
          {% elif trigger.entity_id == 'binary_sensor.livingroom_motion' %}
            - group.living_room_lights
            - group.kitchen_lights
            - group.dining_room_lights
          {% endif %}

Searching the forums, I found the following two threads attempting something similar but finding no solution:


One thread seemed to solve the issue in two ways (the first being similar to my current code above), but these methods seem to no longer work and result in homeassistant/turn_off cannot be called without entity_id:


Is this a bug or no longer feasible? All code checks out in the Jinja editor in Home Assistant, just not when triggering an automation.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>