Created
February 24, 2020 05:04
-
-
Save ekini/7a6e6e6578282d1761328ecc42153312 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
esphome: | |
name: switch_one | |
platform: ESP8266 | |
board: esp01_1m | |
# Enable logging | |
logger: | |
# Enable Home Assistant API | |
api: | |
reboot_timeout: 0s | |
ota: | |
status_led: | |
pin: | |
number: GPIO13 | |
inverted: yes | |
binary_sensor: | |
- platform: gpio | |
id: button | |
pin: | |
number: 0 | |
inverted: True | |
mode: INPUT_PULLUP | |
on_multi_click: | |
- timing: # double click | |
- ON for at most 1s | |
- OFF for at most 1s | |
- ON for at most 1s | |
- OFF for at least 0.2s | |
then: | |
- sensor.template.publish: | |
id: template_button | |
state: 2 | |
- timing: # long click | |
- ON for 1s to 2s | |
- OFF for at least 0.5s | |
then: | |
- sensor.template.publish: | |
id: template_button | |
state: 3 | |
- timing: # short click | |
- ON for at most 1s | |
- OFF for at least 0.5s | |
then: | |
- sensor.template.publish: | |
id: template_button | |
state: 1 | |
- switch.toggle: relay | |
switch: | |
- platform: gpio | |
id: relay | |
pin: 14 | |
name: "Switch One Relay" | |
sensor: | |
- platform: total_daily_energy | |
name: "Switch One Daily Energy" | |
power_id: power_sensor | |
- platform: hlw8012 | |
sel_pin: | |
number: 12 | |
inverted: True | |
cf_pin: 4 | |
cf1_pin: 5 | |
current: | |
name: "Switch One Current" | |
voltage: | |
name: "Switch One Voltage" | |
power: | |
name: "Switch One Power" | |
id: power_sensor | |
update_interval: 30s | |
voltage_divider: 2072 # Lower value gives lower voltage readout | |
current_resistor: 0.00087 # Higher value gives lower watt readout | |
- platform: template | |
name: "Switch One Button" | |
id: template_button | |
# Enable time component to reset energy at midnight | |
time: | |
- platform: homeassistant |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment