Hi all!! First time posting here, so thanks in advance for anyone who reads this.
I’m recently started with Home Assistant. I have some experience programming Arduino and electronics, but I’m still discovering this amazing HA world.
I want to have an automation that checks the value of two temperature sensors, and sends me a Telegram message indicating which one is higher. One sensor is an Arduino that I have on my living room, the other is taking the real time temperature outside from OpenWeatherMap. I want the automation to only trigger once (if temperature outside is higher, send a message. Don’t send it again while temperature outside is higher).
Everything works fine except the blocking of the same state. I’m getting a Telegram message every minute, when it checks de value of the sensors.
I’ve been chating with ChatGPT which helped me with the automation, but I cannor get the blocking of the same state to work.
My code for the automation is as follows:
alias: Comparar sensores y enviar notificación a Telegram
trigger:
- platform: state
entity_id: sensor.openweathermap_temperature, sensor.termometre_d1mini_temperatura
action:
- choose:
- conditions:
- condition: and
conditions:
- condition: numeric_state
entity_id: sensor.openweathermap_temperature
above: sensor.termometre_d1mini_temperatura
- condition: template
value_template: "{{ not caso2_activado }}"
sequence:
- service: notify.casallestabot
data:
message: >-
La temperatura de OpenWeatherMap es mayor que la temperatura de
Termometre D1 Mini.
- service: input_boolean.turn_on
entity_id: input_boolean.caso1_activado
- service: input_boolean.turn_off
entity_id: input_boolean.caso2_activado
- conditions:
- condition: and
conditions:
- condition: numeric_state
entity_id: sensor.termometre_d1mini_temperatura
above: sensor.openweathermap_temperature
- condition: template
value_template: "{{ not caso1_activado }}"
sequence:
- service: notify.casallestabot
data:
message: >-
La temperatura de Termometre D1 Mini es mayor que la temperatura
de OpenWeatherMap.
- service: input_boolean.turn_on
entity_id: input_boolean.caso2_activado
- service: input_boolean.turn_off
entity_id: input_boolean.caso1_activado
variables:
caso1_activado: "{{ is_state('input_boolean.caso1_activado', 'on') }}"
caso2_activado: "{{ is_state('input_boolean.caso2_activado', 'on') }}"
Any idea how to make it work??
Hope everything makes sense, English is not my language.
Thanks ALL!!!