Help with temperature sensor automation

Hello everybody,
i’m new to HA and my goal is to create a system to manage the power on of my heating system.
At the moment i have a temperature sensor (sensor.lumi_lumi_weather_temperatura) and an input number (input_number.temperatura_mansarda). My goal is to turn on a switch (switch.shellyplus2pm_80646fc854b8_switch_0) if the temperature is below the numeric input and turn off is above.

Examples:
numeric_value = 20
temperature = 22
result = off

numeric_value = 20
temperature = 18
result = on

i can achieve it with an automation that relies only with the numeric value like:

- id: '1700568160785'
  alias: Accendi mansarda
  description: ''
  trigger:
  - platform: numeric_state
    entity_id:
    - input_number.temperatura_mansarda
    above: sensor.lumi_lumi_weather_temperatura
  condition: []
  action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.shellyplus2pm_80646fc854b8_switch_0
  mode: single
- id: '1700568209508'
  alias: Spegni mansarda
  description: ''
  trigger:
  - platform: numeric_state
    entity_id:
    - input_number.temperatura_mansarda
    below: sensor.lumi_lumi_weather_temperatura
  condition: []
  action:
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.shellyplus2pm_80646fc854b8_switch_0
  mode: single

with this automation when moving the slider above the temperature value the switch is turning on, and when below turns off.
What i am missing is that if the switch is on and the temperature raise above the value, the switch should be turned off.

I suggest you use the Generic Thermostat integration to control it.

thanks for this!
i’ve managed everything as the example and inserted the yaml in configuration.yaml but i cannot see the thermostat.

My yaml:

climate:
  - platform: generic_thermostat
    name: Temperatura mansarda
    heater: switch.shellyplus2pm_80646fc854b8_switch_0
    target_sensor: sensor.lumi_lumi_weather_temperatura
    min_temp: 0
    max_temp: 50
    ac_mode: false
    target_temp: 18
    cold_tolerance: 0.3
    hot_tolerance: 0
    min_cycle_duration:
      seconds: 5
    keep_alive:
      minutes: 3
    precision: 0.1

Restart Home Assistant.

Then check Developer Tools > States for the presence of climate.temperatura_mansarda

If it doesn’t exist, check the Log for errors.

yeah after some reboot started working, thank you so much!

1 Like