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