I tried linking my central heating in using EMS-ESP, but the thermostat was incompatible.
The incremental rotary encoder in the thermostat uses quadrature encoding at ca. 3V which I thought would be straightforward enough to mimic using an ESP8266. I’ve attached connections to the relevant terminals of the encoder but have not managed to get functional code working yet for the ESP, so have not connected it yet. I’m relatively new to coding so may be making rookie mistakes…
This is my current code:
esphome:
name: esphome-web-10453a
friendly_name: ch-thermostat
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "myKey="
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-10453A"
password: "myPassword"
captive_portal:
#use GPIO4 and GPIO5 as no conflicts at boot
#read
# binary_sensor:
# - platform: gpio
# pin: GPIO5
# id: read_a
# - platform: gpio
# pin: GPIO4
# id: read_b
#write
switch:
- platform: gpio
pin: GPIO5
id: encoder_a
restore_mode: DISABLED
- platform: gpio
pin: GPIO4
id: encoder_b
restore_mode: DISABLED
button:
- platform: template
id: CHup
on_press:
- switch.toggle: encoder_a
- delay: 50ms
- switch.toggle: encoder_b
- delay: 50ms
- platform: template
id: CHdown
on_press:
- switch.toggle: encoder_b
- delay: 50ms
- switch.toggle: encoder_a
- delay: 50ms
Is the state of a GPIO switch stored somewhere, or is it actually checked first?
If the former, does it also need to be a binary sensor to check?
I’ve also tried this, but am getting complaints about syntax errors:
esphome:
name: esphome-web-10453a
friendly_name: ch-thermostat
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "myKey="
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-10453A"
password: "myPassword"
captive_portal:
#use GPIO4 and GPIO5 as no conflicts at boot
#read
binary_sensor:
- platform: gpio
pin: GPIO5
id: read_a
- platform: gpio
pin: GPIO4
id: read_b
#write
switch:
- platform: gpio
pin: GPIO5
id: encoder_a
restore_mode: DISABLED
- platform: gpio
pin: GPIO4
id: encoder_b
restore_mode: DISABLED
button:
- platform: template
id: CHup
on_press:
if:
binary_sensor.is_on: read_a
then:
- switch.turn_off: encoder_a
- delay: 50ms
else:
- switch.turn_on: encoder_a
- delay: 50ms
if:
binary_sensor.is_on: read_b
then:
- switch.turn_off: encoder_b
- delay: 50ms
else:
- switch.turn_on: encoder_b
- delay: 50ms
- platform: template
id: CHdown
on_press:
if:
binary_sensor.is_on: read_b
then:
- switch.turn_off: encoder_b
- delay: 50ms
else:
- switch.turn_on: encoder_b
- delay: 50ms
if:
binary_sensor.is_on: read_a
then:
- switch.turn_off: encoder_a
- delay: 50ms
else:
- switch.turn_on: encoder_a
- delay: 50ms
Any pointers very gratefully received! TIA