103 lines
1.9 KiB
YAML
103 lines
1.9 KiB
YAML
esphome:
|
|
name: smart_plug_4
|
|
platform: ESP8266
|
|
board: esp01_1m
|
|
|
|
substitutions:
|
|
device_name: 'Smart_Plug_4'
|
|
friendly_name: 'Smart_plug_4'
|
|
|
|
wifi:
|
|
networks:
|
|
- ssid: !secret "wifi_ssid"
|
|
password: !secret "wifi_pass"
|
|
- ssid: "Jen B"
|
|
password: "shae1234"
|
|
|
|
ap:
|
|
ssid: "smart_plug_4_fallback"
|
|
password: "Fallback@!"
|
|
|
|
captive_portal:
|
|
|
|
# Enable logging
|
|
logger:
|
|
|
|
# Enable Home Assistant API
|
|
api:
|
|
reboot_timeout: 0s
|
|
|
|
|
|
|
|
ota:
|
|
|
|
web_server:
|
|
port: 80
|
|
|
|
|
|
binary_sensor:
|
|
- platform: gpio
|
|
pin:
|
|
number: GPIO3
|
|
mode: INPUT_PULLUP
|
|
inverted: True
|
|
name: "smart_plug_4"
|
|
on_press:
|
|
- switch.toggle: relay
|
|
|
|
switch:
|
|
- platform: gpio
|
|
name: "smart_plug_4_relay"
|
|
pin: GPIO14
|
|
id: relay
|
|
restore_mode: ALWAYS_ON
|
|
|
|
status_led:
|
|
pin:
|
|
number: GPIO1
|
|
inverted: yes
|
|
|
|
sensor:
|
|
- platform: wifi_signal
|
|
name: "smart_plug_4 WiFi signal"
|
|
update_interval: 60s
|
|
|
|
- platform: uptime
|
|
name: "Smart_plug_4_uptime"
|
|
|
|
|
|
# Power measuring sensor
|
|
- platform: hlw8012
|
|
sel_pin:
|
|
number: GPIO12
|
|
inverted: True
|
|
cf_pin: GPIO4
|
|
cf1_pin: GPIO5
|
|
current:
|
|
name: ${friendly_name} Current
|
|
power:
|
|
name: ${friendly_name} Power
|
|
id: power
|
|
filters:
|
|
# Some calibration
|
|
- multiply: 0.4545
|
|
voltage:
|
|
name: ${friendly_name} Voltage
|
|
current_resistor: 0.001 # default 0.001
|
|
voltage_divider: 910 # default 2351
|
|
change_mode_every: 3 # default 8
|
|
update_interval: 3s # default 60s
|
|
|
|
# Sum power readings over the day
|
|
- platform: total_daily_energy
|
|
name: ${friendly_name} Total Daily Energy
|
|
power_id: power
|
|
filters:
|
|
- multiply: 0.001 # convert Wh to kWh
|
|
unit_of_measurement: kWh
|
|
|
|
# Enable getting local time for total daily energy calculation
|
|
time:
|
|
- platform: homeassistant
|
|
id: homeassistant_time
|
|
timezone: America/Toronto |