Entity_id: for triggers using platform: state or platform: webhook

I know I can get the entity_id of an event that triggered an automation with:

trigger.event.data.entity_id

How do I get the entity_id if the trigger uses platform: state or platform: webhook? I’ve tried, for example changing trigger.event to trigger.state

- alias: "Timer Cancel"
  mode: parallel
  trigger:
    - platform: state
      to: "off"
      entity_id:
        - switch.office_credenza
        - switch.office_desk
  action:
    - service: timer.cancel
      entity_id: "timer.{{ trigger.state.data.entity_id.split('.')[-1] }}"
# to cancel , for example timer.office_desk

trigger.to_state.entity_id for state trigger.

trigger.data.entity_id (presuming an entity_id is passed as part of the data structure) for webhook.

1 Like

Perfect. I now understand the context of those variables.

it’s like having a superpower!

Cheers, Richard

1 Like