本帖最后由 showphi 于 2018-7-3 22:34 编辑
主要目的是为了实现通过触发2个人体感应先后顺序,判断是否开灯。人体感应1触发时间早于人体感应2并且在指定时间内就自动开关,写了以下自动化但是不起作用,求大神帮忙看看哪里有误!
- alias: auto_desklight_on
initial_state: true
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158d000171ba5d
from: 'off'
to: 'on'
- platform: state
entity_id: binary_sensor.motion_sensor_158d0001d6676a
from: 'off'
to: 'on'
condition:
condition: and
conditions:
- condition: state
entity_id: light.yeelight_rgb_34ce008b4b15
state: 'off'
- condition: template
value_template: '{{ ( as_timestamp(states.binary_sensor.motion_sensor_158d0001d6676a.last_changed) - as_timestamp(states.binary_sensor.motion_sensor_158d000171ba5d.last_changed)) | int > 0 }}'
- condition: time
after: '17:00:00'
before: '06:00:00'
action:
- service: switch.turn_on
entity_id: light.yeelight_rgb_34ce008b4b15
|