Nightly briefing for K

This commit is contained in:
2022-04-05 18:29:18 -04:00
parent 20f9ed7e37
commit 4b10ab773f
5 changed files with 246 additions and 7 deletions

View File

@ -63,6 +63,16 @@ automation:
- service: input_boolean.turn_off
entity_id: input_boolean.audible_notifications
- id: 754da2e2-af95-43b0-bb4e-9df553c305fd
alias: Kallen Nightly Briefing
trigger:
platform: time
at: input_datetime.kallen_nightly_report
action:
- service: script.turn_on
entity_id: script.kallen_nightly_briefing
script:
reset_annc_switches:
sequence:
@ -77,12 +87,10 @@ script:
kallen_nightly_briefing:
sequence:
- service: script.local_audio
data_template:
media: "/media/music/ES_RiserSuction5.mp3"
volume: .5
speaker: 'media_player.living_room_echo_dot'
- service: script.text_notify
data_template:
who: "all_ios"
message: "Time for Kallen to get ready for bed."
message: "Time for Kallen to get ready for bed."
- service: notify.alexa_media_basement_echo_dot
data:
message: !include ../templates/speech/kallen_nightly_briefing.yaml

131
packages/events.yaml Normal file
View File

@ -0,0 +1,131 @@
input_boolean:
school_in_session:
name: School In Session
icon: mdi:bus-school
school_today:
name: School Today
icon: mdi:bus-school
school_early_release:
name: School Early Release
icon: mdi:bus-school
input_datetime:
school_first_day:
name: First Day of School
has_date: true
has_time: false
school_last_day:
name: Last Day of School
has_date: true
has_time: false
school_day_start:
name: School Day Start
has_date: false
has_time: true
school_day_end:
name: School Day End
has_date: false
has_time: true
thanksgiving_break_start:
name: Thanksgiving Break
has_date: true
has_time: false
christmas_break_start:
name: Christmas Break
has_date: true
has_time: false
spring_break_start:
name: Spring Break
has_date: true
has_time: false
school_day_start_reminder:
name: School Day Start Reminder
has_date: false
has_time: true
school_day_end_reminder:
name: School Day End Reminder
has_date: false
has_time: true
sensor:
- platform: template
sensors:
school_start_days2go:
value_template: "{{ ((state_attr('input_datetime.school_first_day', 'timestamp')-as_timestamp(now())) | int /60/1440) | round(0) }}"
unit_of_measurement: 'Days'
school_end_days2go:
value_template: "{{ ((state_attr('input_datetime.school_last_day', 'timestamp')-as_timestamp(now())) | int /60/1440) | round(0) }}"
unit_of_measurement: 'Days'
vacation_days2go:
value_template: "{{ ((as_timestamp(strptime(state_attr('calendar.vacation', 'start_time'), '%Y-%m-%d'))-as_timestamp(now())) | int /60/1440) | round(0) }}"
unit_of_measurement: 'Days'
- platform: rest
resource: https://raw.githubusercontent.com/tm24fan8/Home-Assistant-Configs/master/packages/json_data/school.json
name: School Event
scan_interval: 14400
value_template: >
{% set today = now().month ~ '/' ~ now().day %}
{% set event = value_json.EVENTS.static[ today ] %}
{%- if event %}
{{ event }}
{% else %}
Nothing
{%- endif %}
automation:
- id: e1cb2d02-0423-11eb-adc1-0242ac120002
alias: School today
initial_state: true
trigger:
- platform: time
at: '06:00:00'
condition:
- condition: template
value_template: >
{%- if as_timestamp(strptime(state_attr('calendar.kallen_school', 'start_time'), '%Y-%m-%d %H:%M:%S')) | timestamp_custom("%Y-%m-%d") == now().strftime("%Y-%m-%d") %}
true
{%- endif -%}
action:
- choose:
- conditions:
- condition: template
value_template: >
{{ 'Early Release' in states('sensor.school_event') }}
sequence:
- service: input_boolean.turn_on
entity_id: input_boolen.school_early_release
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.school_day_end
data:
time: "14:45:00"
default:
- service: input_datetime.set_datetime
target:
entity_id: input_datetime.school_day_end
data:
time: "15:19:00"
- service: input_boolean.turn_on
entity_id: input_boolean.school_today
- service: script.turn_on
entity_id: script.school_in_session
script:
school_in_session:
sequence:
- condition: state
entity_id: input_boolean.school_in_session
state: 'off'
- service: input_boolean.turn_on
entity_id: input_boolen.school_in_session
school_year_over:
sequence:
- condition: state
entity_id: input_boolean.school_in_session
state: 'on'
- condition: template
value_template: >
{{ states('input_datetime.school_last_day') == now().strftime("%Y-%m-%d") }}
- service: input_boolean.turn_off
entity_id: input_boolen.school_in_session

View File

@ -0,0 +1,9 @@
{
"EVENTS": {
"static": {
"1/25": "Digital Learning Day",
"3/3": "Early Release"
}
}
}