I have an automation that tells me when the fridge is open - with a temperature sensor inside the fridge transmitting by 433 MHz.
The automation works fine and sends a Telegram message.
Now I want to change it so the message includes the actual temperature from the sensor.
Below is as far as I can get.
- id: 4b75316ea5bc479fbebd4ca86b12e9f1
alias: Fridge over temperature alarm
trigger:
- above: '2'
entity_id: sensor.fridge_temp
platform: numeric_state
action:
- service: telegram_bot.send_message
data_template:
title: '*HA Alert!*'
target: '142XXXXXX'
message: Fridge was opened.
- service: telegram_bot.send_message
data_template:
title: '*HA Alert!*'
target: '142XXXXXX'
message: 'Fridge was opened. Temperature = {{ sensor.fridge_temp }}°C'
- service: telegram_bot.send_message
data_template:
title: '*HA Alert!*'
target: '142XXXXXX'
message: 'Fridge was opened. Temperature = °C'
Only 2 of the 3 messages are sent - the 1st & 3rd.
The first is my original message.
The 2nd is the problem message - I am thinking the variable is the problem.
The 3rd message is sent ok - it is just a test message to ensure the automation isn’t getting stuck and also to confirm that there are no other characters causing the problem.
Can variable values not be included in automation actions (messages)?
Or do I have something else wrong?
Thanks very much!
I would have not have figured it out - I looked at a few different examples in the community postings that don’t include that ‘states.’ at the beginning. Included it and ‘.state’ at the end and it is working perfectly now.
Ah, that’s very helpful! Thank you.
How about adding the triggerID to the message (after setting this optional triggerID in the automation trigger section)?
I am trying to send the trigger ID with the telegram message:
alias: "Sicherheit: Bewegung vorm Haus detektiert (Überwachungsmodus)"
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.haustur_motion
from: "off"
to: "on"
id: Ring
- platform: state
entity_id:
- binary_sensor.pir_sensor_with_relay_home_security_motion_detection
from: "off"
to: "on"
id: GartenhausPIR
condition:
- condition: or
conditions:
- condition: state
entity_id: group.persons
state: not_home
- condition: state
entity_id: input_boolean.nightmode
state: "on"
- condition: state
entity_id: input_boolean.bewegungs_meldung_aussen
state: "on"
action:
- service: notify.mobile_app_iphone
data:
message: Bewegung im Garten vorne detektiert!
title: Sicherheit
- service: telegram_bot.send_photo
data:
url: http://192.168.68.74/cgi-bin/snapshot.cgi?1
username: admin
password: xxx
caption: Bewegung im Garten vorne durch {{id}} detektiert.
mode: single
I tried:
{{id}}
{{trigger.id}}
In your example the are quotes, but the oroginal code in my case did not have quotes.
Adding quotes does not change anything though.