I recently bought a V-TAC Smart WiFi Light Switch (3 Gang) which is ESP8285 based. In fact it appears a close clone of a Sonoff T1 3G. It flashed easily and worked perfectly with Tasmota set a T1
It has the same functionality - 3 Touch buttons. Each controls a relay and has its own White LED to indicate “on”. Like the T1 it has a blue backlight LED that can be set “ON” when all 3 switches are “OFF”. I recreated this in ESP Home as below. Only the 3 switches are exposed to HA - logic for the backlight is kept internal.
For each Relay a template sensor is created that tracks the relay state. The Sensor on state change is then used to set the back light accordingly.
I’ve used a single substitution to ensure unique identities throughout the script. If I get a second I can simply copy the complete firmware, change the id used in the substitution once and the switches will have a unique entity in Home assistant. Any number of ways to accomplish similar I’m sure. Having ESP home opens up complete flexibility to treat the buttons with Click / Double Click / Long Hold etc differently. In this case I just wanted basic functionality and chose not to expose the buttons directly to HA - just the relays.
esphomeyaml:
name: esp_vt3g_01
platform: ESP8266
board: esp8285
wifi:
domain: .local
ssid: xxxxxx
password: xxxxxx
manual_ip:
static_ip: 192.168.1.54
gateway: 192.168.1.254
subnet: 255.255.255.0
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
substitutions:
# Unique switch ID
switch_id: "vt3g_01"
binary_sensor:
- platform: gpio
id: ${switch_id}_in_switch1
internal: true
pin: 0
name: "${switch_id} Touch Switch 1"
filters:
- invert:
on_click:
min_length: 50ms
max_length: 350ms
then:
- switch.toggle: ${switch_id}_out_relay1
- platform: gpio
id: ${switch_id}_in_switch2
internal: true
pin: 9
name: "${switch_id} Touch Switch 2"
filters:
- invert:
on_click:
min_length: 50ms
max_length: 350ms
then:
- switch.toggle: ${switch_id}_out_relay2
- platform: gpio
id: in_switch3
internal: true
pin: 10
name: "${switch_id} Touch Switch 3"
filters:
- invert:
on_click:
min_length: 50ms
max_length: 350ms
then:
- switch.toggle: ${switch_id}_out_relay3
- platform: template
name: "${switch_id} Template 1"
id: ${switch_id}_template1
internal: true
lambda: |-
if (id(${switch_id}_out_relay1).state) {
return true;
} else {
return false;
}
on_state:
- if:
condition:
or:
- binary_sensor.is_on: ${switch_id}_template1
- binary_sensor.is_on: ${switch_id}_template2
- binary_sensor.is_on: ${switch_id}_template3
then:
- switch.turn_off: ${switch_id}_out_led
- if:
condition:
and:
- binary_sensor.is_off: ${switch_id}_template1
- binary_sensor.is_off: ${switch_id}_template2
- binary_sensor.is_off: ${switch_id}_template3
then:
- switch.turn_on: ${switch_id}_out_led
- platform: template
name: "${switch_id} Template 2"
id: ${switch_id}_template2
internal: true
lambda: |-
if (id(${switch_id}_out_relay2).state) {
return true;
} else {
return false;
}
on_state:
- if:
condition:
or:
- binary_sensor.is_on: ${switch_id}_template1
- binary_sensor.is_on: ${switch_id}_template2
- binary_sensor.is_on: ${switch_id}_template3
then:
- switch.turn_off: ${switch_id}_out_led
- if:
condition:
and:
- binary_sensor.is_off: ${switch_id}_template1
- binary_sensor.is_off: ${switch_id}_template2
- binary_sensor.is_off: ${switch_id}_template3
then:
- switch.turn_on: ${switch_id}_out_led
- platform: template
name: "${switch_id} Template 3"
id: ${switch_id}_template3
internal: true
lambda: |-
if (id(${switch_id}_out_relay3).state) {
return true;
} else {
return false;
}
on_state:
- if:
condition:
or:
- binary_sensor.is_on: ${switch_id}_template1
- binary_sensor.is_on: ${switch_id}_template2
- binary_sensor.is_on: ${switch_id}_template3
then:
- switch.turn_off: ${switch_id}_out_led
- if:
condition:
and:
- binary_sensor.is_off: ${switch_id}_template1
- binary_sensor.is_off: ${switch_id}_template2
- binary_sensor.is_off: ${switch_id}_template3
then:
- switch.turn_on: ${switch_id}_out_led
switch:
- platform: gpio
pin: 12
id: ${switch_id}_out_relay1
name: "${switch_id} Touch Relay 1"
- platform: gpio
pin: 5
id: ${switch_id}_out_relay2
name: "${switch_id} Touch Relay 2"
- platform: gpio
pin: 4
id: ${switch_id}_out_relay3
name: "${switch_id} Touch Relay 3"
- platform: gpio
pin: 13
internal: true
id: ${switch_id}_out_led
inverted: yes
name: "${switch_id} Touch Status Led"