79 lines
2.7 KiB
YAML
79 lines
2.7 KiB
YAML
blueprint:
|
|
name: NestQuest morning summary
|
|
description: >-
|
|
Sends a morning notification listing what each child still owes
|
|
today. Only children whose NestQuest presence sensor is on are
|
|
included; children who are not present today are omitted entirely.
|
|
The notify service is chosen by the household when importing this
|
|
blueprint — NestQuest never hard-codes a personal notify target.
|
|
domain: automation
|
|
input:
|
|
morning_time:
|
|
name: Morning time
|
|
description: Local time of day the summary is sent.
|
|
default: "08:00"
|
|
selector:
|
|
time: {}
|
|
notify_target:
|
|
name: Notify service
|
|
description: >-
|
|
The Home Assistant notify service to call for the summary,
|
|
for example notify.mobile_app_your_phone — a placeholder;
|
|
pick the notify service for your own device.
|
|
selector:
|
|
text: {}
|
|
send_summary:
|
|
name: Send the summary
|
|
description: >-
|
|
Turn off to keep the automation installed but skip the
|
|
notification entirely.
|
|
default: true
|
|
selector:
|
|
boolean: {}
|
|
|
|
mode: single
|
|
|
|
variables:
|
|
send_summary: !input send_summary
|
|
|
|
triggers:
|
|
- trigger: time
|
|
at: !input morning_time
|
|
|
|
conditions:
|
|
- condition: template
|
|
value_template: "{{ send_summary | bool }}"
|
|
|
|
actions:
|
|
- action: !input notify_target
|
|
data:
|
|
title: NestQuest morning summary
|
|
message: |
|
|
{%- set ns = namespace(lines=[]) -%}
|
|
{%- for due in states.sensor
|
|
| selectattr('entity_id', 'search', '^sensor\\.nestquest_.*_quests_due_today(_\\d+)?$') -%}
|
|
{%- if due.attributes.get('present') -%}
|
|
{%- set remaining_values = states.sensor
|
|
| selectattr('entity_id', 'search', '^sensor\\.nestquest_.*_quests_remaining_today(_\\d+)?$')
|
|
| selectattr('attributes.child_id', 'eq', due.attributes.child_id)
|
|
| map(attribute='state')
|
|
| list -%}
|
|
{%- if remaining_values -%}
|
|
{%- set remaining = remaining_values | first | int -%}
|
|
{%- if remaining > 0 -%}
|
|
{%- set line = due.attributes.child_name ~ ' owes ' ~ remaining ~ ' quest(s) today.' -%}
|
|
{%- else -%}
|
|
{%- set line = due.attributes.child_name ~ ' is all clear today (0 quests remaining).' -%}
|
|
{%- endif -%}
|
|
{%- else -%}
|
|
{%- set line = due.attributes.child_name ~ "'s quest count is unavailable today." -%}
|
|
{%- endif -%}
|
|
{%- set ns.lines = ns.lines + [line] -%}
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{%- if ns.lines -%}
|
|
{{- ns.lines | join('\n') -}}
|
|
{%- else -%}
|
|
No children present today.
|
|
{%- endif -%}
|