Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.99 KB | None | 0 0
  1. sensors:
  2. #HA Update sensor
  3. - platform: rest
  4.   name: Home Assistant Released Version
  5.   json_attributes:
  6.      - body
  7.       - html_url
  8.   resource: https://api.github.com/repos/home-assistant/home-assistant/releases/latest
  9.   username: !secret github_username
  10.   password: !secret github_access_token
  11.   authentication: basic
  12.   value_template: '{{ value_json.tag_name }}'
  13.   headers:
  14.     Accept: application/vnd.github.v3+json
  15.     Content-Type: application/json
  16.     User-Agent: Home Assistant REST sensor
  17. - platform: version  
  18.  
  19. automation:
  20. - alias: Home Assistant Release Check
  21.   initial_state: on
  22.   trigger:
  23.   - platform: template
  24.     value_template: >-
  25.       {% if states.sensor.home_assistant_released_version %}
  26.         {% if states.sensor.current_version %}
  27.           {{ states('sensor.home_assistant_released_version') != states('sensor.current_version') }}
  28.         {% endif %}
  29.       {% endif %}
  30.   # - platform: homeassistant
  31.   #   event: start
  32.   condition:
  33.     condition: template
  34.     value_template: "{{ states('sensor.home_assistant_released_version') != states('sensor.current_version') }}"
  35.   action:
  36.   - service: persistent_notification.create
  37.     data_template:
  38.       title: Home Assistant Release
  39.       message: >-
  40.         A new version of Home Assistant is available, {{ states('sensor.home_assistant_released_version') }}, while current version is {{states('sensor.current_version') }}
  41.        
  42.         Link: {{states.sensor.home_assistant_released_version.attributes.html_url}}
  43.        
  44.         Release notes:
  45.        
  46.         {{states.sensor.home_assistant_released_version.attributes.body.split("## All changes")[0]}}
  47.        
  48.   - service: notify.telegram_notifier
  49.     data_template:
  50.       message: >-
  51.         A new version of Home Assistant is available, {{ states('sensor.home_assistant_released_version') }}, while current version is {{states('sensor.current_version') }}
  52.        
  53.         Link: {{states.sensor.home_assistant_released_version.attributes.html_url}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement