I am trying to configure ESPHome and HASS.IO to use a two-way (on)-off-(on) momentary rockers switch to switch and dim a light defined on HASS (not directly connected to the ESP8266).
I have managed to get the switching action working but am stumped with the dimming part. I’ve tried in various ways, including based on this one by @DeanoX, but not succeeded yet.
What I would like to do is as follows:
Up button short push - light on
Down button short push - light off
Up button long push - light increases in brightness while button pushed
Down button long push - light decreases in brightness while button pushed
This is the code I have so far:
esphome:
name: esp8266_002
platform: ESP8266
board: esp01_1m
wifi:
ssid: "Secret"
password: "TopSecret"
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
binary_sensor:
- platform: gpio
pin:
number: 00
mode: INPUT_PULLUP
inverted: TRUE
name: "Up"
device_class: light
on_multi_click:
- timing:
- ON for 1s to 2s
- OFF for at least 0.5s
then:
- logger.log: "Up Single Long Clicked"
# test code follows - to be replaced by dimmer code
- homeassistant.service:
service: light.turn_on
data:
entity_id: "light.study1"
flash: short
# end test code
- timing:
- ON for at most 1s
- OFF for at least 0.5s
then:
- logger.log: "Up Single short Clicked"
- homeassistant.service:
service: light.turn_on
data:
entity_id: "light.study1"
- platform: gpio
pin:
number: 02
mode: INPUT_PULLUP
inverted: TRUE
name: "Down"
device_class: light
on_multi_click:
- timing:
- ON for 1s to 2s
- OFF for at least 0.5s
then:
- logger.log: "Down Single Long Clicked"
# test code follows - to be replaced by dimmer code
- homeassistant.service:
service: light.turn_on
data:
entity_id: "light.study1"
flash: long
# end test code
- timing:
- ON for at most 1s
- OFF for at least 0.5s
then:
- logger.log: "Down Single short Clicked"
- homeassistant.service:
service: light.turn_off
data:
entity_id: "light.study1"
I really would appreciate any help or guidance provided. Thanks.