Automation data action uri change to trigger sensor

Hi,

I’ve got an automation which informs me about the lights if these are still on for 2 hours.
Because of the multiple triggers, I want to have a data action (a button in the notification) that points/go to the belonging trigger sensor.

So for instance when the lightgarage triggers, this uri needs to point to:
uri: entityId:sensor.lightgarage
And when another trigger is hit (lets say lightkitchen, the uri needs to change to that light entity:
uri: entityId:sensor.lightkitchen

Is this possible?

alias: light
description: ""
trigger:
  - platform: state
    entity_id:
      - light.garage
    for:
      hours: 2
      minutes: 0
      seconds: 0
    from: "off"
    to: "on"
  - platform: state
    entity_id:
      - light.kitchen
    for:
      hours: 2
      minutes: 0
      seconds: 0
    from: "off"
    to: "on"
condition: []
action:
  - service: notify.family
    data:
      message: "{{ trigger.entity_id }}\" is on for 2 hours, is this needed?"
      title: Lights
  data:
    actions:
      - action: URI
        title: LightGarage
        uri: entityId:sensor.lightgarage

Check your indentation in the action. Should be something like:

alias: light
description: ""
trigger:
  - platform: state
    entity_id:
      - light.garage
      - light.kitchen
    for: "02:00:00"
    from: "off"
    to: "on"
condition: []
action:
  - service: notify.family
    data:
      message: "{{ trigger.entity_id }}\" is on for 2 hours, is this needed?"
      title: Lights
      data:
        actions:
          - action: "URI"
            title: "{{ trigger.to_state.name }}"
            uri: "entityId:{{ trigger.entity_id }}"

References:

Trigger variables for a state trigger:

State object, for the name property:

Structure of actionable notifications:

This last doc doesn’t explicitly state that templates are supported in the uri field. Try it as above and report back if successful.

1 Like

Thanks for the reply
This one works:

      - action: URI
        title: "{{ trigger.to_state.name }}"
        uri: entityId:{{ trigger.entity_id }}