Automation help: temperature sensor + climate + time

Hi, i wanna heat bedroom in the night. If sesor detect 19ºC start heating, if bedroom reach 21º it stop. This automation applyes only from 22h to 06am. I have make to automations. Does it have sense? trigguer is correct? Thanks

  - id: heat_night_bedroom_start
    alias: Heat Night Bedroom
    trigger:
      platform: time_pattern
      minutes: '/1'
    condition:
      condition: and
      conditions:
        - condition: time
          after: '22:00:00'
          before: '06:00:00'
        - condition: numeric_state
          entity_id: sensor.bedroom_temperature
          below: 19
    action:
      service: notify.telegram
      data:
        message: Bedroom at 19, heat started

      service: climate.set_temperature
      entity_id: climate.termostato_casa
      data:
        temperature: 21


  - id: heat_night_bedroom_stop
    alias: Stop Heating Bedroom at Night
    trigger:
      platform: time_pattern
      minutes: '/1'
    condition:
      condition: and
      conditions:
        - condition: time
          after: '22:00:00'
          before: '06:00:00'
        - condition: numeric_state
          entity_id: sensor.bedroom_temperature
          above: 21
    action:
      service: notify.telegram
      data:
        message: Bedroom at 21, heat stoped

      service: climate.set_temperature
      entity_id: climate.termostato_casa
      data:
        temperature: 19
1 Like

You don’t need to trigger the automations every minute, instead trigger the first automation when temp is goes below 19 and the second when it goes above 21.

Thanks Burningstone. What do you think i should use as Trigger then? (as far as i know, all automations require : trigger(s) + conditions(s) + action(s) isnt it?)

Thanks!

All automations require triggers and actions, conditions are optional.

Your trigger would be a numeric state trigger and look like this:

trigger:
  platform: numeric_state
  entity_id: sensor.bedroom_temperature
  below: 19

You can then remove the numeric_state condition. You also need to add a dash before “service” in your actions so that the system know there are two actions, you can’t separate them with a blank line.

In the end it should look something like this:

- id: heat_night_bedroom_start
  alias: Heat Night Bedroom
  trigger:
    platform: numeric_state
    entity_id: sensor.bedroom_temperature
    below: 19
  condition:
    condition: time
    after: '22:00:00'
    before: '06:00:00'
  action:
    - service: notify.telegram
      data:
        message: Bedroom at 19, heat started
    - service: climate.set_temperature
      entity_id: climate.termostato_casa
      data:
          temperature: 21
1 Like