Cannot set thermostat target temperature

I flashed a NodeMCU with a thermostatic controller,(heat only) like so:

climate:
  - platform: thermostat
    name: "Bedroom Thermostat"
    id: bedroom_thermostat
    min_heating_off_time: 3min
    min_heating_run_time: 3min
    min_idle_time: 0min
    sensor: bedroom_temperature
    default_target_temperature_low: 20
    heat_deadband: .4
    heat_overrun: .4
    heat_action:
      - switch.turn_on: relay_heater
    idle_action:
      - switch.turn_off: relay_heater
    preset:
    - name: Night
      default_target_temperature_low: 20
    - name: Day
      default_target_temperature_low: 22.22
    - name: Away
      default_target_temperature_low: 18.9

It runs and both presets and target temperature can be controlled from HA frontend thermostat card. I connected a rotary encoder to the NodeMCU to control target temperature, like so:

  - platform: rotary_encoder
    id: encoder
    pin_a:
      number: D6
      mode: INPUT_PULLUP
    pin_b:
      number: D7
      mode: INPUT_PULLUP
    on_clockwise:
      then:
        - climate.control:
            id: bedroom_thermostat
            target_temperature_low: !lambda "return id(bedroom_thermostat).target_temperature_low + 0.5;"
    on_anticlockwise:
      then:
        - climate.control:
            id: bedroom_thermostat
            target_temperature_low: !lambda "return id(bedroom_thermostat).target_temperature_low - 0.5;"

but turning the encoder knob gives this error:

[13:11:46][D][climate:010]: 'Bedroom Thermostat' - Setting
[13:11:46][W][climate:106]:   Cannot set low/high target temperature for this device!

Am I using the wrong command, or is the thermostat set up wrong? Thanks for any help.

I also tried this code, which I found on this forum:

  - platform: rotary_encoder
    id: encoder
    pin_a: D6
    pin_b: D7
    min_value: 20
    max_value: 70
    resolution: 2
    filters:
    - lambda: return x * 0.5;
    on_value:
      then:
      - delay: 0.2s
      - homeassistant.service:
          service: climate.set_temperature
          data_template:
            entity_id: climate.bedroom_thermostat
            temperature: !lambda "return id(encoder).state;"

but this throws a stack error exception.

Since you’re only using it for heat mode, you should be using target_temperature instead of target_temperature_low.

Try this code for your climate action:

- platform: rotary_encoder
    id: encoder
    pin_a:
      number: D6
      mode: INPUT_PULLUP
    pin_b:
      number: D7
      mode: INPUT_PULLUP
    on_clockwise:
      then:
        - climate.control:
            id: bedroom_thermostat
            target_temperature: !lambda "return id(bedroom_thermostat).target_temperature + 0.5;"
    on_anticlockwise:
      then:
        - climate.control:
            id: bedroom_thermostat
            target_temperature: !lambda "return id(bedroom_thermostat).target_temperature - 0.5;"

Yeah, I eventually guessed that. It’s a little confusing because the thermostat itself requires temperature_low even in single mode. Thanks.

1 Like