home-assistant-configuration/config/packages/events.yaml

454 lines
12 KiB
YAML
Raw Normal View History

2019-10-08 00:29:29 +00:00
###############################################################################
# @author : Jeffrey Stone
# @date : 02/19/2019
# @package : Events
# @description : Special Events.
###############################################################################
input_boolean:
rex_manning_audio:
name: Rex Manning audio
icon: mdi:speaker-wireless
blackout_time:
name: Blackout Time
icon: mdi:closed-octagon
school_in_session:
name: School In Session
icon: mdi:bus-school
school_is_digital:
name: Digital Learning
icon: mdi:laptop
input_datetime:
school_first_day:
name: First Day of School
has_date: true
has_time: false
initial: '2020-08-12'
school_last_day:
name: Last Day of School
has_date: true
has_time: false
initial: '2021-05-26'
school_day_start:
name: School Day Start
has_date: false
has_time: true
initial: '07:45:00'
school_day_end:
name: School Day End
has_date: false
has_time: true
initial: '14:45:00'
blackout_time_start:
name: Blackout Time Start
has_date: false
has_time: true
initial: '12:00:00'
blackout_time_end:
name: Blackout Time End
has_date: false
has_time: true
initial: '16:00:00'
morning_meeting:
name: Morning Meeting
has_date: false
has_time: true
initial: '08:12:00'
math:
name: Math
has_date: false
has_time: true
initial: '08:28:00'
reading:
name: Reading
has_date: false
has_time: true
initial: '09:48:00'
phonics:
name: Phonics
has_date: false
has_time: true
initial: '10:48:00'
lunch:
name: Lunch
has_date: false
has_time: true
initial: '11:10:00'
specials:
name: Specials
has_date: false
has_time: true
initial: '12:08:00'
writing:
name: Writing
has_date: false
has_time: true
initial: '12:53:00'
science:
name: Science
has_date: false
has_time: true
initial: '13:33:00'
shared_reading:
name: Shared Reading
has_date: false
has_time: true
initial: '14:18:00'
sensor:
- platform: template
sensors:
school_start_days2go:
value_template: '{{ (((states.input_datetime.school_first_day.attributes.timestamp)-as_timestamp(now())) | int /60/1440) | round(0) }}'
unit_of_measurement: 'Days'
school_end_days2go:
value_template: '{{ (((states.input_datetime.school_last_day.attributes.timestamp)-as_timestamp(now())) | int /60/1440) | round(0) }}'
unit_of_measurement: 'Days'
2021-03-06 15:10:07 +00:00
- platform: rest
resource: https://raw.githubusercontent.com/thejeffreystone/home-assistant-configuration/master/config/packages/json_data/school_lunch.json
name: School Lunch
scan_interval: 14400
value_template: >
{% set today = now().month ~ '/' ~ now().day %}
{% set lunch = value_json.MENU.static[ today ] %}
{{ lunch }}
2019-10-08 00:29:29 +00:00
automation:
- id: refresh_special_event_sensors
alias: Refresh special event sensors
initial_state: true
trigger:
- platform: time
at: '00:00:01'
- platform: homeassistant
event: start
action:
- service: python_script.special_events
data:
name: Skylar
type: birthday
date: !secret skylar_bday
- service: python_script.special_events
data:
name: Jeff
type: birthday
date: !secret jeff_bday
- service: python_script.special_events
data:
name: Kat
type: birthday
date: !secret kat_bday
- service: python_script.special_events
data:
name: Our wedding
type: anniversary
date: !secret wed_anniversary
- service: python_script.special_events
data:
name: Disney
type: trip
date: !secret disney_trip
- id: rex_manning_audio
alias: Rex Manning Day Audio
initial_state: true
trigger:
- platform: time
at: '14:00:00'
condition:
- condition: state
entity_id: calendar.anchorage_holidays
state: "on"
- condition: template
value_template: >
{%- set event=states.calendar.anchorage_holidays.attributes.message %}
{%- if event == 'Rex Manning Day' %}
true
{%- endif -%}
action:
- service: script.turn_on
entity_id: script.rex_manning_audio
- delay:
seconds: 40
- service: script.turn_off
entity_id: script.rex_manning_audio
- service: media_player.media_stop
entity_id: media_player.ha_speaker
- id: new_ha_notification
alias: New HA Notification
initial_state: true
trigger:
- platform: state
entity_id: binary_sensor.updater
from: 'off'
to: 'on'
action:
- service: script.twitter_new_ha
# - service: ifttt.trigger
# data_template: {"event":"GitPost", "value1":"Home Assistant {{ states.binary_sensor.updater.attributes.newest_version }} is now available.", "value2":"{{ states.binary_sensor.updater.attributes.newest_version }}"}
- service: rest_command.new_version_github_issue
data_template:
version: "{{ states.binary_sensor.updater.attributes.newest_version }}"
- id: blackout_time_start
initial_state: true
alias: Blackout time Start
trigger:
platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.blackout_time_start', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
condition: template
value_template: '{{ states.calendar.skylar_school.state == "Off" }}'
action:
- wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}"
- service: script.speech_engine
data_template:
who: '{{ states.sensor.room_audio.state }}'
message: "Blackout time has started."
- service: input_boolean.turn_on
entity_id: input_boolean.blackout_time
- id: blackout_time_end
initial_state: true
alias: Blackout time End
trigger:
platform: template
value_template: "{{ states('sensor.time') == (state_attr('input_datetime.blackout_time_end', 'timestamp') | int | timestamp_custom('%H:%M', False)) }}"
condition:
condition: state
entity_id: input_boolean.blackout_time
state: 'on'
action:
- wait_template: "{{ not is_state('media_player.ha_speaker', 'playing') }}"
- service: script.speech_engine
data_template:
who: '{{ states.sensor.room_audio.state }}'
message: "Blackout time has ended"
- service: input_boolean.turn_off
entity_id: input_boolean.blackout_time
- id: digital_learning_start
alias: Digital Learning Start
initial_state: true
trigger:
- platform: state
entity_id: calendar.skylar_school
to: 'on'
condition:
condition: state
entity_id: input_boolean.school_is_digital
state: 'on'
action:
- service: switch.turn_on
entity_id: switch.skylars_desk
- service: script.turn_on
entity_id: script.digital_learning_notification
- id: digital_learning_end
alias: Digital Learning End
initial_state: true
trigger:
- platform: state
entity_id: calendar.skylar_school
to: 'off'
condition:
condition: state
entity_id: input_boolean.school_is_digital
state: 'on'
action:
- service: scene.turn_on
entity_id: scene.skylar_desk_off
- service: input_boolean.turn_on
entity_id: input_boolean.audible_notifications
- id: e1cb391e-0423-11eb-adc1-0242ac120002
alias: Morning Meeting Warning
initial_state: true
trigger:
platform: time
at: input_datetime.morning_meeting
condition:
- condition: state
entity_id: input_boolean.school_is_digital
state: 'on'
action:
- service: script.class_alarm
data:
class: 'Morning Meeting'
- id: e1cb386a-0423-11eb-adc1-0242ac120002
alias: Reading Warning
initial_state: true
trigger:
platform: time
at: input_datetime.reading
condition:
- condition: state
entity_id: input_boolean.school_is_digital
state: 'on'
action:
- service: script.class_alarm
data:
class: 'Reading'
- id: e1cb37a2-0423-11eb-adc1-0242ac120002
alias: Math Warning
initial_state: true
trigger:
platform: time
at: input_datetime.math
condition:
- condition: state
entity_id: input_boolean.school_is_digital
state: 'on'
action:
- service: script.class_alarm
data:
class: 'Math'
- id: e1cb3590-0423-11eb-adc1-0242ac120002
alias: Phonics Warning
initial_state: true
trigger:
platform: time
at: input_datetime.phonics
condition:
- condition: state
entity_id: input_boolean.school_is_digital
state: 'on'
action:
- service: script.class_alarm
data:
class: 'Phonics'
- id: e1cb34d2-0423-11eb-adc1-0242ac120002
alias: Lunch Warning
initial_state: true
trigger:
platform: time
at: input_datetime.lunch
condition:
- condition: state
entity_id: input_boolean.school_is_digital
state: 'on'
action:
- service: script.class_alarm
data:
class: 'Lunch'
- id: e1cb341e-0423-11eb-adc1-0242ac120002
alias: Specials Warning
initial_state: true
trigger:
platform: time
at: input_datetime.specials
condition:
- condition: state
entity_id: input_boolean.school_is_digital
state: 'on'
action:
- service: script.class_alarm
data:
class: 'Specials'
- id: e1cb3360-0423-11eb-adc1-0242ac120002
alias: Writing Warning
initial_state: true
trigger:
platform: time
at: input_datetime.writing
condition:
- condition: state
entity_id: input_boolean.school_is_digital
state: 'on'
action:
- service: script.class_alarm
data:
class: 'Writing'
- id: e1cb32a2-0423-11eb-adc1-0242ac120002
alias: Science Warning
initial_state: true
trigger:
platform: time
at: input_datetime.science
condition:
- condition: state
entity_id: input_boolean.school_is_digital
state: 'on'
action:
- service: script.class_alarm
data:
class: 'Science'
- id: e1cb31e4-0423-11eb-adc1-0242ac120002
alias: Shared Reading Warning
initial_state: true
trigger:
platform: time
at: input_datetime.shared_reading
condition:
- condition: state
entity_id: input_boolean.school_is_digital
state: 'on'
action:
- service: script.class_alarm
data:
class: 'Shared Reading'
script:
rex_manning_audio:
sequence:
- condition: state
entity_id: input_boolean.audible_notifications
state: 'on'
- condition: state
entity_id: sensor.family_status
state: Home
- service: media_player.turn_on
entity_id: media_player.ha_speaker
- service: media_player.volume_set
data_template:
entity_id: media_player.ha_speaker
volume_level: .4
- service: media_player.play_media
entity_id: media_player.ha_speaker
data:
media_content_id: http://192.168.7.40/audio/Rex_Manning_-_Say_No_More_Mon_Amour.mp3
media_content_type: "music"
digital_learning_notification:
sequence:
- condition: state
entity_id: sensor.family_status
state: Home
- service: script.speech_engine
data_template:
who: '{{ states.sensor.room_audio.state }}'
message: "Skylar, digital learning will begin in about thirty minutes. I have turned on the lighting around your desk."
class_alarm:
sequence:
- service: script.speech_engine
data:
who: main
message: >
{{ class }} starts in two minutes.
- service: script.text_notify
data:
who: 'parents'
message: >
{{ class }} starts in two minutes.
rest_command:
new_version_github_issue:
url: https://api.github.com/repos/thejeffreystone/home-assistant-configuration/issues
method: POST
headers:
2020-05-02 00:48:19 +00:00
Authorization: !secret github_issue_token
payload: '{"title":"Home-Assistant {{ version }} available","body":"Home-Assistant {{ version }} is now available"}'