Struggling to understand automation variables from trigger to notification message

I have searched and read but something isn’t clicking for me obviously so a post here is my last resort ( I really want to understand rather than just get the answer).

I have an automation rule:

alias: Notification - Printer Ink Low
description: ''
trigger:
  - type: value
    platform: device
    device_id: xxxxx
    entity_id: sensor.mfc_xxxxx_black_ink_remaining
    domain: sensor
    below: 10
    id: printer_black_ink_low
  - type: value
    platform: device
    device_id: xxxxx
    entity_id: sensor.mfc_xxxxx_cyan_ink_remaining
    domain: sensor
    below: 10
    id: printer_cyan_ink_low
  - type: value
    platform: device
    device_id: xxxxx
    entity_id: sensor.mfc_xxxxx_magenta_ink_remaining
    domain: sensor
    below: 10
    id: printer_megenta_ink_low
  - type: value
    platform: device
    device_id: xxxxx
    entity_id: sensor.mfc_xxxxx_yellow_ink_remaining
    domain: sensor
    below: 10
    id: printer_yellow_ink_low
condition: []
action:
  - service: notify.home_automation_group
    data:
      message: >-
        You need to purchase new ink for the printer:
        hXXps://www.amazon[.]co[.]uk/{URL TO INK NEEDED}
mode: single

What I am looking to achieve is the telegram message to say

{{ VARIABLE FOR Black/Cyan/Yellow ink etc }} is low , you need to go and buy this {{ variable for each ink URL in amazon needed }}

Is there a cheat sheet on what variables can be used , or how I determine what variable I need to use etc. I think once I get it , its going to be simple.

Thanks for any advice :wink:

Automation Triggers Variables

Also, you need to be familiar with this:
State Object

1 Like

You can create a mapper:

action:
  - service: notify.home_automation_group
    data:
      message: >
        {% set map = {
          'printer_yellow_ink_low': 'URL for yellow',
          'printer_cyan_ink_low': 'URL for cyan',
          'printer_black_ink_low': 'URL for black',
          'printer_magenta_ink_low': 'URL for magenta' 
        }%}
        You need to purchase new ink for the printer:
        hXXps://www.amazon[.]co[.]uk/{{ map[trigger.id] }}

You then use the id of the trigger to get the URL from the mapper.

1 Like

yeah i saw that, but

Paulus just changed from {{ trigger.from_state.state }}

how do I know what the {{ xxxxx }} bits are meant to be?

ok so tell me how do i read up about how this works, any resources?

Read the two links I posted.

ah you added another link, will have a read. cheers

That’s a simple dictionary in Jinja (language used for Home Assistant YAML code) → Template Designer Documentation — Jinja Documentation (3.0.x)

The part about trigger.id can be found in the trigger docs → Automation Trigger - Home Assistant and in the docs that Taras linked.

1 Like

cheers really handy