Trying to use a rotary encoder to set target temperature of a thermostat. Code is here:
binary_sensor:
- platform: template
id: fire
- platform: gpio
id: button
pin:
number: D4
inverted: true
on_press:
then:
- switch.toggle: heat_adjust
dallas:
pin: D2
update_interval: 3s
climate:
- platform: thermostat
# min_cooling_off_time: 0s
# min_cooling_run_time: 0s
min_heating_off_time: 0s
min_heating_run_time: 0s
min_idle_time: 0s
visual:
min_temperature: 15 °C
max_temperature: 30 °C
name: "Living Room Thermostat"
id: this_thermostat
sensor: internal_temperature
default_target_temperature_low: 20
# default_target_temperature_high: 28
# cool_action:
# - logger.log: "Cooler On"
heat_action:
- switch.turn_on: relay_heater
- lambda: id(fire).publish_state(true);
- homeassistant.service:
service: homeassistant.turn_on
data:
entity_id: ${entity_heater}
idle_action:
- switch.turn_off: relay_heater
- lambda: id(fire).publish_state(false);
- homeassistant.service:
service: homeassistant.turn_off
data:
entity_id: ${entity_heater}
preset:
- name: Night
default_target_temperature_low: 20
# default_target_temperature_high: 28
- name: Day
default_target_temperature_low: 22.22
# default_target_temperature_high: 28
- name: Away
default_target_temperature_low: 18.9
# default_target_temperature_high: 28
sensor:
- platform: dallas
id: internal_temperature
address: 0xec3cd3f648bf6828
- platform: rotary_encoder
id: encoder
pin_a:
number: D6
mode: INPUT_PULLUP
pin_b:
number: D7
mode: INPUT_PULLUP
on_clockwise:
- if:
condition:
switch.is_on: heat_adjust
then:
- climate.control:
id: this_thermostat
target_temperature_low: !lambda "return id(this_thermostat).target_temperature_low + 0.5;"
on_anticlockwise:
- if:
condition:
switch.is_on: heat_adjust
then:
- climate.control:
id: this_thermostat
target_temperature_low: !lambda "return id(this_thermostat).target_temperature_low - 0.5;"
The thermostat uses a Dallas probe as sensor. The button toggles a switch, heat_adjust, which allows the encoder to set the low target temperature. Or should allow; as written here, I get this error when turning the encoder:
[12:19:57][W][climate:106]: Cannot set low/high target temperature for this device!
However, if I remove the commented-out lines, thereby converting the thermostat into a dual-point, the encoder behaves as desired, moving the low target temperature up and down, forcing the high target temperature to move when needed. In short, it will control a dual-point but not a single-point thermostat. Why is that, and can I make the encoder work with a single-point thermostat? I’d prefer to see a single-point in the front-end.