I have a bunch of automatons that increment a counter each time a motion detector is activated. I would like to consolidate these into a single automation.
I tied the following automation, but HA complains with Message malformed: not a valid value for dictionary value @ data[‘action’][0][‘entity_id’] when I save.
Any thoughts on resolving this?
alias: counter - motion activated test
description: ''
trigger:
- platform: state
from: 'off'
to: 'on'
entity_id: binary_sensor.motion_breakfast
- platform: state
from: 'off'
to: 'on'
entity_id: binary_sensor.motion_front_door
- platform: state
entity_id: binary_sensor.motion_gameroom
from: 'off'
to: 'on'
condition: []
action:
- service: counter.increment
data: {}
entity_id: |
{% if (trigger.entity_id) == 'binary_sensor.motion_breakfast' %}
counter.motbreakfast
{% elif (trigger.entity_id) == 'binary_sensor.motion_front_door' %}
counter.motfdoor
{% elif (trigger.entity_id) == 'binary_sensor.motion_gameroom' %}
counter.motgameroom
{% else %}
counter.motgameroom
{% endif %}
mode: single
Thanks!