From 6cb6e2ef07c59d903bb8d89b943be39a0cead678 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Fri, 29 Mar 2024 19:05:24 -0400 Subject: [PATCH] Add basement briefing #193 --- automations.yaml | 22 ++++++++++++ configuration.yaml | 2 ++ packages/announcements.yaml | 14 ++++++++ sensors/house_stats.yaml | 19 ++++++++++ templates/speech/basement_briefing.yaml | 48 +++++++++++++++++++++++++ 5 files changed, 105 insertions(+) create mode 100644 templates/speech/basement_briefing.yaml diff --git a/automations.yaml b/automations.yaml index 7de8e90..bd8b474 100644 --- a/automations.yaml +++ b/automations.yaml @@ -4776,3 +4776,25 @@ alias: Set time night meds were taken mode: parallel max: 4 +- id: '1711657679853' + alias: Basement Briefing + description: '' + trigger: + - platform: state + entity_id: + - binary_sensor.basement_studio_motion + from: 'off' + to: 'on' + id: motion-on + alias: Motion is detected in the basement + condition: + - condition: state + entity_id: input_boolean.basement_briefing + state: 'off' + alias: Basement briefing has not already run for the day + action: + - service: script.basement_briefing + metadata: {} + data: {} + alias: Run basement briefing script + mode: single diff --git a/configuration.yaml b/configuration.yaml index 1b92f85..978b3b6 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -303,6 +303,7 @@ influxdb: - sensor.climate_devices_running - sensor.bypassed_sensors - input_boolean.shower_mode + - sensor.services_down logbook: include: @@ -461,3 +462,4 @@ prometheus: - sensor.climate_devices_running - sensor.bypassed_sensors - input_boolean.shower_mode + - sensor.services_down diff --git a/packages/announcements.yaml b/packages/announcements.yaml index 914086e..fe5842b 100644 --- a/packages/announcements.yaml +++ b/packages/announcements.yaml @@ -82,6 +82,9 @@ input_boolean: kallen_nightly_briefing: name: Kallen Nightly Briefing Ran icon: mdi:home-analytics + basement_briefing: + name: Basement Briefing Ran + icon: mdi:home-analytics weather_reports: name: Weather Info icon: mdi:weather-cloudy-alert @@ -198,6 +201,17 @@ script: target: entity_id: input_boolean.good_morning + basement_briefing: + alias: 'Basement Briefing' + sequence: + - service: script.speech_engine + data: + who: "{{ who|default('basement') }}" + message: !include ../templates/speech/basement_briefing.yaml + - service: input_boolean.turn_on + target: + entity_id: input_boolean.basement_briefing + dinner_is_ready: alias: 'Dinner Is Ready' sequence: diff --git a/sensors/house_stats.yaml b/sensors/house_stats.yaml index 7b9986e..d161e46 100644 --- a/sensors/house_stats.yaml +++ b/sensors/house_stats.yaml @@ -453,3 +453,22 @@ {'friendly_name': state_attr('sensor.master_bedroom_illuminance','friendly_name'), 'state': states('sensor.master_bedroom_illuminance') | default(0) | int }] %} {% set names_list = entity_list | sort(attribute='state',reverse=true) | map(attribute='friendly_name') | list %} {{ names_list[0] | regex_replace(find='Illuminance', replace='', ignorecase=False) }} + - name: Services Down + unique_id: 1617ede2-c2ee-4159-a0a0-f0ae869325f1 + unit_of_measurement: '' + icon: mdi:close-network-outline + state: > + {% set uptimekuma = states.binary_sensor | + selectattr('entity_id','in',integration_entities('uptime_kuma')) | + selectattr('state','eq','off') | + map(attribute='attributes.friendly_name') | + list %} + {{ uptimekuma | count | int }} + attributes: + services: > + {% set uptimekuma = states.binary_sensor | + selectattr('entity_id','in',integration_entities('uptime_kuma')) | + selectattr('state','eq','off') | + map(attribute='attributes.friendly_name') | + list %} + {{ uptimekuma | join(', ') }} diff --git a/templates/speech/basement_briefing.yaml b/templates/speech/basement_briefing.yaml new file mode 100644 index 0000000..05643e8 --- /dev/null +++ b/templates/speech/basement_briefing.yaml @@ -0,0 +1,48 @@ +> + {# Basement Briefing #} + + {% from 'formatting.jinja' import cleanup %} + {%- macro getReport() -%} + {% from 'speech.jinja' import greeting, today_is %} + {% from 'weather.jinja' import weatherReport %} + {% from 'sports.jinja' import sports_updates %} +

+ {{ greeting('date') }} +

+

+ {{ today_is() }} +

+ +

+ {{ weatherReport('full','tts') }} +

+ +

+ There are {{ states('sensor.services_down') }} services currently offline. + {% if states('sensor.services_down') | int > 0 %} + They are {{ state_attr('sensor.services_down','services') }}. + {% endif %} +

+ +

+ {% if is_state('input_boolean.sports_updates','on') %} + {{ sports_updates('pregame') }} + {{ sports_updates('main') }} + {% endif %} +

+ + {%- endmacro -%} + + {# a macro that removes all newline characters, empty spaces, and returns formatted text #} + {%- macro cleanup(data) -%} + {%- for item in data.split("\n") if item | trim != "" -%} + {{ item | trim }} {% endfor -%} + {%- endmacro -%} + + {# a macro to call all macros :) #} + {%- macro mother_of_all_macros() -%} + {{ getReport() }} + {%- endmacro -%} + + {# Call the macro #} + {{- cleanup(mother_of_all_macros()) -}}