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.
120 lines
3.1 KiB
120 lines
3.1 KiB
4 years ago
|
esphome:
|
||
|
name: bedroom_switch
|
||
|
platform: ESP8266
|
||
|
board: esp01_1m
|
||
|
|
||
|
wifi:
|
||
|
ssid: !secret wifi-ssid
|
||
|
password: !secret wifi-password
|
||
|
|
||
|
logger:
|
||
|
api:
|
||
|
ota:
|
||
|
|
||
|
binary_sensor:
|
||
|
- platform: gpio
|
||
|
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";'
|
||
|
#- homeassistant.service:
|
||
|
# service: input_boolean.turn_on
|
||
|
# data:
|
||
|
# entity_id: input_boolean.bedroom_single
|
||
|
#- delay: 0.2s
|
||
|
#- homeassistant.service:
|
||
|
# service: input_boolean.turn_off
|
||
|
# data:
|
||
|
# entity_id: input_boolean.bedroom_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";'
|
||
|
#- homeassistant.service:
|
||
|
# service: input_boolean.turn_on
|
||
|
# data:
|
||
|
# entity_id: input_boolean.bedroom_double
|
||
|
#- delay: 0.2s
|
||
|
#- homeassistant.service:
|
||
|
# service: input_boolean.turn_off
|
||
|
# data:
|
||
|
# entity_id: input_boolean.bedroom_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";'
|
||
|
#- homeassistant.service:
|
||
|
# service: input_boolean.turn_on
|
||
|
# data:
|
||
|
# entity_id: input_boolean.bedroom_hold
|
||
|
#- delay: 0.2s
|
||
|
#- homeassistant.service:
|
||
|
# service: input_boolean.turn_off
|
||
|
# data:
|
||
|
# entity_id: input_boolean.bedroom_hold
|
||
|
on_press:
|
||
|
then:
|
||
|
- output.turn_on: blue_led
|
||
|
on_release:
|
||
|
then:
|
||
|
- output.turn_off: blue_led
|
||
|
|
||
|
switch:
|
||
|
- platform: gpio
|
||
|
name: "Bedroom Relay"
|
||
|
pin: GPIO12
|
||
|
|
||
|
output:
|
||
|
# Register the blue LED as a dimmable output ....
|
||
|
- platform: esp8266_pwm
|
||
|
id: blue_led
|
||
|
pin: GPIO13
|
||
|
inverted: True
|
||
|
|
||
|
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 "";'
|
||
|
|
||
|
#light:
|
||
|
# # ... and then make a light out of it.
|
||
|
# - platform: monochromatic
|
||
|
# name: "Bedroom switch light"
|
||
|
# output: blue_led
|