Hi, I have a mini-smart switch (with a BK7231 inside) running ESPHome controlling the light in my garage. Prior to installing the mini-smart switch, the light was controlled by a three-way switch.
Because of the three-way switch, the mini-smart switch needs to toggle the relay each time that either of the switches’ state is changed.
I have added a script to the ESPHome yaml to turn off the light after a set amount of time.
I’d like to add the ability to turn on the light with no time limit so that when I’m working in the garage for an extended period of time I don’t have to keep turning the light back on. This could be by pressing a switch three times quickly - on/off/on. I thought about adding a template binary sensor to record the type of ‘click’ and then only run the turn off script for single-clicks, but can’t see how to get it to work. Can someone give me an idea of whether this is the right way to go, or if there is something simpler?
My existing config:
esphome:
name: "ha-eh-lights-garage"
friendly_name: Garage Lights
bk72xx:
framework:
version: latest
board: generic-bk7231n-qfn32-tuya
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: #####
ota:
password: #####
captive_portal:
wifi:
networks:
- ssid: !secret #####
password: !secret #####
- ssid: !secret #####
password: !secret #####
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ###############
password: ##################
script:
- id: inching_script
then:
- delay: 180s
- switch.turn_off: relay_1
switch:
- platform: gpio
name: "Garage Lights"
pin: GPIO15
id: relay_1
on_turn_on:
- output.turn_on: led_1
- script.execute: inching_script
on_turn_off:
- output.turn_off: led_1
- script.stop: inching_script
output:
- platform: gpio
pin: GPIO6
inverted: True
id: led_1
binary_sensor:
- platform: gpio
pin:
number: GPIO14
mode: INPUT_PULLUP
inverted: True
name: "Garage Light Switch"
on_state:
- switch.toggle: relay_1
- platform: gpio
pin:
number: GPIO8
mode: INPUT_PULLUP
inverted: True
name: "Pair/Toggle All Button"
on_press:
- switch.toggle: relay_1
sensor:
- platform: wifi_signal
name: "Garage Light WiFi Strength"
update_interval: 300s
- platform: uptime
name: Garage Light Uptime
Thanks