|
|
@ -14,6 +14,10 @@ logger: |
|
|
|
api: |
|
|
|
api: |
|
|
|
ota: |
|
|
|
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: |
|
|
|
binary_sensor: |
|
|
|
- platform: gpio |
|
|
|
- platform: gpio |
|
|
|
name: "Bedroom Sensor" |
|
|
|
name: "Bedroom Sensor" |
|
|
@ -34,15 +38,6 @@ binary_sensor: |
|
|
|
- text_sensor.template.publish: |
|
|
|
- text_sensor.template.publish: |
|
|
|
id: bedroom_button |
|
|
|
id: bedroom_button |
|
|
|
state: !lambda 'return "single";' |
|
|
|
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 |
|
|
|
# Double |
|
|
|
- timing: |
|
|
|
- timing: |
|
|
|
- ON for at most 1s |
|
|
|
- ON for at most 1s |
|
|
@ -53,15 +48,6 @@ binary_sensor: |
|
|
|
- text_sensor.template.publish: |
|
|
|
- text_sensor.template.publish: |
|
|
|
id: bedroom_button |
|
|
|
id: bedroom_button |
|
|
|
state: !lambda 'return "double";' |
|
|
|
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 |
|
|
|
# Hold |
|
|
|
- timing: |
|
|
|
- timing: |
|
|
|
- ON for 1s to 3s |
|
|
|
- ON for 1s to 3s |
|
|
@ -70,15 +56,14 @@ binary_sensor: |
|
|
|
- text_sensor.template.publish: |
|
|
|
- text_sensor.template.publish: |
|
|
|
id: bedroom_button |
|
|
|
id: bedroom_button |
|
|
|
state: !lambda 'return "hold";' |
|
|
|
state: !lambda 'return "hold";' |
|
|
|
#- homeassistant.service: |
|
|
|
# There is a bit of a delay between pushing the button on the switch and |
|
|
|
# service: input_boolean.turn_on |
|
|
|
# the light turning on. This is for 2 main reasons: |
|
|
|
# data: |
|
|
|
# * There is a bit of a delay for the switch to decide if a single or |
|
|
|
# entity_id: input_boolean.bedroom_hold |
|
|
|
# double press was wanted |
|
|
|
#- delay: 0.2s |
|
|
|
# * The smart bulbs take a little while to turn on |
|
|
|
#- homeassistant.service: |
|
|
|
# To give some instant feedback to the user, I re-purpose the wifi light. |
|
|
|
# service: input_boolean.turn_off |
|
|
|
# Whenever the touchpad is being pushed, the light is on. |
|
|
|
# data: |
|
|
|
# This makes it clear that the push has been registered. |
|
|
|
# entity_id: input_boolean.bedroom_hold |
|
|
|
|
|
|
|
on_press: |
|
|
|
on_press: |
|
|
|
then: |
|
|
|
then: |
|
|
|
- output.turn_on: blue_led |
|
|
|
- output.turn_on: blue_led |
|
|
@ -86,18 +71,26 @@ binary_sensor: |
|
|
|
then: |
|
|
|
then: |
|
|
|
- output.turn_off: blue_led |
|
|
|
- output.turn_off: blue_led |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# This switch gives electrisity to the bulb. We want it on all the time really |
|
|
|
switch: |
|
|
|
switch: |
|
|
|
- platform: gpio |
|
|
|
- platform: gpio |
|
|
|
name: "Bedroom Relay" |
|
|
|
name: "Bedroom Relay" |
|
|
|
pin: GPIO12 |
|
|
|
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: |
|
|
|
output: |
|
|
|
# Register the blue LED as a dimmable output .... |
|
|
|
|
|
|
|
- platform: esp8266_pwm |
|
|
|
- platform: esp8266_pwm |
|
|
|
id: blue_led |
|
|
|
id: blue_led |
|
|
|
pin: GPIO13 |
|
|
|
pin: GPIO13 |
|
|
|
inverted: True |
|
|
|
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: |
|
|
|
text_sensor: |
|
|
|
- platform: template |
|
|
|
- platform: template |
|
|
|
name: "Bedroom Touchpad" |
|
|
|
name: "Bedroom Touchpad" |
|
|
@ -115,9 +108,3 @@ text_sensor: |
|
|
|
- text_sensor.template.publish: |
|
|
|
- text_sensor.template.publish: |
|
|
|
id: bedroom_button |
|
|
|
id: bedroom_button |
|
|
|
state: !lambda 'return "";' |
|
|
|
state: !lambda 'return "";' |
|
|
|
|
|
|
|
|
|
|
|
#light: |
|
|
|
|
|
|
|
# # ... and then make a light out of it. |
|
|
|
|
|
|
|
# - platform: monochromatic |
|
|
|
|
|
|
|
# name: "Bedroom switch light" |
|
|
|
|
|
|
|
# output: blue_led |
|
|
|
|
|
|
|