New morning briefing, and scheduling changes

This commit is contained in:
2022-05-24 18:39:35 -04:00
parent 2071094b63
commit 6290d17053
3 changed files with 175 additions and 1 deletions

View File

@ -99,6 +99,18 @@ automation:
action: action:
- service: script.daily_briefing - service: script.daily_briefing
- id: 5d06ba92-de10-4bf3-bc08-86f5be60c4a7
alias: Morning Briefing
trigger:
- platform: time
at: input_datetime.morning_report
condition:
condition: state
entity_id: binary_sensor.people_present
state: 'on'
action:
- service: script.morning_report
script: script:
reset_annc_switches: reset_annc_switches:
sequence: sequence:
@ -153,4 +165,11 @@ script:
- service: script.speech_engine - service: script.speech_engine
data_template: data_template:
who: "{{ who }}" who: "{{ who }}"
message: !include ../templates/speech/daily_briefing.yaml message: !include ../templates/speech/daily_briefing.yaml
morning_report:
sequence:
- service: script.speech_engine
data_template:
who: "{{ who }}"
message: !include ../templates/speech/morning_briefing.yaml

View File

@ -98,6 +98,26 @@ automation:
{% else %} {% else %}
09:00 09:00
{% endif %} {% endif %}
- service: input_datetime.set_datetime
entity_id: input_datetime.morning_report
data_template:
time: >
{% if is_state('input_boolean.school_today','on') %}
08:20
{% elif is_state('input_boolean.work_today','on') and is_state('input_boolean.school_today','off') %}
{{ (state_attr('input_datetime.tina_workday_start', 'timestamp') - 1800) | timestamp_custom('%H:%M', false) }}
{% else %}
12:00
{% endif %}
- service: input_datetime.set_datetime
entity_id: input_datetime.daily_briefing
data_template:
time: >
{% if is_state('input_boolean.school_today','on') %}
14:15
{% else %}
{{ (state_attr('input_datetime.tina_workday_end', 'timestamp') + 1800) | timestamp_custom('%H:%M', false) }}
{% endif %}
- id: 55293e9a-ec3b-46bb-af47-94e95f3c9951 - id: 55293e9a-ec3b-46bb-af47-94e95f3c9951
alias: House Scheduling - Evening alias: House Scheduling - Evening

View File

@ -0,0 +1,135 @@
>
{# Morning Report #}
{%- macro getReport() -%}
<p>
{% if now().strftime('%H')|int < 12 and now().strftime('%H')|int > 6 %}
Good morning.
{% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %}
Good afternoon.
{% else %}
Good evening.
{% endif %}
</p>
<p>
{% if now().strftime('%H')|int < 12 %}
{% if now().strftime('%M')|int == 0 %}
It is {{ now().strftime('%H')|int }} AM.
{% else %}
It is {{ now().strftime('%H')|int }} {{ now().strftime('%M')|int }} AM.
{% endif %}
{% elif now().strftime('%H')|int > 12 %}
{% if now().strftime('%M')|int == 0 %}
It is {{ now().strftime('%H')|int }} PM.
{% else %}
It is {{ now().strftime('%H')|int }} {{ now().strftime('%M')|int }} PM.
{% endif %}
{% else %}
{% endif %}
</p>
<p>
{{ [
'Today is ',
'If you have not been keeping track today is ',
'Do you know what day of the week it is? Today is',
'I hate to be the bearer of bad news, but today is '
]|random }}
{{states.sensor.today_is.state }}.
</p>
<p>
It is currently {{states.weather.iron_nerd_weather_station.state}} and {{states.sensor.pirateweather_temperature.state|round}} degrees in Defiance.
</p>
<p>
{% if states.sensor.weatheralerts_active_alerts.state | int > 0 %}
There are currently {{states.sensor.weatheralerts_active_alerts.state }} active weather alerts for our area.
{% endif %}
</p>
<p>
{{ [
'The rest of the day should be,',
'Todays forecast should be ,'
]|random }}
{{ states.sensor.current_forecast.state }}
</p>
<p>
{% if is_state('sensor.halloween_countdown','0') %}
Happy Halloween!
{% endif %}
{% if is_state('sensor.christmas_countdown','0') %}
Merry Christmas Everyone!
{% endif %}
{% if is_state('sensor.anniversary_wedding_anniversary','0') %}
Happy Anniversary! It been an amazing {{ states.sensor.anniversary_wedding_anniversary.attributes.years }} years!
{% endif %}
{% if is_state('calendar.holidays_in_united_states', 'on') %}
Today is {{states.calendar.holidays_in_united_states.attributes.message}}.
{% endif %}
{% if states.calendar.birthdays.state == 'on' %}
Today is {{ states.calendar.birthdays.attributes.message }}! So Happy Birthday! The confetti cannon is not working otherwise I would shower you in paper garbage that someone else would have to pick up.
{% endif %}
{%- set event=states.calendar.national_holidays.attributes.message %}
{% if 'Day' in event and 'National' in event%}
{{ [
'And a very special Happy ',
'It is also ',
'Today is also known as ',
'Oh <emphasis>Look</emphasis>. Today is ',
'Want to know a fact? Today is ',
'Everyday can be a holiday. So today is '
]|random }}
{{states.calendar.national_holidays.attributes.message | replace("&"," and ") }}.
{%- endif -%}
</p>
<p>
{% if is_state('input_boolean.school_today','on') and is_state('input_boolean.work_today','on') %}
{%- if states.sensor.home_to_school.state|round > 12 %}
Traffic to the school appears heavier than normnal.
{% else %}
Traffic to the school is normal.
{% endif %}
Currently it will take {{states.sensor.home_to_school.state|round}} minutes to get to the school.
{%- if states.sensor.school_to_chipotle.state|round > 15 %}
Traffic from the school to Chipotle appears heavier than normnal.
{% else %}
Traffic from the school to Chipotle is normal.
{% endif %}
Currently it will take {{states.sensor.school_to_chipotle.state|round}} minutes to get to Chipotle from the school.
{% elif is_state('input_boolean.work_today','on') %}
{%- if states.sensor.home_to_chipotle.state|round > 15 %}
Traffic to Chipotle appears heavier than normnal.
{% else %}
Traffic to Chipotle is normal.
{% endif %}
Currently it will take {{states.sensor.home_to_chipotle.state|round}} minutes to get to Chipotle.
{% elif is_state('input_boolean.school_today','on') %}
{%- if states.sensor.home_to_school.state|round > 12 %}
Traffic to the school appears heavier than normnal.
{% else %}
Traffic to the school is normal.
{% endif %}
Currently it will take {{states.sensor.home_to_school.state|round}} minutes to get to the school.
{% else %}
It appears no traffic reports are needed today. Enjoy your day off!
{% endif %}
</p>
{%- 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()) -}}