Files
esphome-configs/mcu-socket-03.yaml
T

160 lines
3.8 KiB
YAML

---
# Hardware: BlitzWolf BW-SHP2/SHP6
# Pinout:
# GPIO0 GPIO_LED1_INV Red LED (inverted), Power Status -> led_red (output gpio)
# GPIO1 GPIO_USER RXD, Optional sensor
# GPIO2 GPIO_LEDLNK_INV Blue LED (inverted), Link Status -> led_blue (output gpio)
# GPIO3 GPIO_USER TXD, Optional sensor
# GPIO5 GPIO_HJL_CF BL0937 or HJL-01 CF power -> sensor/hlw8012 (sensor hlw8012 cf_pin)
# GPIO12 GPIO_NRG_SEL_INV BL0937 or HJL-01 Sel output (0 = Voltage) -> sensor/hlw8012 (sensor hlw8012 sel_pin) (inverted)
# GPIO13 GPIO_KEY1 Button -> Button (binary_sensor gpio) (inverted)
# GPIO14 GPIO_NRG_CF1 BL0937 or HJL-01 CF1 current / voltage -> sensor/hlw8012 (sensor hlw8012 cf1_pin)
# GPIO15 GPIO_REL1 Relay -> Relay (switch gpio)
substitutions:
device: socket-03
name: Socket 03
area: Bedroom
comment: SPARE Socket
max_power: "3450"
# <2020
current_res: "0.00290"
voltage_div: "940"
cf1_pin: GPIO14
# >2020
# current_res: "0.00117"
# voltage_div: "755"
# cf1_pin: GPIO04
esphome:
name: mcu-${device}
friendly_name: ${name}
area: ${area}
comment: ${comment}
esp8266:
board: esp01_1m
toolchain: arduino
packages:
common: !include common/common_esp8266.yaml
binary_sensor:
- platform: gpio
pin:
number: GPIO13
mode: INPUT_PULLUP
inverted: yes
name: Button
# filters:
# invert:
on_press:
# min_length: 50ms
# max_length: 350ms
then:
- switch.toggle: relay
on_double_click:
# min_length: 50ms
# max_length: 350ms
then:
- switch.turn_on: relay
- light.turn_on: light_blue
- delay: 10s
- switch.turn_off: relay
- light.turn_off: light_blue
output:
- platform: gpio
pin: GPIO00
id: led_red
inverted: True
- platform: gpio
pin: GPIO02
id: led_blue
inverted: True
light:
- platform: binary
name: Red LED
id: light_red
output: led_red
- platform: binary
name: Blue LED
id: light_blue
output: led_blue
sensor:
- platform: hlw8012
sel_pin:
number: GPIO12
inverted: true
cf_pin: GPIO05
cf1_pin: ${cf1_pin}
current_resistor: ${current_res}
voltage_divider: ${voltage_div}
current:
name: Current
icon: mdi:flash-circle
accuracy_decimals: 3
voltage:
name: Voltage
icon: mdi:current-ac
power:
name: Power
id: power
icon: mdi:flash-outline
on_value_range:
- above: ${max_power}
then:
- light.turn_off: light_red
- switch.turn_off: relay
- homeassistant.action:
action: persistent_notification.create
data:
title: Message from ${name}
data_template:
message: Switch turned off because power exceeded ${max_power} W
energy:
name: Energy
unit_of_measurement: "Wh"
icon: mdi:flash-outline
update_interval: 30s
change_mode_every: 4
- platform: total_daily_energy
name: Total Daily Power
power_id: power
accuracy_decimals: 5
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
icon: mdi:circle-slice-3
switch:
- platform: gpio
name: Relay
# icon: mdi:power-socket-eu
pin: GPIO15
id: relay
on_turn_on:
- light.turn_on: light_red
on_turn_off:
- light.turn_off: light_red
# status_led:
# pin:
# number: GPIO00
# inverted: True
# time:
# - platform: homeassistant
# timezone: Europe/Bratislava
# on_time:
# # Switch on on the hour
# - seconds: 0
# minutes: /15
# hours: "*"
# then:
# - switch.turn_on: relay_1
# - delay: 12min
# - switch.turn_off: relay_1