Automation air conditioning, below X OFF, above Y ON

I wish to automated an old A/C not inverter mode that never follows the internal temperature reading.

The goal is that

  • during the night automatically
  • if temperature below 24 the IR blaster sends OFF command
  • if temperature above 26 the IR blaster sends ON command

Is the below code correct?

  - alias: Air Gilma ON
    trigger:
      platform: time
      minutes: '/10'
      seconds: 00
    condition:
      condition: and
      conditions: 
        - condition: time
          after: '23:00:00'
          before: '07:00:00'
        - condition: template
          value_template: '{{ states.sensor.netatmo_gilma_bedroom_temperature.state > 26 }}'
    action:
      - service: switch.turn_on
        entity_id: switch.air_gilma
  - alias: Air Gilma OFF
    trigger:
      platform: time
      minutes: '/10'
      seconds: 00
    condition:
      condition: and
      conditions: 
        - condition: time
          after: '23:00:00'
          before: '07:00:00'
        - condition: template
          value_template: '{{ states.sensor.netatmo_gilma_bedroom_temperature.state < 24 }}'
    action:
      - service: switch.turn_off
        entity_id: switch.air_gilma

Probably correct, but can be simplified by changing the template condition to a numeric_state condition

  • condition: numeric_state
    entity_id: ‘sensor.netatmo_gilma_bedroom_temperature’
    below: ‘24’

the automation is not working. Is it because the above things of two different days and never fires?

I haven’t tried this, but the documentation says that spanning midnight is valid.

EDIT:
I ran a similar automation on my test system and it turns out that the sensor that I was using for temperature was not a numeric value. I had to convert it to float for the template to pass.

Try this:
value_template: ‘{{ states.sensor.netatmo_gilma_bedroom_temperature.state | float > 26 }}’