78 lines
3.0 KiB
YAML
Executable File
78 lines
3.0 KiB
YAML
Executable File
- alias: "Update Available Notification"
|
||
hide_entity: True
|
||
trigger:
|
||
platform: state
|
||
entity_id: updater.updater
|
||
|
||
condition:
|
||
- condition: template
|
||
value_template: "{{ states('updater.updater') != 'unknown' }}"
|
||
|
||
action:
|
||
- service: script.notify_engine
|
||
data_template:
|
||
value1: "Home Assistant {{ states.updater.updater.state }} is now available. {{now().strftime('%Y-%m-%d %I:%M %p')}}"
|
||
who: 'carlo'
|
||
|
||
- service: ifttt.trigger
|
||
data_template: {"event":"GitPost", "value1":"Home Assistant {{ states.updater.updater.state }} is now available.", "value2":"{{ states.updater.updater.state }}"}
|
||
|
||
- service: script.tweet_engine_image
|
||
data_template:
|
||
tweet: >-
|
||
{% macro getIntro() %}
|
||
{{- [
|
||
"Woohoo! ",
|
||
"BAM! ",
|
||
"Look at that! "
|
||
] | random -}}
|
||
{% endmacro %}
|
||
{% macro getVersion() %}
|
||
"New version of @Home_Assistant! Cannot wait for @CCostan to install {{ states('updater.updater') }}! (http://www.vmwareinfo.com/2017/07/my-smart-home-look-at-parts-that-make.html)"
|
||
{% endmacro %}
|
||
{%- macro getRandomSnark() -%}
|
||
{{- [
|
||
" It’s like Patch Tuesday, but without the fail. #homeassistant",
|
||
" Get in my SSD! #homeassistant",
|
||
" Shut up and take my ones and zeros! #homeassistant",
|
||
" Seriously, you want some of this! #homeassistant",
|
||
" Be sure to read the breaking changes! ",
|
||
""
|
||
] | random -}}
|
||
{%- 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() -%}
|
||
{{ getIntro() }}
|
||
{{ getVersion() }}
|
||
{{ getRandomSnark() }}
|
||
|
||
{%- endmacro -%}
|
||
|
||
{# Call the macro #}
|
||
{{- cleanup(mother_of_all_macros()) -}}
|
||
|
||
image: >-
|
||
{{ [
|
||
"/config/www/custom_ui/floorplan/images/branding/repo_ad.png",
|
||
"/config/www/custom_ui/floorplan/images/branding/repo_ad2.png",
|
||
"/config/www/custom_ui/floorplan/images/branding/repo_ad3.png",
|
||
] | random }}
|
||
|
||
- service: notify.html5
|
||
data_template:
|
||
title: "Update Available"
|
||
message: "Home Assistant {{ states('updater.updater') }} is available. - {{ as_timestamp(now()) | timestamp_custom('%I:%M:%S %p %d%b%Y', true) }}"
|
||
|
||
- service: persistent_notification.create
|
||
data:
|
||
title: "Update Available"
|
||
message: "Home Assistant {{ states('updater.updater') }} is available. - {{ as_timestamp(now()) | timestamp_custom('%I:%M:%S %p %d%b%Y', true) }}"
|
||
notification_id: "update_available"
|