Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias: Check Doors Are Locked
- description: ""
- triggers:
- - trigger: state
- entity_id:
- - input_button.test_button
- conditions: []
- actions:
- - variables:
- unlocked_doors: |
- {% set unlocked = namespace(lst=[]) %}
- {% for lock_entity in states.lock %}
- {% if state_attr(lock_entity.entity_id, 'lock_state') == 'unlocked' or states(lock_entity.entity_id) == 'unlocked' %}
- {% set unlocked.lst = unlocked.lst + [state_attr(lock_entity.entity_id, 'friendly_name') | default(lock_entity.entity_id.split('.')[1] | replace('_', ' ') | title)] %}
- {% endif %}
- {% endfor %}
- {{ unlocked.lst }}
- - choose:
- - conditions:
- - condition: template
- value_template: "{{ unlocked_doors | length > 0 }}"
- sequence:
- - action: assist_satellite.ask_question
- metadata: {}
- data:
- question: |
- {% if unlocked_doors | length == 1 %}
- It looks like the {{ unlocked_doors[0] }} is unlocked. Would you like me to lock it?
- {% else %}
- It looks like these doors are unlocked: {{ unlocked_doors | join(', ') }}. Would you like me to lock them?
- {% endif %}
- preannounce: true
- entity_id: assist_satellite.seeed_respeaker_satellite2_assist_satellite
- answers:
- - id: yes_lock
- sentences:
- - "yes"
- - please lock them
- - lock them
- - yeah
- - affirmative
- - id: no_dont_lock
- sentences:
- - "no"
- - don't lock them
- - leave them
- - negative
- response_variable: door_lock_response
- continue_on_error: true
- - choose:
- - conditions:
- - condition: template
- value_template: "{{ door_lock_response.id == 'yes_lock' }}"
- sequence:
- - action: lock.lock
- metadata: {}
- data: {}
- target:
- entity_id: >
- {% set lock_entities = [] %} {% for door_name in
- unlocked_doors %}
- {% for entity_id in states.lock %}
- {% if state_attr(entity_id, 'friendly_name') == door_name or entity_id.split('.')[1] | replace('_', ' ') | title == door_name %}
- {% set lock_entities = lock_entities + [entity_id] %}
- {% endif %}
- {% endfor %}
- {% endfor %} {{ lock_entities }}
- - action: assist_satellite.announce
- metadata: {}
- data:
- message: "\"Okay, I'm locking the doors.\""
- preannounce: true
- target:
- entity_id: >-
- assist_satellite.seeed_respeaker_satellite2_assist_satellite
- - conditions:
- - condition: template
- value_template: "{{ door_lock_response.id == 'no_dont_lock' }}"
- sequence:
- - action: assist_satellite.announce
- metadata: {}
- data:
- message: Understood. I will not lock them.
- preannounce: true
- target:
- entity_id: >-
- assist_satellite.seeed_respeaker_satellite2_assist_satellite
- - conditions:
- - condition: template
- value_template: "{{ door_lock_response.id is none }}"
- sequence:
- - action: assist_satellite.announce
- metadata: {}
- data:
- message: I didn't catch that. Please check your doors.
- preannounce: true
- target:
- entity_id: >-
- assist_satellite.seeed_respeaker_satellite2_assist_satellite
- default:
- - action: assist_satellite.announce
- metadata: {}
- data:
- message: All doors are currently locked
- preannounce: true
- target:
- entity_id: assist_satellite.seeed_respeaker_satellite2_assist_satellite
- mode: single
Advertisement
Add Comment
Please, Sign In to add comment