| @@ -0,0 +1,29 @@ | |||
| 1 | + | alias: Buzzer Alarm | |
| 2 | + | description: Start and stop the MIDI player with the alarm toggle. | |
| 3 | + | triggers: | |
| 4 | + | - trigger: state | |
| 5 | + | entity_id: input_boolean.alarm_ringing | |
| 6 | + | to: 'on' | |
| 7 | + | - trigger: state | |
| 8 | + | entity_id: input_boolean.alarm_ringing | |
| 9 | + | to: 'off' | |
| 10 | + | actions: | |
| 11 | + | - choose: | |
| 12 | + | - conditions: | |
| 13 | + | - condition: state | |
| 14 | + | entity_id: input_boolean.alarm_ringing | |
| 15 | + | state: 'on' | |
| 16 | + | sequence: | |
| 17 | + | - action: media_player.repeat_set | |
| 18 | + | target: | |
| 19 | + | entity_id: media_player.midi_player_tux_universe_esp32_wroom_1 | |
| 20 | + | data: | |
| 21 | + | repeat: all | |
| 22 | + | - action: media_player.media_play | |
| 23 | + | target: | |
| 24 | + | entity_id: media_player.midi_player_tux_universe_esp32_wroom_1 | |
| 25 | + | default: | |
| 26 | + | - action: media_player.media_stop | |
| 27 | + | target: | |
| 28 | + | entity_id: media_player.midi_player_tux_universe_esp32_wroom_1 | |
| 29 | + | mode: restart | |
jonas / Homeassistant config files for my alarm system synced with school starting times
Last active 9 hours ago
YAML configs for my home assistant alarm setup
Diff is too large to be shown
| @@ -0,0 +1,35 @@ | |||
| 1 | + | alias: OSIRIS Alarm Trigger | |
| 2 | + | description: >- | |
| 3 | + | Turns on the alarm when the configured weekday time is reached and Alarm on is | |
| 4 | + | enabled. | |
| 5 | + | triggers: | |
| 6 | + | - trigger: time | |
| 7 | + | at: input_datetime.osiris_maandag | |
| 8 | + | - trigger: time | |
| 9 | + | at: input_datetime.osiris_dinsdag | |
| 10 | + | - trigger: time | |
| 11 | + | at: input_datetime.osiris_woensdag | |
| 12 | + | - trigger: time | |
| 13 | + | at: input_datetime.osiris_donderdag | |
| 14 | + | - trigger: time | |
| 15 | + | at: input_datetime.osiris_vrijdag | |
| 16 | + | conditions: | |
| 17 | + | - condition: state | |
| 18 | + | entity_id: input_boolean.alarm_on | |
| 19 | + | state: 'on' | |
| 20 | + | - condition: template | |
| 21 | + | value_template: | | |
| 22 | + | {% set weekday = now().weekday() %} | |
| 23 | + | {% set helpers = [ | |
| 24 | + | 'input_datetime.osiris_maandag', | |
| 25 | + | 'input_datetime.osiris_dinsdag', | |
| 26 | + | 'input_datetime.osiris_woensdag', | |
| 27 | + | 'input_datetime.osiris_donderdag', | |
| 28 | + | 'input_datetime.osiris_vrijdag' | |
| 29 | + | ] %} | |
| 30 | + | {{ weekday < 5 and trigger.entity_id == helpers[weekday] }} | |
| 31 | + | actions: | |
| 32 | + | - action: input_boolean.turn_on | |
| 33 | + | target: | |
| 34 | + | entity_id: input_boolean.alarm_ringing | |
| 35 | + | mode: single | |
| @@ -0,0 +1,121 @@ | |||
| 1 | + | alias: OSIRIS Force Update Week | |
| 2 | + | mode: single | |
| 3 | + | sequence: | |
| 4 | + | - action: calendar.get_events | |
| 5 | + | target: | |
| 6 | + | entity_id: calendar.osiris | |
| 7 | + | data: | |
| 8 | + | start_date_time: >- | |
| 9 | + | {{ (today_at('00:00') - | |
| 10 | + | timedelta(days=today_at('00:00').weekday())).strftime('%Y-%m-%d | |
| 11 | + | 00:00:00') }} | |
| 12 | + | end_date_time: >- | |
| 13 | + | {{ (today_at('00:00') - timedelta(days=today_at('00:00').weekday()) + | |
| 14 | + | timedelta(days=5)).strftime('%Y-%m-%d 00:00:00') }} | |
| 15 | + | response_variable: osiris_calendar | |
| 16 | + | - variables: | |
| 17 | + | maandag_events: > | |
| 18 | + | {% set ns = namespace(events=[]) %} {% set target_date = | |
| 19 | + | (today_at('00:00') - | |
| 20 | + | timedelta(days=today_at('00:00').weekday())).strftime('%Y-%m-%d') %} {% | |
| 21 | + | for event in osiris_calendar['calendar.osiris']['events'] %} | |
| 22 | + | {% set start = as_datetime(event.start) %} | |
| 23 | + | {% if start and start.strftime('%Y-%m-%d') == target_date and event.summary != 'ZIE PERSOONLIJK ROOSTER' %} | |
| 24 | + | {% set ns.events = ns.events + [event] %} | |
| 25 | + | {% endif %} | |
| 26 | + | {% endfor %} {{ ns.events | sort(attribute='start') }} | |
| 27 | + | dinsdag_events: > | |
| 28 | + | {% set ns = namespace(events=[]) %} {% set target_date = | |
| 29 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday() - | |
| 30 | + | 1)).strftime('%Y-%m-%d') %} {% for event in | |
| 31 | + | osiris_calendar['calendar.osiris']['events'] %} | |
| 32 | + | {% set start = as_datetime(event.start) %} | |
| 33 | + | {% if start and start.strftime('%Y-%m-%d') == target_date and event.summary != 'ZIE PERSOONLIJK ROOSTER' %} | |
| 34 | + | {% set ns.events = ns.events + [event] %} | |
| 35 | + | {% endif %} | |
| 36 | + | {% endfor %} {{ ns.events | sort(attribute='start') }} | |
| 37 | + | woensdag_events: > | |
| 38 | + | {% set ns = namespace(events=[]) %} {% set target_date = | |
| 39 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday() - | |
| 40 | + | 2)).strftime('%Y-%m-%d') %} {% for event in | |
| 41 | + | osiris_calendar['calendar.osiris']['events'] %} | |
| 42 | + | {% set start = as_datetime(event.start) %} | |
| 43 | + | {% if start and start.strftime('%Y-%m-%d') == target_date and event.summary != 'ZIE PERSOONLIJK ROOSTER' %} | |
| 44 | + | {% set ns.events = ns.events + [event] %} | |
| 45 | + | {% endif %} | |
| 46 | + | {% endfor %} {{ ns.events | sort(attribute='start') }} | |
| 47 | + | donderdag_events: > | |
| 48 | + | {% set ns = namespace(events=[]) %} {% set target_date = | |
| 49 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday() - | |
| 50 | + | 3)).strftime('%Y-%m-%d') %} {% for event in | |
| 51 | + | osiris_calendar['calendar.osiris']['events'] %} | |
| 52 | + | {% set start = as_datetime(event.start) %} | |
| 53 | + | {% if start and start.strftime('%Y-%m-%d') == target_date and event.summary != 'ZIE PERSOONLIJK ROOSTER' %} | |
| 54 | + | {% set ns.events = ns.events + [event] %} | |
| 55 | + | {% endif %} | |
| 56 | + | {% endfor %} {{ ns.events | sort(attribute='start') }} | |
| 57 | + | vrijdag_events: > | |
| 58 | + | {% set ns = namespace(events=[]) %} {% set target_date = | |
| 59 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday() - | |
| 60 | + | 4)).strftime('%Y-%m-%d') %} {% for event in | |
| 61 | + | osiris_calendar['calendar.osiris']['events'] %} | |
| 62 | + | {% set start = as_datetime(event.start) %} | |
| 63 | + | {% if start and start.strftime('%Y-%m-%d') == target_date and event.summary != 'ZIE PERSOONLIJK ROOSTER' %} | |
| 64 | + | {% set ns.events = ns.events + [event] %} | |
| 65 | + | {% endif %} | |
| 66 | + | {% endfor %} {{ ns.events | sort(attribute='start') }} | |
| 67 | + | - if: | |
| 68 | + | - condition: template | |
| 69 | + | value_template: '{{ maandag_events | length > 0 }}' | |
| 70 | + | then: | |
| 71 | + | - action: input_datetime.set_datetime | |
| 72 | + | target: | |
| 73 | + | entity_id: input_datetime.osiris_maandag | |
| 74 | + | data: | |
| 75 | + | datetime: > | |
| 76 | + | {{ (as_datetime(maandag_events[0].start) - | |
| 77 | + | timedelta(minutes=90)).strftime('%Y-%m-%d %H:%M:%S') }} | |
| 78 | + | - if: | |
| 79 | + | - condition: template | |
| 80 | + | value_template: '{{ dinsdag_events | length > 0 }}' | |
| 81 | + | then: | |
| 82 | + | - action: input_datetime.set_datetime | |
| 83 | + | target: | |
| 84 | + | entity_id: input_datetime.osiris_dinsdag | |
| 85 | + | data: | |
| 86 | + | datetime: > | |
| 87 | + | {{ (as_datetime(dinsdag_events[0].start) - | |
| 88 | + | timedelta(minutes=90)).strftime('%Y-%m-%d %H:%M:%S') }} | |
| 89 | + | - if: | |
| 90 | + | - condition: template | |
| 91 | + | value_template: '{{ woensdag_events | length > 0 }}' | |
| 92 | + | then: | |
| 93 | + | - action: input_datetime.set_datetime | |
| 94 | + | target: | |
| 95 | + | entity_id: input_datetime.osiris_woensdag | |
| 96 | + | data: | |
| 97 | + | datetime: > | |
| 98 | + | {{ (as_datetime(woensdag_events[0].start) - | |
| 99 | + | timedelta(minutes=90)).strftime('%Y-%m-%d %H:%M:%S') }} | |
| 100 | + | - if: | |
| 101 | + | - condition: template | |
| 102 | + | value_template: '{{ donderdag_events | length > 0 }}' | |
| 103 | + | then: | |
| 104 | + | - action: input_datetime.set_datetime | |
| 105 | + | target: | |
| 106 | + | entity_id: input_datetime.osiris_donderdag | |
| 107 | + | data: | |
| 108 | + | datetime: > | |
| 109 | + | {{ (as_datetime(donderdag_events[0].start) - | |
| 110 | + | timedelta(minutes=90)).strftime('%Y-%m-%d %H:%M:%S') }} | |
| 111 | + | - if: | |
| 112 | + | - condition: template | |
| 113 | + | value_template: '{{ vrijdag_events | length > 0 }}' | |
| 114 | + | then: | |
| 115 | + | - action: input_datetime.set_datetime | |
| 116 | + | target: | |
| 117 | + | entity_id: input_datetime.osiris_vrijdag | |
| 118 | + | data: | |
| 119 | + | datetime: > | |
| 120 | + | {{ (as_datetime(vrijdag_events[0].start) - | |
| 121 | + | timedelta(minutes=90)).strftime('%Y-%m-%d %H:%M:%S') }} | |
| @@ -0,0 +1,156 @@ | |||
| 1 | + | alias: OSIRIS Update Week | |
| 2 | + | mode: single | |
| 3 | + | sequence: | |
| 4 | + | - action: calendar.get_events | |
| 5 | + | target: | |
| 6 | + | entity_id: calendar.osiris | |
| 7 | + | data: | |
| 8 | + | start_date_time: >- | |
| 9 | + | {{ (today_at('00:00') - | |
| 10 | + | timedelta(days=today_at('00:00').weekday())).strftime('%Y-%m-%d | |
| 11 | + | 00:00:00') }} | |
| 12 | + | end_date_time: >- | |
| 13 | + | {{ (today_at('00:00') - timedelta(days=today_at('00:00').weekday()) + | |
| 14 | + | timedelta(days=5)).strftime('%Y-%m-%d 00:00:00') }} | |
| 15 | + | response_variable: osiris_calendar | |
| 16 | + | - variables: | |
| 17 | + | osiris_events: | | |
| 18 | + | {{ osiris_calendar['calendar.osiris']['events'] | |
| 19 | + | | rejectattr('summary', 'equalto', 'ZIE PERSOONLIJK ROOSTER') | |
| 20 | + | | list }} | |
| 21 | + | - if: | |
| 22 | + | - condition: template | |
| 23 | + | value_template: | | |
| 24 | + | {{ states('input_datetime.osiris_maandag')[0:10] != | |
| 25 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday())).strftime('%Y-%m-%d') }} | |
| 26 | + | then: | |
| 27 | + | - variables: | |
| 28 | + | maandag_events: > | |
| 29 | + | {% set ns = namespace(events=[]) %} {% set target_date = | |
| 30 | + | (today_at('00:00') - | |
| 31 | + | timedelta(days=today_at('00:00').weekday())).strftime('%Y-%m-%d') %} | |
| 32 | + | {% for event in osiris_events %} | |
| 33 | + | {% set start = as_datetime(event.start) %} | |
| 34 | + | {% if start and start.strftime('%Y-%m-%d') == target_date %} | |
| 35 | + | {% set ns.events = ns.events + [event] %} | |
| 36 | + | {% endif %} | |
| 37 | + | {% endfor %} {{ ns.events | sort(attribute='start') }} | |
| 38 | + | - if: | |
| 39 | + | - condition: template | |
| 40 | + | value_template: '{{ maandag_events | length > 0 }}' | |
| 41 | + | then: | |
| 42 | + | - action: input_datetime.set_datetime | |
| 43 | + | target: | |
| 44 | + | entity_id: input_datetime.osiris_maandag | |
| 45 | + | data: | |
| 46 | + | datetime: > | |
| 47 | + | {{ (as_datetime(maandag_events[0].start) - | |
| 48 | + | timedelta(minutes=90)).strftime('%Y-%m-%d %H:%M:%S') }} | |
| 49 | + | - if: | |
| 50 | + | - condition: template | |
| 51 | + | value_template: | | |
| 52 | + | {{ states('input_datetime.osiris_dinsdag')[0:10] != | |
| 53 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday() - 1)).strftime('%Y-%m-%d') }} | |
| 54 | + | then: | |
| 55 | + | - variables: | |
| 56 | + | dinsdag_events: > | |
| 57 | + | {% set ns = namespace(events=[]) %} {% set target_date = | |
| 58 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday() - | |
| 59 | + | 1)).strftime('%Y-%m-%d') %} {% for event in osiris_events %} | |
| 60 | + | {% set start = as_datetime(event.start) %} | |
| 61 | + | {% if start and start.strftime('%Y-%m-%d') == target_date %} | |
| 62 | + | {% set ns.events = ns.events + [event] %} | |
| 63 | + | {% endif %} | |
| 64 | + | {% endfor %} {{ ns.events | sort(attribute='start') }} | |
| 65 | + | - if: | |
| 66 | + | - condition: template | |
| 67 | + | value_template: '{{ dinsdag_events | length > 0 }}' | |
| 68 | + | then: | |
| 69 | + | - action: input_datetime.set_datetime | |
| 70 | + | target: | |
| 71 | + | entity_id: input_datetime.osiris_dinsdag | |
| 72 | + | data: | |
| 73 | + | datetime: > | |
| 74 | + | {{ (as_datetime(dinsdag_events[0].start) - | |
| 75 | + | timedelta(minutes=90)).strftime('%Y-%m-%d %H:%M:%S') }} | |
| 76 | + | - if: | |
| 77 | + | - condition: template | |
| 78 | + | value_template: | | |
| 79 | + | {{ states('input_datetime.osiris_woensdag')[0:10] != | |
| 80 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday() - 2)).strftime('%Y-%m-%d') }} | |
| 81 | + | then: | |
| 82 | + | - variables: | |
| 83 | + | woensdag_events: > | |
| 84 | + | {% set ns = namespace(events=[]) %} {% set target_date = | |
| 85 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday() - | |
| 86 | + | 2)).strftime('%Y-%m-%d') %} {% for event in osiris_events %} | |
| 87 | + | {% set start = as_datetime(event.start) %} | |
| 88 | + | {% if start and start.strftime('%Y-%m-%d') == target_date %} | |
| 89 | + | {% set ns.events = ns.events + [event] %} | |
| 90 | + | {% endif %} | |
| 91 | + | {% endfor %} {{ ns.events | sort(attribute='start') }} | |
| 92 | + | - if: | |
| 93 | + | - condition: template | |
| 94 | + | value_template: '{{ woensdag_events | length > 0 }}' | |
| 95 | + | then: | |
| 96 | + | - action: input_datetime.set_datetime | |
| 97 | + | target: | |
| 98 | + | entity_id: input_datetime.osiris_woensdag | |
| 99 | + | data: | |
| 100 | + | datetime: > | |
| 101 | + | {{ (as_datetime(woensdag_events[0].start) - | |
| 102 | + | timedelta(minutes=90)).strftime('%Y-%m-%d %H:%M:%S') }} | |
| 103 | + | - if: | |
| 104 | + | - condition: template | |
| 105 | + | value_template: | | |
| 106 | + | {{ states('input_datetime.osiris_donderdag')[0:10] != | |
| 107 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday() - 3)).strftime('%Y-%m-%d') }} | |
| 108 | + | then: | |
| 109 | + | - variables: | |
| 110 | + | donderdag_events: > | |
| 111 | + | {% set ns = namespace(events=[]) %} {% set target_date = | |
| 112 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday() - | |
| 113 | + | 3)).strftime('%Y-%m-%d') %} {% for event in osiris_events %} | |
| 114 | + | {% set start = as_datetime(event.start) %} | |
| 115 | + | {% if start and start.strftime('%Y-%m-%d') == target_date %} | |
| 116 | + | {% set ns.events = ns.events + [event] %} | |
| 117 | + | {% endif %} | |
| 118 | + | {% endfor %} {{ ns.events | sort(attribute='start') }} | |
| 119 | + | - if: | |
| 120 | + | - condition: template | |
| 121 | + | value_template: '{{ donderdag_events | length > 0 }}' | |
| 122 | + | then: | |
| 123 | + | - action: input_datetime.set_datetime | |
| 124 | + | target: | |
| 125 | + | entity_id: input_datetime.osiris_donderdag | |
| 126 | + | data: | |
| 127 | + | datetime: > | |
| 128 | + | {{ (as_datetime(donderdag_events[0].start) - | |
| 129 | + | timedelta(minutes=90)).strftime('%Y-%m-%d %H:%M:%S') }} | |
| 130 | + | - if: | |
| 131 | + | - condition: template | |
| 132 | + | value_template: | | |
| 133 | + | {{ states('input_datetime.osiris_vrijdag')[0:10] != | |
| 134 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday() - 4)).strftime('%Y-%m-%d') }} | |
| 135 | + | then: | |
| 136 | + | - variables: | |
| 137 | + | vrijdag_events: > | |
| 138 | + | {% set ns = namespace(events=[]) %} {% set target_date = | |
| 139 | + | (today_at('00:00') - timedelta(days=today_at('00:00').weekday() - | |
| 140 | + | 4)).strftime('%Y-%m-%d') %} {% for event in osiris_events %} | |
| 141 | + | {% set start = as_datetime(event.start) %} | |
| 142 | + | {% if start and start.strftime('%Y-%m-%d') == target_date %} | |
| 143 | + | {% set ns.events = ns.events + [event] %} | |
| 144 | + | {% endif %} | |
| 145 | + | {% endfor %} {{ ns.events | sort(attribute='start') }} | |
| 146 | + | - if: | |
| 147 | + | - condition: template | |
| 148 | + | value_template: '{{ vrijdag_events | length > 0 }}' | |
| 149 | + | then: | |
| 150 | + | - action: input_datetime.set_datetime | |
| 151 | + | target: | |
| 152 | + | entity_id: input_datetime.osiris_vrijdag | |
| 153 | + | data: | |
| 154 | + | datetime: > | |
| 155 | + | {{ (as_datetime(vrijdag_events[0].start) - | |
| 156 | + | timedelta(minutes=90)).strftime('%Y-%m-%d %H:%M:%S') }} | |
| @@ -0,0 +1,17 @@ | |||
| 1 | + | alias: Run OSIRIS Update | |
| 2 | + | description: '' | |
| 3 | + | triggers: | |
| 4 | + | - trigger: time | |
| 5 | + | at: '05:00:00' | |
| 6 | + | weekday: | |
| 7 | + | - mon | |
| 8 | + | - tue | |
| 9 | + | - wed | |
| 10 | + | - thu | |
| 11 | + | - fri | |
| 12 | + | conditions: [] | |
| 13 | + | actions: | |
| 14 | + | - action: script.osiris_update_week | |
| 15 | + | metadata: {} | |
| 16 | + | data: {} | |
| 17 | + | mode: single | |
| @@ -0,0 +1,13 @@ | |||
| 1 | + | alias: Toggle alarm with button | |
| 2 | + | description: '' | |
| 3 | + | triggers: | |
| 4 | + | - trigger: state | |
| 5 | + | entity_id: | |
| 6 | + | - binary_sensor.jonas_bedroom_tux_universe_esp32_wroom_1_button_1 | |
| 7 | + | from: 'off' | |
| 8 | + | to: 'on' | |
| 9 | + | actions: | |
| 10 | + | - action: input_boolean.toggle | |
| 11 | + | target: | |
| 12 | + | entity_id: input_boolean.alarm_ringing | |
| 13 | + | mode: single | |