photo64

Final Check Doors Yaml

Jul 22nd, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. alias: Check Doors Are Locked
  2. description: ""
  3. triggers:
  4. - trigger: state
  5. entity_id:
  6. - input_button.test_button
  7. conditions: []
  8. actions:
  9. - variables:
  10. unlocked_doors: >
  11. {% set unlocked = namespace(lst=[]) %} {% set excluded_entities =
  12. ['lock.ratgdo32_garage_door_1_lock_remotes',
  13. 'lock.ratgdo_garage_door_2_lock_remotes'] %} {% for lock_entity in
  14. states.lock | rejectattr('entity_id', 'in', excluded_entities) %}
  15. {% if state_attr(lock_entity.entity_id, 'lock_state') == 'unlocked' or states(lock_entity.entity_id) == 'unlocked' %}
  16. {% set unlocked.lst = unlocked.lst + [state_attr(lock_entity.entity_id, 'friendly_name') | default(lock_entity.entity_id.split('.')[1] | replace('_', ' ') | title)] %}
  17. {% endif %}
  18. {% endfor %}
  19.  
  20. {{ unlocked.lst }}
  21.  
  22. - choose:
  23. - conditions:
  24. - condition: template
  25. value_template: "{{ unlocked_doors | length > 0 }}"
  26. sequence:
  27. - action: assist_satellite.ask_question
  28. metadata: {}
  29. data:
  30. question: |
  31. {% if unlocked_doors | length == 1 %}
  32. It looks like the {{ unlocked_doors[0] }} is unlocked. Would you like me to lock it?
  33. {% else %}
  34. It looks like these doors are unlocked: {{ unlocked_doors | join(', ') }}. Would you like me to lock them?
  35. {% endif %}
  36. preannounce: true
  37. entity_id: assist_satellite.seeed_respeaker_satellite2_assist_satellite
  38. answers:
  39. - id: yes_lock
  40. sentences:
  41. - "yes"
  42. - please lock them
  43. - lock them
  44. - yeah
  45. - affirmative
  46. - id: no_dont_lock
  47. sentences:
  48. - "no"
  49. - don't lock them
  50. - leave them
  51. - negative
  52. response_variable: door_lock_response
  53. continue_on_error: true
  54. - choose:
  55. - conditions:
  56. - condition: template
  57. value_template: "{{ door_lock_response.id == 'yes_lock' }}"
  58. sequence:
  59. - action: lock.lock
  60. metadata: {}
  61. data: {}
  62. target:
  63. entity_id: >
  64. {% set lock_entities = namespace(lst=[]) %} {% for
  65. door_name in unlocked_doors %}
  66. {% for lock_entity in states.lock %}
  67. {% if state_attr(lock_entity.entity_id, 'friendly_name') == door_name or lock_entity.entity_id.split('.')[1] | replace('_', ' ') | title == door_name %}
  68. {% set lock_entities.lst = lock_entities.lst + [lock_entity.entity_id] %}
  69. {% endif %}
  70. {% endfor %}
  71. {% endfor %} {{ lock_entities.lst }}
  72. - action: assist_satellite.announce
  73. metadata: {}
  74. data:
  75. message: "\"Okay, I'm locking the doors.\""
  76. preannounce: true
  77. target:
  78. entity_id: >-
  79. assist_satellite.seeed_respeaker_satellite2_assist_satellite
  80. - conditions:
  81. - condition: template
  82. value_template: "{{ door_lock_response.id == 'no_dont_lock' }}"
  83. sequence:
  84. - action: assist_satellite.announce
  85. metadata: {}
  86. data:
  87. message: Understood. I will not lock them.
  88. preannounce: true
  89. target:
  90. entity_id: >-
  91. assist_satellite.seeed_respeaker_satellite2_assist_satellite
  92. - conditions:
  93. - condition: template
  94. value_template: "{{ door_lock_response.id is none }}"
  95. sequence:
  96. - action: assist_satellite.announce
  97. metadata: {}
  98. data:
  99. message: I didn't catch that. Please check your doors.
  100. preannounce: true
  101. target:
  102. entity_id: >-
  103. assist_satellite.seeed_respeaker_satellite2_assist_satellite
  104. default:
  105. - action: assist_satellite.announce
  106. metadata: {}
  107. data:
  108. message: All doors are currently locked
  109. preannounce: true
  110. target:
  111. entity_id: assist_satellite.seeed_respeaker_satellite2_assist_satellite
  112. mode: single
Advertisement
Add Comment
Please, Sign In to add comment