Compare commits

...

3 Commits

Author SHA1 Message Date
f264412639 Desktop notifications for Tony's meds 2025-12-28 01:12:59 -05:00
6cddca76f7 time_diff macro 2025-12-28 01:12:42 -05:00
f57c41868e Facilitate PC notifications via HASS.Agent 2025-12-28 01:12:00 -05:00
4 changed files with 286 additions and 47 deletions

View File

@@ -5354,72 +5354,96 @@
- id: '1722378602352'
alias: Tony Meds Cleanup
description: Handles the setting/clearing of medication configs for Tony
trigger:
- platform: state
entity_id:
triggers:
- entity_id:
- input_boolean.tony_morning_meds_reminder
from: 'on'
to: 'off'
id: morning-reminders-off
alias: Morning reminders off
trigger: state
- alias: Afternoon reminders off
platform: state
entity_id:
- input_boolean.tony_afternoon_meds_reminder
from: 'on'
to: 'off'
id: afternoon-reminders-off
trigger: state
- alias: Night reminders off
platform: state
entity_id:
- input_boolean.tony_night_meds_reminder
from: 'on'
to: 'off'
id: night-reminders-off
- platform: event
event_type: ios.notification_action_fired
trigger: state
- event_type: ios.notification_action_fired
event_data:
actionName: TONY_MORNING_MEDS_TAKEN
id: morning-taken
alias: Morning taken
- alias: Afternoon taken
platform: event
alias: Morning taken iOS
trigger: event
- alias: Morning taken PC
event_type: hass_agent_notifications
event_data:
action: TONY_MORNING_MEDS_TAKEN
id: morning-taken
trigger: event
- alias: Afternoon taken iOS
event_type: ios.notification_action_fired
event_data:
actionName: TONY_AFTERNOON_MEDS_TAKEN
id: afternoon-taken
- alias: Night taken
platform: event
trigger: event
- alias: Afternoon taken PC
event_type: hass_agent_notifications
event_data:
action: TONY_AFTERNOON_MEDS_TAKEN
id: afternoon-taken
trigger: event
- alias: Night taken iOS
event_type: ios.notification_action_fired
event_data:
actionName: TONY_NIGHT_MEDS_TAKEN
id: night-taken
- alias: Morning skipped
platform: event
trigger: event
- alias: Morning skipped iOS
event_type: ios.notification_action_fired
event_data:
actionName: TONY_MORNING_MEDS_SKIPPED
id: morning-skipped
- alias: Afternoon skipped
platform: event
trigger: event
- alias: Morning skipped PC
event_type: hass_agent_notifications
event_data:
action: TONY_MORNING_MEDS_SKIPPED
id: morning-skipped
trigger: event
- alias: Afternoon skipped iOS
event_type: ios.notification_action_fired
event_data:
actionName: TONY_AFTERNOON_MEDS_SKIPPED
id: afternoon-skipped
- alias: Night skipped
platform: event
trigger: event
- alias: Afternoon skipped PC
event_type: hass_agent_notifications
event_data:
action: TONY_AFTERNOON_MEDS_SKIPPED
id: afternoon-skipped
trigger: event
- alias: Night skipped iOS
event_type: ios.notification_action_fired
event_data:
actionName: TONY_NIGHT_MEDS_SKIPPED
id: night-skipped
- platform: state
entity_id:
trigger: event
- entity_id:
- person.tony_stork
from: home
id: left
alias: Left
condition: []
action:
trigger: state
conditions: []
actions:
- alias: Routing
choose:
- conditions:
@@ -5428,19 +5452,19 @@
- morning-reminders-off
alias: Morning Reminders Off
sequence:
- service: counter.reset
metadata: {}
- metadata: {}
data: {}
target:
entity_id: counter.tony_morning_meds_reminder_count
alias: Reset morning reminder count
- service: script.text_notify
data:
action: counter.reset
- data:
type: alert
who: tony
message: clear_notification
tag: tony-morning-meds
alias: Clear morning notification
action: script.text_notify
- conditions:
- condition: trigger
id:
@@ -5448,18 +5472,18 @@
alias: Afternoon reminders off
sequence:
- alias: Reset afternoon reminder count
service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.tony_afternoon_meds_reminder_count
- service: script.text_notify
data:
action: counter.reset
- data:
type: alert
who: tony
message: clear_notification
tag: tony-afternoon-meds
alias: Clear afternoon notification
action: script.text_notify
- conditions:
- condition: trigger
id:
@@ -5467,90 +5491,90 @@
alias: Night reminders off
sequence:
- alias: Reset night reminder count
service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.tony_night_meds_reminder_count
- service: script.text_notify
data:
action: counter.reset
- data:
type: alert
who: tony
message: clear_notification
tag: tony-night-meds
alias: Clear night notification
action: script.text_notify
- conditions:
- condition: trigger
- alias: Morning taken
condition: trigger
id:
- morning-taken
alias: Morning taken
sequence:
- service: input_boolean.turn_on
metadata: {}
- metadata: {}
data: {}
target:
entity_id: input_boolean.tony_morning_meds_taken
alias: Turn on morning meds taken
action: input_boolean.turn_on
- conditions:
- condition: trigger
id:
- afternoon-taken
alias: Afternoon taken
sequence:
- service: input_boolean.turn_on
metadata: {}
- metadata: {}
data: {}
target:
entity_id: input_boolean.tony_afternoon_meds_taken
alias: Turn on afternoon meds taken
action: input_boolean.turn_on
- conditions:
- condition: trigger
id:
- night-taken
alias: Night taken
sequence:
- service: input_boolean.turn_on
metadata: {}
- metadata: {}
data: {}
target:
entity_id: input_boolean.tony_night_meds_taken
alias: Turn on night meds taken
action: input_boolean.turn_on
- conditions:
- condition: trigger
id:
- morning-skipped
alias: Morning skipped
sequence:
- service: input_boolean.turn_off
metadata: {}
- metadata: {}
data: {}
target:
entity_id: input_boolean.tony_morning_meds_reminder
alias: Deactivate morning reminders
action: input_boolean.turn_off
- conditions:
- condition: trigger
id:
- afternoon-skipped
alias: Afternoon skipped
sequence:
- service: input_boolean.turn_off
metadata: {}
- metadata: {}
data: {}
target:
entity_id: input_boolean.tony_afternoon_meds_reminder
alias: Deactivate afternoon reminders
action: input_boolean.turn_off
- conditions:
- condition: trigger
id:
- night-skipped
alias: Night skipped
sequence:
- service: input_boolean.turn_off
metadata: {}
- metadata: {}
data: {}
target:
entity_id: input_boolean.tony_night_meds_reminder
alias: Deactivate night reminders
action: input_boolean.turn_off
- conditions:
- condition: trigger
id:
@@ -5576,7 +5600,6 @@
alias: Night meds reminder active
then:
- alias: Send critical TTS notification
service: script.text_notify
metadata: {}
data:
type: critical
@@ -5584,6 +5607,7 @@
title: HEY DUMBASS
message: YOU FORGOT TO TAKE YOUR MEDS!!!!!
tag: tony-left-meds
action: script.text_notify
mode: queued
max: 10
- id: '1722386174249'

View File

@@ -109,4 +109,9 @@
{% macro next_twitch_stream() %}
{{ custom_time('calendar.tony_s_twitch_schedule','week,day,hour') }}
{% endmacro %}
{% macro time_diff(sensor) %}
{% set diff = (as_timestamp(now()) - as_timestamp(states(sensor))) | int %}
{{ diff }}
{% endmacro %}

View File

@@ -79,6 +79,9 @@ input_boolean:
tv_notifications:
name: TV Notifications
icon: mdi:message
pc_notifications:
name: PC Notifications
icon: mdi:desktop-classic
input_select:
select_phones:
@@ -103,6 +106,19 @@ input_select:
- All
initial: None
icon: mdi:television-play
select_pcs:
name: Select PCs
options:
- None
- Tony
- Tina
- Kallen
- Parents
- Nerds
- Not Tony
- All
initial: None
icon: mdi:desktop-classic
text_notification_priority_level:
name: Notification Priority Level
options:
@@ -352,6 +368,27 @@ notify:
services:
- service: alexa_media_living_room_echo_dot
- service: alexa_media_basement_echo_dot
- name: pc_parents
platform: group
services:
- service: notify.tony_asus
- service: notify.xia_desktop
- name: pc_nerds
platform: group
services:
- service: notify.tony_asus
- service: notify.kallen_desktop
- name: pc_all
platform: group
services:
- service: notify.tony_asus
- service: notify.xia_desktop
- service: notify.kallen_desktop
- name: pc_not_tony
platform: group
services:
- service: notify.xia_desktop
- service: notify.kallen_desktop
script:
volume_reset:
@@ -805,6 +842,131 @@ script:
message: '{{ message }}'
data: '{{ data|default("{}") }}'
pc_notify:
alias: 'PC Notify'
description: 'Use this to send popup text notifications to PCs in the house via HASS.Agent'
mode: queued
max: 20
fields:
who:
name: 'Who'
description: 'Which PC to send the notification to'
example: 'tony_pc, tina_pc, kallen_pc, all_pcs'
required: true
selector:
select:
options:
- tony
- tina
- kallen
- parents
- nerds
- not_tony
- all
title:
name: 'Title'
description: 'The title of the notification'
example: 'Greetings'
required: true
selector:
text:
message:
name: 'Message'
description: 'The body of the notification'
example: 'I am notifying you that this is a notification'
required: true
selector:
text:
multiline: true
actions:
name: 'Actions'
description: 'A list of actions for the notification'
required: false
selector:
object:
sequence:
- variables:
mod_who: >
{% set tony_notify = is_state('sensor.tony_asus_usernotification','AcceptsNotifications') %}
{% set tina_notify = is_state('sensor.xia_desktop_usernotification','AcceptsNotifications') %}
{% set kallen_notify = is_state('sensor.kallen_desktop_usernotification','AcceptsNotifications') %}
{% if who == 'tony' and not tony_notify %}
none
{% elif who == 'tina' and not tina_notify %}
none
{% elif who == 'kallen' and not kallen_notify %}
none
{% elif who == 'parents' %}
{% if tony_notify and not tina_notify %}
tony
{% elif not tony_notify and tina_notify %}
tina
{% elif not tony_notify and not tina_notify %}
none
{% else %}
parents
{% endif %}
{% elif who == 'nerds' %}
{% if tony_notify and not kallen_notify %}
tony
{% elif not tony_notify and kallen_notify %}
kallen
{% elif not tony_notify and not kallen_notify %}
none
{% else %}
nerds
{% endif %}
{% elif who == 'all' %}
{% if tony_notify %}
{% if tina_notify and not kallen_notify %}
parents
{% elif kallen_notify and not tina_notify %}
nerds
{% elif not tina_notify and not kallen_notify %}
tony
{% else %}
all
{% endif %}
{% elif tina_notify %}
{% if kallen_notify %}
not_tony
{% else %}
tina
{% endif %}
{% elif kallen_notify %}
kallen
{% else %}
none
{% endif %}
{% else %}
{{ who }}
{% endif %}
- if:
- condition: template
value_template: "{{ mod_who != 'none' and is_state('input_boolean.pc_notifications','on') }}"
then:
- service: >
{% if mod_who == 'tony' %}
notify.tony_asus
{% elif mod_who == 'tina' %}
notify.xia_desktop
{% elif mod_who == 'kallen' %}
notify.kallen_desktop
{% elif mod_who == 'parents' %}
notify.pc_parents
{% elif mod_who == 'nerds' %}
notify.pc_nerds
{% elif mod_who == 'not_tony' %}
notify.pc_not_tony
{% elif mod_who == 'all' %}
notify.pc_all
{% endif %}
data:
title: '{{ title }}'
message: '{{ message }}'
data:
actions: '{{ actions|default("{}") }}'
text_alert_image:
alias: 'Text Alert Image'
sequence:

View File

@@ -1785,6 +1785,18 @@ tony_morning_meds:
- action: TONY_MORNING_MEDS_SKIPPED
title: Skip
action: script.text_notify
- alias: Send PC notification
action: script.pc_notify
metadata: {}
data:
who: tony
title: Morning Meds
message: '{{ response.data.notification_text }}'
actions:
- action: TONY_MORNING_MEDS_TAKEN
title: Taken
- action: TONY_MORNING_MEDS_SKIPPED
title: Skip
- alias: Send TTS if reminders > 2 and Tony is home
if:
- alias: When reminders > 2 and Tony is home
@@ -1826,6 +1838,18 @@ tony_morning_meds:
title: Skip
message: You need to take your morning meds
action: script.text_notify
- alias: Send PC notification
action: script.pc_notify
metadata: {}
data:
who: tony
title: Morning Meds
message: You need to take your morning meds
actions:
- action: TONY_MORNING_MEDS_TAKEN
title: Taken
- action: TONY_MORNING_MEDS_SKIPPED
title: Skip
- alias: Send TTS if reminders > 2 and Tony is home
if:
- alias: When reminders > 2 and Tony is home
@@ -2113,6 +2137,18 @@ tony_afternoon_meds:
- action: TONY_AFTERNOON_MEDS_SKIPPED
title: Skip
action: script.text_notify
- action: script.pc_notify
metadata: {}
data:
who: tony
title: Afternoon Meds
message: '{{ response.data.notification_text }}'
actions:
- action: TONY_AFTERNOON_MEDS_TAKEN
title: Taken
- action: TONY_AFTERNOON_MEDS_SKIPPED
title: Skip
alias: Send PC notification
- alias: Send TTS if reminders > 2 and Tony is home
if:
- alias: When reminders > 2 and Tony is home
@@ -2154,6 +2190,18 @@ tony_afternoon_meds:
title: Skip
message: You need to take your afternoon meds
action: script.text_notify
- alias: Send PC notification
action: script.pc_notify
metadata: {}
data:
who: tony
title: Afternoon Meds
message: You need to take your afternoon meds
actions:
- action: TONY_AFTERNOON_MEDS_TAKEN
title: Taken
- action: TONY_AFTERNOON_MEDS_SKIPPED
title: Skip
- alias: Send TTS if reminders > 2 and Tony is home
if:
- alias: When reminders > 2 and Tony is home