Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- automation:
- - id: check_door_status
- alias: check_door_status
- description: 定時檢查門
- trigger:
- - platform: time
- at: '10:00'
- - platform: time
- at: '12:00'
- - platform: time
- at: '15:00'
- action:
- - service: notify.line_notify
- data:
- message: >
- {% if states.sensor.door_open.state != '0' %}
- {{ state_attr("sensor.door_open","attribute") }}開著
- {%- else -%}
- 門都關好了!
- {%- endif %}
- template:
- - sensor:
- - name: "door_open"
- unique_id: door_open
- icon: mdi:door
- state: >
- {% set doors = [ 'binary_sensor.door_mainbath_contact',
- 'binary_sensor.door_toolbox_contact',
- 'binary_sensor.door_mainroom_contact',
- 'binary_sensor.door_kidsroom_contact',
- 'binary_sensor.door_guestroom_contact',
- 'binary_sensor.door_backyard_contact',
- 'binary_sensor.door_bathroom_contact',
- 'binary_sensor.door_window_sensor_158d000106e9b5',
- 'binary_sensor.door_window_sensor_158d0000f81711',
- ] %}
- {{ expand(doors) | selectattr('state','eq','on') | list | count }}
- attributes:
- attribute: >
- {% set doors = [ 'binary_sensor.door_mainbath_contact',
- 'binary_sensor.door_toolbox_contact',
- 'binary_sensor.door_mainroom_contact',
- 'binary_sensor.door_kidsroom_contact',
- 'binary_sensor.door_guestroom_contact',
- 'binary_sensor.door_backyard_contact',
- 'binary_sensor.door_bathroom_contact',
- 'binary_sensor.door_window_sensor_158d000106e9b5',
- 'binary_sensor.door_window_sensor_158d0000f81711',
- ] %}
- {{ expand(doors) | selectattr('state','eq','on') | map(attribute='name') | list | join('、') }}
Add Comment
Please, Sign In to add comment