Noob help: triggering heater based on temperature

As my first attempt at a proper automation, I’m trying to control my office heater based on a temperature sensor. My code in automations.yaml is:

- id: '1689215707989'
  alias: Shed Heater Toggle
  description: ''
  triggers:
  - trigger: numeric_state
    id: 'On'
    entity_id:
    - sensor.lywsd03mmc_shoffice_shoffice_temp
    below: 21.2
  - trigger: numeric_state
    id: 'Off'
    entity_id:
    - sensor.lywsd03mmc_shoffice_shoffice_temp
    above: 22
  conditions: []
  actions:
  - choose:
    - conditions:
      - condition: trigger
        id:
        - 'On'
      sequence:
      - type: turn_on
        device_id: bc656e78431faea14dafd79374b40dd5
        entity_id: 0c82c3e1c52289b85ac40ff669a4b24e
        domain: switch
    - conditions:
      - condition: trigger
        id:
        - 'Off'
      sequence:
      - type: turn_off
        device_id: bc656e78431faea14dafd79374b40dd5
        entity_id: 0c82c3e1c52289b85ac40ff669a4b24e
        domain: switch
  mode: single

I expect this to turn on the heater when the temperature goes below 21.2 C and switch it off when it goes above 22 C (test values).

However, when the temperature drops, nothing happens. Any clues as to why or how I would debug this?

Thanks

Dave

Don’t reinvent the wheel. Use a generic thermostat helper.

1 Like

Thanks, I’ll check that out.