The config files for my esphome devices
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.2 KiB

#SONOFF T1 EU/UK (1 button)
#https://www.banggood.com/SONOFF-T1-EU-or-UK-AC-100-240V-1-or-2-or-3-Gang-TX-Series-WIFI-Wall-Switch-433Mhz-RF-Remote-Controlled-Wifi-Switch-Smart-Home-Switch-Works-With-Alexa-Google-Home-p-1470883.html?rmmds=myorder&cur_warehouse=UK&ID=6278514
esphome:
name: bedroom_switch
platform: ESP8266
board: esp01_1m
wifi:
ssid: !secret wifi-ssid
password: !secret wifi-password
logger:
api:
ota:
# This is the button on the switch
# It is no longer published to home assistant, it is instead used by esphome to
# update the state of a "virtual" sensor. This is how I distinguish
# between a single, double and hold push
binary_sensor:
- platform: gpio
name: "Bedroom Sensor"
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
filters:
- delayed_on: 30ms
- delayed_off: 30ms
internal: True
on_multi_click:
# Single
- timing:
- ON for at most 1s
- OFF for at least 0.5s
then:
- text_sensor.template.publish:
id: bedroom_button
state: !lambda 'return "single";'
# Double
- timing:
- ON for at most 1s
- OFF for at most 1s
- ON for at most 1s
- OFF for at least 0.2s
then:
- text_sensor.template.publish:
id: bedroom_button
state: !lambda 'return "double";'
# Hold
- timing:
- ON for 1s to 3s
- OFF for at least 0.5s
then:
- text_sensor.template.publish:
id: bedroom_button
state: !lambda 'return "hold";'
# There is a bit of a delay between pushing the button on the switch and
# the light turning on. This is for 2 main reasons:
# * There is a bit of a delay for the switch to decide if a single or
# double press was wanted
# * The smart bulbs take a little while to turn on
# To give some instant feedback to the user, I re-purpose the wifi light.
# Whenever the touchpad is being pushed, the light is on.
# This makes it clear that the push has been registered.
on_press:
then:
- output.turn_on: blue_led
on_release:
then:
- output.turn_off: blue_led
# This switch gives electrisity to the bulb. We want it on all the time really
switch:
- platform: gpio
name: "Bedroom Relay"
pin: GPIO12
restore_mode: ALWAYS_ON
# This is the blue wifi led.
# It is used above to determine whether or not a push is registered
output:
- platform: esp8266_pwm
id: blue_led
pin: GPIO13
inverted: True
# This sensor is published to homeassistant with the value:
# * single
# * double
# * hold
# This can be used to trigger automations by type "state"
text_sensor:
- platform: template
name: "Bedroom Touchpad"
id: bedroom_button
icon: "mdi:toggle-switch"
on_value:
then:
- if:
condition:
text_sensor.state:
id: bedroom_button
state: ""
else:
- delay: 20ms
- text_sensor.template.publish:
id: bedroom_button
state: !lambda 'return "";'