本帖最后由 neroxps 于 2020-10-30 17:16 编辑
需求保证所有开关在7:30-23:30之间开,其余时间是关闭的模块由于偶尔有时候自己会重启,导致大半夜的开关打开了,此处想加个模块启动比对时间决定开关的状态
以下附上代码
对于lambda实在无能为力,求助求助
esphome:
name: test
platform: esp8266
board: d1_mini
esp8266_restore_from_flash: true
on_boot:
priority: -10
then:
if:
condition:
lambda: |-
//此处需要判断系统时间是否在7:30至23:30之间,求大神帮忙
then:
- switch.turn_on: switch86
- switch.turn_on: switch55
- switch.turn_on: switchbeiyong
else:
- switch.turn_off: switch86
- switch.turn_off: switch55
- switch.turn_off: switchbeiyong
wifi:
ssid: "ZZCJ-Power"
password: "我是密码"
reboot_timeout: 60s
manual_ip:
static_ip: 10.16.9.10
gateway: 10.16.8.5
subnet: 255.255.252.0
dns1: 222.246.129.80
dns2: 114.114.114.114
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "我是密码"
reboot_timeout: 0s
ota:
safe_mode: True
password: "我是密码"
time:
- platform: homeassistant
id: homeassistant_time
timezone: Asia/Shanghai
on_time:
- seconds: 0
minutes: 0
hours: 7
then:
- switch.turn_on: switch86
- seconds: 0
minutes: 30
hours: 23
then:
- switch.turn_off: switch86
web_server:
port: 80
auth:
username: admin
password: 我是密码
output:
- platform: gpio
pin: 14
id: 'testswitch86'
- platform: gpio
pin: 13
id: 'testswitch55'
- platform: gpio
pin: 15
id: 'testswitchbeiyong'
switch:
- platform: output
name: "test switch86"
output: 'testswitch86'
id: switch86
inverted: true
- platform: output
name: "test switch55"
output: 'testswitch55'
id: switch55
inverted: true
- platform: output
name: "test switchbeiyong"
output: 'testswitchbeiyong'
id: switchbeiyong
inverted: true
- platform: restart
name: "test Restart"
- platform: gpio
pin: 14
id: gpio14
restore_mode: ALWAYS_ON
- platform: gpio
pin: 13
id: gpio13
restore_mode: ALWAYS_ON
- platform: gpio
pin: 15
id: gpio15
restore_mode: ALWAYS_ON
sensor:
- platform: wifi_signal
name: "test Signal"
update_interval: 5s
- platform: uptime
id: sensoruptime
name: test Uptime Sensor
update_interval: 5s
|