本帖最后由 花蟋蟀 于 2018-11-30 17:37 编辑
【简单粗暴】
简单的自动开关灯:
- alias: auto_BedRoom_lamp
#initial_state: true #重启HA自动化是开启(true)还是关闭(false)
hide_entity: false #隐藏自动化
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_XXX #人体传感器
to: 'on'
- platform: state
entity_id: binary_sensor.motion_sensor_XXX #人体传感器
to: 'off'
for:
seconds: 30 #等待30秒
condition:
#条件:太阳下山
- condition: state
entity_id: sun.sun
state: "below_horizon"
action:
#通过IF判断感应器的状态
- service_template: "light.turn_{% if trigger.to_state.state == 'on' %}on{% else %}off{% endif %}"
entity_id: light.yeelight_bedside_XXX #灯
|