Question about alert on temp

Hi i was wondering if someone could shed some light, Currently using one of the devices to monitor temperature, but cant seem to get working the trigger, not sure how to configure it
I have the following as the triggers worked which i tested but cant seem to trigger correctly, the idea is to alert me when its above 22 degrees or alert me below 15 degrees, and in theory at the moment its 23.2 should of alert it me

This will trigger when the temperature crosses from inside to outside the range:

trigger: platform: numeric_state
entity_id: sensor.temperature
above: 22
below: 15

If your sensor was already above 22 when you created the automation nothing will happen. It has to be below 22 first, then go above 22 to trigger.

You can overcome this by the addition of HA start and automation reload triggers along with a numeric condition to check the temperature is outside the range.

thanks for the reply so i configured the following

alias: Telegram Alert Temperature Site A
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.multisensor_7_air_temperature
condition:
  - condition: numeric_state
    entity_id: sensor.multisensor_7_air_temperature
    below: "22"
    above: "22"
action:
  - service: telegram_bot.send_message
    data:
      message: Alert Temperature HIGH on site A
mode: single

and current temperature is right now 25.4 should of gotten an alert?

or how would i reset the trigger?

Thanks

No. How can the temperature be above 22 and below 22 at the same time?

You could do it like this:

alias: Telegram Alert Temperature Site A
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.multisensor_7_air_temperature
condition:
  - condition: or
      - condition: numeric_state
        entity_id: sensor.multisensor_7_air_temperature
        below: "22"
      - condition: numeric_state
        entity_id: sensor.multisensor_7_air_temperature
        above: "22"
action:
  - service: telegram_bot.send_message
    data:
      message: Alert Temperature HIGH on site A
mode: single

However with that trigger and condition you will get an alert just about every time the sensor updates (except when the sensor == 22).

Do it like I said:

alias: Telegram Alert Temperature Site A
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.multisensor_7_air_temperature
    above: 22
  - platform: numeric_state
    entity_id:
      - sensor.multisensor_7_air_temperature
    below: 15
  - platform: event
    event_type: call_service
    event_data:
      domain: automation
      service: reload
  - platform: event
    event_type: call_service
    event_data:
      domain: homeassistant
      service: reload_all
  - platform: homeassistant
    event: start
condition:
  - condition: or
     conditions:
      - condition: numeric_state
        entity_id: sensor.multisensor_7_air_temperature
        below: 15
      - condition: numeric_state
        entity_id: sensor.multisensor_7_air_temperature
        above: 22
action:
  - service: telegram_bot.send_message
    data:
      message: "Alert Temperature HIGH on site A: {{ trigger.to_state }} °C"
mode: single

This way you only get an alert when it crosses above or below your thresholds or if the sensor is already above or below the threshold when you restart or reload you will also get an alert.

EDIT: fixed syntax errors.

Thank you so much for the reply, currently i tried coppying and pasting but im getting this error

Message malformed: extra keys not allowed @ data['above']

This is wrong, platform: state does not support below.

Replace with

trigger:
  - platform: numeric_state
    entity_id:
      - sensor.multisensor_7_air_temperature
    above: 22
  - platform: numeric_state
    entity_id:
      - sensor.multisensor_7_air_temperature
    below: 15
2 Likes

Thank you so much for the reply, but it seems the part of

condition:
  - condition: or
      - condition: numeric_state
        entity_id: sensor.multisensor_7_air_temperature
        below: 15
      - condition: numeric_state
        entity_id: sensor.multisensor_7_air_temperature
        above: 22

shows issue
as son as i remove that part it let me saves

You need an additional conditions: line after the or — see the docs:

condition:
  - condition: or
    conditions:
      - condition: numeric_state
        entity_id: sensor.multisensor_7_air_temperature
        below: 15
      - condition: numeric_state
        entity_id: sensor.multisensor_7_air_temperature
        above: 22

Thank you so much that did the trick, so if the temperature is above 22 i should get an alert? lets say i want to change 22 to 28 which i was trying but when i test the condition im getting does not pass

alias: Telegram Alert Temperature Site A
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.multisensor_7_air_temperature
    above: 28
  - platform: numeric_state
    entity_id:
      - sensor.multisensor_7_air_temperature
    below: 21
  - platform: event
    event_type: call_service
    event_data:
      domain: automation
      service: reload
  - platform: event
    event_type: call_service
    event_data:
      domain: homeassistant
      service: reload_all
  - platform: homeassistant
    event: start
condition:
  - condition: or
    conditions:
      - condition: numeric_state
        entity_id: sensor.multisensor_7_air_temperature
        below: 21
      - condition: numeric_state
        entity_id: sensor.multisensor_7_air_temperature
        above: 28
action:
  - service: telegram_bot.send_message
    data:
      message: "Alert Temperature HIGH on site A: {{ trigger.to_state }} °C"
mode: single

What is the current temperature indicated by your sensor?

Is it above 28 or below 21?

thanks for the reply, currently right now its showing 24.4 Celsius

So it won’t get past the condition block because it is neither below 21 nor above 28.

thanks for the reply, the idea is to alert me when the temperature is above 28 or below 21

I know. You seemed confused that the UI was saying “condition does not pass”.

With the conditions you have set up and a current temperature of 24 that is expected behaviour.

When the temperature is below 21 or above 28, then the condition will pass and you will be sent an alert.

1 Like

gotcha thank you so much yeah i was bit confused thank you again