一时兴起给自己的帖子收个尾
通过脚本可实现操作:
1. automation调用开灯脚本timed_lamp
2. timed_lamp执行三个动作:关闭timer_off脚本、开启网关灯、打开timer_off脚本。
3. timer_off执行两个动作:delay 5秒、关闭网关灯
yaml内容如下
automation.yaml:
- action:
- alias: start
data: {}
service: script.1505808681270
alias: switch_test
condition: []
id: '1505358810232'
trigger:
- entity_id: binary_sensor.door_window_sensor_158d000120c834
from: 'on'
platform: state
to: 'off'
script.yaml:
'1505808124854':
alias: timer_off
sequence:
- delay: 00:00:05
- alias: Turn off lamp after 5 seconds
data:
entity_id: light.gateway_light_34ce008be2c2
service: light.turn_off
'1505808681270':
alias: timed_lamp
sequence:
- alias: turn off script
data:
entity_id: script.1505808124854
service: script.turn_off
- alias: Turn on lamp
data:
entity_id: light.gateway_light_34ce008be2c2
service: light.turn_on
- alias: set new timer
data:
entity_id: script.1505808124854
service: script.turn_on
页面配置生成脚本对应entity_id可通过页面states查看
|