Temperature in automation notification not working

Once I add the temperature to the notification the Automation breaks

alias: Fridge open for X minutes
description: ''
trigger:
 
  - type: temperature
    platform: device
    device_id: c6f39af9eb083ffaf219296a47b0f69e
    entity_id: sensor.frezer_temperature_2         #EDITED
    domain: sensor
    above: -5
    for:
      hours: 0
      minutes: 1
      seconds: 3
      milliseconds: 0

condition: []
action:
  - service: telegram_bot.send_message
    data:
      message: Temp {{ state_attr('sensor.frezer_temperature_2','temperature') }}
mode: single

this is my sensor

when you add “temperature” or " state_attr “, or does your “service: telegram” work with a Hello World” ?
Does you temperature_device have an attribute called “temperature” ?
EDIT: I assume you have noticed the trailing _2 on your entity, and that 1 (same friendly name )is unavailable in your card

1 Like

i.e IF your read your attached code, you’ll notice you use 2 different entities

entity_id: sensor.frezer_temperature
and
state_attr(‘sensor.frezer_temperature_2’

and you try to show state_attr(attribute) from your temp_sensor, and not i.e

{{ states('sensor.frezer_temperature_2') }} or what ever sensor you decide you want the state from
1 Like

Yes, Telegram works with Hello World.

the sensor.frezer_temperature_2 is the one I want the temperature from, it shows -20c but i’m not able to pull it with:

message:  Fridge open: Temp {{ state_attr('sensor.frezer_temperature','temperature') }}` 

if I use:

message:  Fridge open: Temp {{ state('sensor.frezer_temperature_2') }}

then I will get NONE
Fridge open:Temp None

and if I use:

  message:  Fridge open: Temp {{ 'sensor.frezer_temperature_2' }}

I will gent also NONE
Fridge open:Temp None

not sure how to see if the device has an attribute temperature:
Screen Shot 2022-05-13 at 11.26.21 AM

which one is showing “unavailable” in your card ? … you have to know whether it is
sensor.frezer_temperature_2 or sensor.frezer_temperature that works and then ONLY use this in your automation
NOTE: You use 2 different sensors in your automation( im very certain that 1 of these is NOT available, AS your card says", … you take temperature from 1 sensor, then use another sensor in you “message” ? … it’s like saying “check temp i frezer and send me message with temperature from fridge”

trigger:
 
  - type: temperature
    platform: device
    device_id: c6f39af9eb083ffaf219296a47b0f69e
    entity_id: sensor.frezer_temperature
    domain: sensor
    above: -5
    for:

NOTE ABOVE:: entity_id: sensor.frezer_temperature

NOTE ABOVE: sensor.frezer_temperature_2

Do you have 2 sensors in your Frezer, as your card shows ?

1 Like

And this is my espHome device:


dallas:
  - pin: GPIO0

sensor:
  - platform: dallas
    address: 0xDA0516A4B4C8FF28
    name: "Frezer Temperature"

and not sure which are frezer_temperature_2 and frezer_temperature.
however the one what shows the temp on the card is frezer_temperature_2

Screen Shot 2022-05-13 at 12.14.20 PM

Screen Shot 2022-05-13 at 12.16.14 PM

then change your automation to

trigger:
 
  - type: temperature
    platform: device
    device_id: c6f39af9eb083ffaf219296a47b0f69e
    entity_id: sensor.frezer_temperature_2
1 Like

unfortunately it will not work also with frezer_temperature_2 in the trigger.

I’m having the problem that I can send Hello World but non of these are working:

message:  Fridge open: Temp {{ state_attr('sensor.frezer_temperature','temperature') }}` 

message:  Fridge open: Temp {{ state('sensor.frezer_temperature_2') }}

message:  Fridge open: Temp {{ 'sensor.frezer_temperature_2' }}

Try


message:  "Fridge open: Temp {{ state_attr('sensor.frezer_temperature','temperature') }}"


or

# states, not state
message:  "Fridge open: Temp {{ states('sensor.frezer_temperature_2') }}"

1 Like

Finally got it to work!!!
I also changed the name of frezer_temperature_2 to frezer_temp

message: Frige Open Temp {{ states('sensor.frezer_temp') }}

Thank you so much!!!

You can always check your Jinja code via Developer Tools —> Template.