Guest User

Untitled

a guest
Feb 27th, 2022
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.12 KB | None | 0 0
  1. blueprint:
  2. name: Advanced medication reminder
  3. description: Get advanced notification and history for medication reminder
  4. domain: automation
  5. input:
  6. reminder_time:
  7. name: Reminder time
  8. description: At what time do you want to be reminded
  9. selector:
  10. time: {}
  11. notify_device:
  12. name: Notification
  13. description: Device needs to run the official Home Assistant app to receive
  14. notifications
  15. selector:
  16. device:
  17. integration: mobile_app
  18. input_boolean:
  19. name: Dedicated input_boolean
  20. description: Create and set here a input_boolean to handle history and state
  21. of the automation
  22. selector:
  23. entity:
  24. domain: input_boolean
  25. notification_title:
  26. name: Notification title (Optional)
  27. description: 'Default: Medication reminder'
  28. default: Medication reminder!
  29. notification_message:
  30. name: Notification message (Optional)
  31. description: 'Default: It''s time to take your medication'
  32. default: It's time to take your medication
  33. notification_action_taken:
  34. name: 'Notification action: Taken (Optional)'
  35. description: 'Default: Taken'
  36. default: Taken
  37. notification_action_later:
  38. name: 'Notification action: Ask later (Optional)'
  39. description: 'Default: Ask later'
  40. default: Ask later
  41. notification_action_skip:
  42. name: 'Notification action: Skip (Optional)'
  43. description: 'Default: Skip'
  44. default: Skip
  45. ask_later_wait_time:
  46. name: Wait time before next reminder
  47. description: Minutes before notify again after a Ask later action.
  48. default: 30
  49. selector:
  50. number:
  51. min: 5.0
  52. max: 1440.0
  53. unit_of_measurement: minutes
  54. mode: slider
  55. step: 1.0
  56. logbook_message_remind:
  57. name: Logbook message for remind (Optional)
  58. description: 'Default: Reminder sent'
  59. default: Reminder sent
  60. logbook_message_taken:
  61. name: Logbook message for action Taken (Optional)
  62. description: 'Default: Medication taken'
  63. default: Medication taken
  64. logbook_message_later:
  65. name: Logbook message for action Ask later (Optional)
  66. description: 'Default: Postpone reminder'
  67. default: Postpone reminder
  68. logbook_message_skip:
  69. name: Logbook message for action Skip (Optional)
  70. description: 'Default: Reminder skipped'
  71. default: Reminder skipped
  72. logbook_message_no_answer:
  73. name: Logbook message for no action after timeout (Optional)
  74. description: 'Default: No answer time out'
  75. default: No answer time out
  76. optional_action:
  77. name: Optional action
  78. description: Run an action like notify a speaker at the same time that the mobile
  79. notification
  80. selector:
  81. action: {}
  82. default: []
  83. source_url: https://raw.githubusercontent.com/Aohzan/hass-blueprints/main/blueprints/medication_reminder.yaml
  84. trigger:
  85. - platform: time
  86. at: !input 'reminder_time'
  87. mode: restart
  88. action:
  89. - service: input_boolean.turn_off
  90. target:
  91. entity_id: !input 'input_boolean'
  92. - alias: Notify until the medication has been take
  93. repeat:
  94. while:
  95. - condition: state
  96. entity_id: !input 'input_boolean'
  97. state: 'off'
  98. sequence:
  99. - service: logbook.log
  100. data:
  101. name: !input 'notification_title'
  102. message: !input 'logbook_message_remind'
  103. entity_id: !input 'input_boolean'
  104. - choose:
  105. - conditions: '{{ true }}'
  106. sequence: !input 'optional_action'
  107. - device_id: !input 'notify_device'
  108. domain: mobile_app
  109. type: notify
  110. title: !input 'notification_title'
  111. message: !input 'notification_message'
  112. data:
  113. actions:
  114. - title: !input 'notification_action_taken'
  115. action: taken
  116. - title: !input 'notification_action_later'
  117. action: later
  118. - title: !input 'notification_action_skip'
  119. action: skip
  120. tag: !input 'input_boolean'
  121. - wait_for_trigger:
  122. - platform: event
  123. event_type: mobile_app_notification_action
  124. event_data:
  125. tag: !input 'input_boolean'
  126. - platform: event
  127. event_type: mobile_app_notification_action
  128. event_data:
  129. action: taken
  130. - platform: event
  131. event_type: mobile_app_notification_action
  132. event_data:
  133. action: later
  134. - platform: event
  135. event_type: mobile_app_notification_action
  136. event_data:
  137. action: skip
  138. timeout:
  139. minutes: !input 'ask_later_wait_time'
  140. - choose:
  141. - conditions: '{{ wait.trigger.event.data.action == "taken" }}'
  142. sequence:
  143. - service: input_boolean.turn_on
  144. target:
  145. entity_id: !input 'input_boolean'
  146. - service: logbook.log
  147. data:
  148. name: !input 'notification_title'
  149. message: !input 'logbook_message_taken'
  150. entity_id: !input 'input_boolean'
  151. - conditions: '{{ wait.trigger.event.data.action == "later" }}'
  152. sequence:
  153. - service: logbook.log
  154. data:
  155. name: !input 'notification_title'
  156. message: !input 'logbook_message_later'
  157. entity_id: !input 'input_boolean'
  158. - delay:
  159. minutes: !input 'ask_later_wait_time'
  160. - conditions: '{{ wait.trigger.event.data.action == "skip" }}'
  161. sequence:
  162. - service: input_boolean.turn_on
  163. target:
  164. entity_id: !input 'input_boolean'
  165. - service: logbook.log
  166. data:
  167. name: !input 'notification_title'
  168. message: !input 'logbook_message_skip'
  169. entity_id: !input 'input_boolean'
  170. default:
  171. - device_id: !input 'notify_device'
  172. domain: mobile_app
  173. type: notify
  174. message: clear_notification
  175. data:
  176. tag: !input 'input_boolean'
  177. - service: logbook.log
  178. data:
  179. name: !input 'notification_title'
  180. message: !input 'logbook_message_no_answer'
  181. entity_id: !input 'input_boolean'
  182.  
Advertisement
Add Comment
Please, Sign In to add comment