现在用 time pattern 触发,配合input_boolean,凑活实现了主贴中的功能。
有没有更合适,简洁的方法?
configration:
input_boolean:
trigger_washroom_motion_close_allow:
name: washroom close allow
icon: mdi:kettle
automation:
# 更改trigger_washroom_motion_close_allow状态
- alias: change_trigger_washroom_motion_close_allow
initial_state: true
trigger:
- platform: state
entity_id: binary_sensor.0x00158d000542c12b_occupancy
to: 'on'
- platform: state
entity_id: binary_sensor.0x00158d000542c12b_occupancy
to: 'off'
action:
- service_template: "homeassistant.turn_{% if trigger.to_state.state == 'off' %}on{% else %}off{% endif %}"
entity_id: input_boolean.trigger_washroom_motion_close_allow
- alias: Respond_washroom_door_open_timeout_2_light_fan_off
initial_state: true
trigger:
- platform: time_pattern
minutes: "/2"
condition:
condition: and
conditions:
- condition: state
entity_id: input_boolean.trigger_washroom_motion
state: 'on'
- condition: state
entity_id: switch.hassmart_0f494e_1
state: 'on'
- condition: state
entity_id: binary_sensor.0x00158d0003983d98_contact
state: 'on'
action:
- service: switch.turn_off
entity_id: switch.hassmart_0f494e_1
- service: switch.turn_off
entity_id: switch.hassmart_0f494e_2
|