Event triggers

Hi,

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

Thanks!

Neil

Please format your code correctly:

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?

Hi,

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.

Thanks

Neil

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.

1 Like

Thanks - that works just fine. Not clear why it doesn’t work the other way, but as long as it achieves the desired result :slight_smile:

Thanks

Neil

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?

Probably a problem with indentation, but we can’t tell, because you did not post your code correct.

f6be36681e0da431418ec7781fb6c62712941803

Sorry for that. It’s not code, it’s developer event log.

Same thing: formatting is important.