I have the following automation
- id: '1600800443864'
alias: Canon Printer needs attention
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.cnlbp622c_623c_canon_cartridge_054_black_toner
below: '10'
- platform: numeric_state
entity_id: sensor.cnlbp622c_623c_canon_cartridge_054_cyan_toner
below: '10'
for: 0:05:00
- platform: numeric_state
entity_id: sensor.cnlbp622c_623c_canon_cartridge_054_magenta_to
below: '10'
for: 0:05:00
- platform: numeric_state
entity_id: sensor.cnlbp622c_623c_canon_cartridge_054_yellow_ton
below: '10'
for: 0:05:00
condition: []
action:
- service: notify.glenn_telegram
data:
message: '"{{ trigger.entity_id.attributes.friendly_name }} toner on the Canon
Laser Printer is running low."'
mode: single
In the message of the action, if I have it as shown, nothing at all happens and I get the following error.
homeassistant.exceptions.HomeAssistantError: Error rendering data template: UndefinedError: 'trigger' is undefined
If I change the template to
{{ state_attr('trigger.entity_id', 'friendly_name') }}
then the notification goes out, but is says “none toner on the Canon Laser Printer is running low.”
Below is an example of the attributes of the sensors being triggered against
marker_low_level: 7
marker_type: toner
unit_of_measurement: %
friendly_name: Black
icon: mdi:water
I have searched the forums and only found older messages that recommend the 2 methods I have tried, but these appear to no longer work. How does this now work?