I’m trying to create a trigger which will look for an event being marked as complete in a todo list, with the name of the event being based on a sensor value. This is what I have so far, but it never seems to trigger - am I looking at this wrong, or will a slight syntax change make this work for me?
platform: event
event_type: call_service
event_data:
domain: todo
service: update_item
service_data:
rename: >-
"Get {{states('sensor.tomorrows_meat')}} out of the freezer for tomorrows
dinner"
status: completed
entity_id:
- todo.jobs
id: Tomorrows meat has been taken out of the freezer
enabled: true
Have you tried listening to the Event bus (under Developer Tools) to see this event happening? Does it really include the rename as well as the status update?
Sorry, the code is now reformatted - I was struggling to do that before. I got the format from the developer tools\events, this is the output of the event:
event_type: call_service
data:
domain: todo
service: update_item
service_data:
item: 82e436ea-009f-11ef-b33e-f0d4e2f42d0e
rename: Get Chicken out of the freezer for tomorrows dinner
status: completed
entity_id:
- todo.jobs
origin: LOCAL
time_fired: "2024-04-22T12:27:17.731567+00:00"
context:
id: 01HW2WCQV382YBRCTTCKGPCRB8
parent_id: null
user_id: eb626ba213c44c87b2d6ab4201966b0e
It seems to work OK until I introduce the sensor into the syntax.
Perhaps try setting up the trigger without the rename, then checking for that in a condition. Here, I’m using a template condition in shorthand notation:
condition:
- "{{ 'freezer for tomorrows dinner' in trigger.event.data.service_data.rename }}"
Even if it doesn’t work first time like that, it should give an automation trace that’ll show you why it’s not working.
This worked for me quite reliably. I have a feeling that it’s gotten significantly worse with the last update - but I’m not sure on timing.
I get two kinds of results. First one is with .rename set:
event_type: call_service
data:
domain: todo
service: update_item
service_data:
item: ME5YekpwV0FsbnRTcVNjeA
rename: Fünf
status: completed
entity_id:
- todo.arbeit
origin: LOCAL
time_fired: “2024-08-22T06:25:16.283291+00:00”
context:
id: 01J5WC5HFVFY4HZJ1PT6V1QHFH
parent_id: null
user_id: 40053342b6174b079a9a62a23b9298af
Second this is with .rename empty:
event_type: call_service
data:
domain: todo
service: update_item
service_data:
item: Vier
status: completed
entity_id:
- todo.arbeit
origin: LOCAL
time_fired: “2024-08-22T06:23:49.735791+00:00”
context:
id: 01J5WC2WZ771S79QR3BZNPPEV3
parent_id: 01J5WC2WZ6AF71F4XBTKA7A8RJ
user_id: null
I have adjusted my automation to catch both cases…but shouldn’t it always behave in the same way?