提供一个给你们看看吧,涉及到一个门磁,一个人体, 一个灯组(由两个小灯组 组成) ,一个主灯,外加光线传感器, 你们可以试试Node-red实现起来会不会容易还涉及到时间判断。
- alias: brinary_indoor
################自动化灯光#################
initial_state: true
trigger:
- platform: template
value_template: '{{ is_state("binary_sensor.door_window_sensor_158d0001e7497a", "off") and is_state("binary_sensor.motion_sensor_158d00022434bd", "on") and is_state("light.indoor_group", "off") and states.sensor.northlux.state | int <= 600 }}'
- platform: template
value_template: '{{ is_state("binary_sensor.door_window_sensor_158d0001e7497a", "on") and is_state("binary_sensor.motion_sensor_158d00022434bd", "off") and is_state("light.indoor_group", "off") and states.sensor.northlux.state | int <= 600 }}'
- platform: template
value_template: '{{ is_state("binary_sensor.door_window_sensor_158d0001e7497a", "off") and is_state("binary_sensor.motion_sensor_158d00022434bd", "off") and is_state("light.indoor_group", "on") }}'
action:
- delay: 0:{{ '0' if states.light.indoor_group.state == 'off' else '2' }}
- service_template: "light.turn_{{ 'on' if states.light.indoor_group.state == 'off' else 'off' }}"
data_template:
entity_id: >
{% if is_state("light.keting_light", "on") or is_state("light.keting_downlight", "on") %}
light.indoor,light.rgb_indoor
{% elif now().hour <= 19 and now().hour >= 12 %}
light.indoor,light.rgb_indoor
{% else %}
light.indoor_group
{% endif %}
|