本帖最后由 shay 于 2023-3-7 09:50 编辑
100包邮3个买的,结合坛子里唯一一篇提问贴,外加那个收费固件贴,终于搞定各引脚定义。直接上代码:
esphome:
name: power-strips
esp8266:
board: esp_wroom_02
#restore_from_flash: yes
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "b1b2336c502630a0a34820da43b6e6ea"
#web_server:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Power-Strips Fallback Hotspot"
password: !secret wifi_hotspot_passwd
captive_portal:
switch:
- platform: gpio
pin: 14
id: "relay"
inverted: true
- platform: gpio
pin: 0
id: "yellow"
inverted: true
- platform: gpio
pin: 2
id: "blue"
inverted: true
- platform: gpio
pin: 15
id: "light"
- platform: gpio
pin: 12
id: "gpio12"
- platform: template
name: "guomei"
id: "guomei"
optimistic: true
turn_on_action:
then:
- switch.turn_on: relay
- switch.turn_on: gpio12
- switch.turn_off: gpio12
- switch.turn_on: yellow
turn_off_action:
then:
- switch.turn_off: relay
- switch.turn_on: gpio12
- switch.turn_off: gpio12
- switch.turn_off: yellow
binary_sensor:
- platform: gpio
id: "button"
pin: 13
filters:
- invert:
- delayed_on: 50ms
- delayed_off: 50ms
on_click:
- min_length: 50ms
max_length: 500ms
then:
- switch.toggle: guomei
sensor:
- platform: hlw8012
model: BL0937
sel_pin:
number: 16
inverted: true
cf_pin: 4
cf1_pin: 5
voltage_divider: 1314
current:
name: "Current"
voltage:
name: "Voltage"
power:
name: "Power"
energy:
name: "Energy"
#update_interval: 30s
interval:
- interval: 1s
then:
if:
condition:
wifi.connected:
then:
- if:
condition:
api.connected:
then:
if:
condition:
- switch.is_off: blue
then:
- switch.turn_on: blue
else:
- switch.turn_on: blue
- delay: 500ms
- switch.turn_off: blue
- delay: 500ms
else:
- switch.turn_on: blue
- delay: 200ms
- switch.turn_off: blue
- delay: 200ms
另外赠送原版dump的固件一份,可直接烧录还原,赶紧小黄鱼收起来吧,除了插座不是单控的外,做工优秀,插口多,同样做工的普通插排也比这个价贵。还带电量检测。
问大神个问题,为啥继电器需要gpio12高电平触发下才行啊,好奇葩的设计,这是为啥呢?
ps:一直懒得完善,主要是语法不会。既然有坛友还在关注,花了点时间完善了下。目前的功能是未连接wifi快闪蓝灯,未连接ha慢闪蓝灯,连接ha蓝灯常亮;电源开亮黄灯(貌似是橙灯),电源关关闭黄灯。
|