|
|
|
@ -14,6 +14,10 @@ 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" |
|
|
|
@ -34,15 +38,6 @@ binary_sensor: |
|
|
|
|
- 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 |
|
|
|
@ -53,15 +48,6 @@ binary_sensor: |
|
|
|
|
- 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 |
|
|
|
@ -70,15 +56,14 @@ binary_sensor: |
|
|
|
|
- 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 |
|
|
|
|
# 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 |
|
|
|
@ -86,18 +71,26 @@ binary_sensor: |
|
|
|
|
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: |
|
|
|
|
# Register the blue LED as a dimmable 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" |
|
|
|
@ -115,9 +108,3 @@ text_sensor: |
|
|
|
|
- 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 |
|
|
|
|