diff --git a/restart-notifier.yaml b/restart-notifier.yaml new file mode 100644 index 0000000..b59c46b --- /dev/null +++ b/restart-notifier.yaml @@ -0,0 +1,68 @@ +--- +# SPDX-License-Identifier: MIT +blueprint: + name: Restart Notifier (v0.1) + + description: | + Sends a notification when Home Assistant restarts + + domain: automation + + input: + notify_service: + name: Zulip Notify + description: | + Notify service name to send to. Should be a Zulip (or compatible) + notify service + default: "zulip" + notify_topic: + name: Notification topic + description: | + The topic that will be used in the Zulip stream + default: "{{ state_attr('zone.home', 'friendly_name') }} restart" + notify_message_prelude: + name: Notification message prelude + description: | + The flavor text to prelude schedules with + default: "{{ state_attr('zone.home', 'friendly_name') }} " + +mode: single + +triggers: + - event: shutdown + id: shutdown + trigger: homeassistant + - event: start + id: startup + trigger: homeassistant + +variables: + # inputs + input_notify_service: !input notify_service + input_notify_topic: !input notify_topic + input_notify_message_prelude: !input notify_message_prelude + + # yamllint disable-line rule:line-length + notify_target: "{{ input_notify_service | lower | replace('notify.', '') | replace(' ', '_') }}" + +condition: [] + +actions: + - choose: + - conditions: + - condition: trigger + id: shutdown + sequence: + - data: + message: "{{ input_notify_message_prelude }} shutting down" + title: "{{ input_notify_topic }}" + action: notify.{{ notify_target }} + - conditions: + - condition: trigger + id: startup + sequence: + - data: + message: "{{ input_notify_message_prelude }} has started" + title: "{{ input_notify_topic }}" + action: notify.{{ notify_target }} + default: []