Guest User

Untitled

a guest
Feb 22nd, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 3.29 KB | None | 0 0
  1. sensors.yaml:
  2. - platform: rest
  3.   name: Home Assistant Docker Latest Image Build
  4.   scan_interval: 300
  5.   resource: https://registry.hub.docker.com/v1/repositories/homeassistant/home-assistant/tags
  6.   headers:
  7.     Content-Type: application/json
  8.     User-Agent: Home Assistant REST sensor
  9.   value_template: >-
  10.         {% for image_build in value_json | reverse if image_build.name.split(".")[0]=="0"  %}
  11.           {% if loop.first %}
  12.                {{image_build.name}}
  13.           {% endif %}
  14.         {% endfor %}  
  15. - platform: rest
  16.   name: Home Assistant Released Version
  17.   scan_interval: 300
  18.   json_attributes:
  19.      - body
  20.       - html_url
  21.   resource: https://api.github.com/repos/home-assistant/home-assistant/releases/latest
  22.   username: !secret github_username
  23.   password: !secret github_access_token
  24.   authentication: basic
  25.   value_template: '{{ value_json.tag_name }}'
  26.   headers:
  27.     Accept: application/vnd.github.v3+json
  28.     Content-Type: application/json
  29.     User-Agent: Home Assistant REST sensor
  30.  
  31. - alias: Home Assistant Release Check
  32.   initial_state: on
  33.   trigger:
  34.   - platform: template
  35.     value_template: >-
  36.       {% if states.sensor.home_assistant_released_version %}
  37.         {% if states.sensor.current_version %}
  38.           {% if states.sensor.home_assistant_docker_latest_image_build %}
  39.             {% if states('sensor.home_assistant_released_version') != states('sensor.current_version') %}
  40.               {{ states('sensor.home_assistant_released_version') == states('sensor.home_assistant_docker_latest_image_build') }}
  41.             {% endif %}
  42.           {% endif %}
  43.         {% endif %}
  44.       {% endif %}
  45.   - platform: homeassistant
  46.     event: start
  47.   condition:
  48.     condition: and
  49.     conditions:
  50.       - condition: template
  51.         value_template: >-
  52.           {% if states.sensor.home_assistant_released_version %}
  53.             {% if states.sensor.current_version %}
  54.               {% if states.sensor.home_assistant_docker_latest_image_build %}
  55.                 {% if states('sensor.home_assistant_released_version') != states('sensor.current_version') %}
  56.                   {{ states('sensor.home_assistant_released_version') == states('sensor.home_assistant_docker_latest_image_build') }}
  57.                 {% endif %}
  58.               {% endif %}
  59.             {% endif %}
  60.           {% endif %}
  61.   action:
  62.   - service: persistent_notification.create
  63.     data_template:
  64.       title: Home Assistant Release
  65.       notification_id: hass_release_{{states('sensor.home_assistant_docker_latest_image_build')}}
  66.       message: >-
  67.         A new version of Home Assistant is available, {{ states('sensor.home_assistant_released_version') }}, while current version is {{states('sensor.current_version') }}
  68.        
  69.         Link: {{states.sensor.home_assistant_released_version.attributes.html_url}}
  70.        
  71.         Release notes:
  72.        
  73.         {{states.sensor.home_assistant_released_version.attributes.body.split("## All changes")[0]}}
  74.        
  75.   - service: notify.telegram_notifier
  76.     data_template:
  77.       message: >-
  78.         A new version of Home Assistant is available, {{ states('sensor.home_assistant_released_version') }}, while current version is {{states('sensor.current_version') }}
  79.        
  80.         Link: {{states.sensor.home_assistant_released_version.attributes.html_url}}
Add Comment
Please, Sign In to add comment