68 lines
3.4 KiB
YAML
68 lines
3.4 KiB
YAML
blueprint:
|
|
name: NestQuest afternoon reminder
|
|
description: 'Sends an afternoon nudge listing ONLY the children who still have
|
|
open quests today. Children who are present and all clear are omitted (the nudge
|
|
is for stragglers, not a roll call), children who are not present today are omitted
|
|
entirely, and the household rollup sensors are excluded by the same present guard.
|
|
When every present child is already done the automation sends NOTHING at all:
|
|
a template condition stops the run before the notification. The notify service
|
|
is chosen by the household when importing this blueprint — NestQuest never hard-codes
|
|
a personal notify target.'
|
|
domain: automation
|
|
input:
|
|
afternoon_time:
|
|
name: Afternoon time
|
|
description: Local time of day the reminder is sent.
|
|
default: '15:00'
|
|
selector:
|
|
time: {}
|
|
notify_target:
|
|
name: Notify service
|
|
description: The Home Assistant notify service to call for the reminder, for
|
|
example notify.mobile_app_your_phone — a placeholder; pick the notify service
|
|
for your own device.
|
|
selector:
|
|
text:
|
|
multiline: false
|
|
multiple: false
|
|
send_reminder:
|
|
name: Send the reminder
|
|
description: Turn off to keep the automation installed but skip the notification
|
|
entirely.
|
|
default: true
|
|
selector:
|
|
boolean: {}
|
|
source_url: https://github.com/Maniacs-Mansion/NestQuest/blob/main/custom_components/nestquest/blueprints/automation/afternoon_reminder.yaml
|
|
mode: single
|
|
variables:
|
|
send_reminder: !input send_reminder
|
|
triggers:
|
|
- trigger: time
|
|
at: !input afternoon_time
|
|
conditions:
|
|
- condition: template
|
|
value_template: '{{ send_reminder | bool }}'
|
|
- condition: template
|
|
value_template: "{%- set ns = namespace(any_open=false) -%}\n{%- for due in states.sensor\n
|
|
\ | selectattr('entity_id', 'search', '^sensor\\\\.nestquest_.*_quests_due_today(_\\\\d+)?$')
|
|
-%}\n {%- if due.attributes.get('present') -%}\n {%- set remaining_values
|
|
= states.sensor\n | selectattr('entity_id', 'search', '^sensor\\\\.nestquest_.*_quests_remaining_today(_\\\\d+)?$')\n
|
|
\ | selectattr('attributes.child_id', 'eq', due.attributes.child_id)\n
|
|
\ | map(attribute='state')\n | list -%}\n {%- if remaining_values
|
|
and (remaining_values | first | int) > 0 -%}\n {%- set ns.any_open = true
|
|
-%}\n {%- endif -%}\n {%- endif -%}\n{%- endfor -%}\n{{- ns.any_open -}}\n"
|
|
actions:
|
|
- action: !input notify_target
|
|
data:
|
|
title: NestQuest afternoon reminder
|
|
message: "{%- set ns = namespace(lines=[]) -%}\n{%- for due in states.sensor\n
|
|
\ | selectattr('entity_id', 'search', '^sensor\\\\.nestquest_.*_quests_due_today(_\\\\d+)?$')
|
|
-%}\n {%- if due.attributes.get('present') -%}\n {%- set remaining_values
|
|
= states.sensor\n | selectattr('entity_id', 'search', '^sensor\\\\.nestquest_.*_quests_remaining_today(_\\\\d+)?$')\n
|
|
\ | selectattr('attributes.child_id', 'eq', due.attributes.child_id)\n
|
|
\ | map(attribute='state')\n | list -%}\n {%- if remaining_values
|
|
and (remaining_values | first | int) > 0 -%}\n {%- set line = due.attributes.child_name
|
|
~ ' still has ' ~ (remaining_values | first | int) ~ ' quest(s) open.' -%}\n
|
|
\ {%- set ns.lines = ns.lines + [line] -%}\n {%- endif -%}\n {%- endif
|
|
-%}\n{%- endfor -%}\n{{- ns.lines | join('\\n') -}}"
|