#State Trigger with Dynamic entity_id?

1 messages · Page 1 of 1 (latest)

deep nebula
#

Hi, is this not possible? I tried to add a jinja template and it seems to fail:

trigger: state
entity_id: >-
  {{ expand(states.binary_sensor) 
     | selectattr('attributes.device_class', 'defined') 
     | selectattr('attributes.device_class', 'in', ['motion', 'door', 'window']) 
     | map(attribute='entity_id')
     | list }}

error: Message malformed: Entity {{ expand(states.binary_sensor) | selectattr('attributes.device_class' is neither a valid entity ID nor a valid UUID for dictionary value @ data['entity_id']

sonic tide
#

Short answer, no

#

Long answer, you could trigger on every state change event, and look then at what entity ID was involved

deep nebula
#

Yea do [] instead? That seems kinda compute inefficient?

value_template: |-
  {{ expand(states.binary_sensor) 
     | selectattr('attributes.device_class', 'defined') 
     | selectattr('attributes.device_class', 'in', ['motion', 'door', 'window']) 
     | selectattr('state', 'eq', 'on') 
     | list 
     | count > 0 }}
trigger: template

I had this template for trigger, but that only triggers when "on" is happening. not state change. fron on to off and off to on. Also it wont let me find which one in trigger.xx 😦

sonic tide
#

Event trigger