Automation: Check for update

I’ve added an automation:

alias: Update Available Notifications
initial_state: 'on'
trigger:
  platform: state
  entity_id: sensor.latest_version
condition:
  condition: template
  value_template: "{{ ( states('sensor.latest_version') | string ) != ( states('sensor.current_version') | string ) }}"
action:
  - service: persistent_notification.create
    data:
      title: "Update Available"
      message: |
        Update for Home Assistant is available. {{ states('sensor.latest_version') }}
        [Home Assistant Dev Blog](https://home-assistant.io/blog/)
        [Updating Home Assistant](https://www.home-assistant.io/docs/installation/updating/)
        
        [Release Notes](https://github.com/home-assistant/home-assistant/releases)

And the 2 sensors:

  - platform: version

  - platform: rest
    resource: https://pypi.python.org/pypi/homeassistant/json
    name: Latest version
    value_template: '{{ value_json.info.version }}'
    scan_interval: 3600

But the condition on the automation doesn’t seem to be working, I always get the persistent notification shown even when the current version matches to the latest version,

Not sure how to help with your example, but could this work instead?

I use the above referenced updater sensor and put the resulting updater.updater entity on my main view. When there is an update it will pop up letting you know it’s available.

Following my script:
configurations.yaml

#Sensori versioni home assistant

  • platform: version

  • platform: rest
    resource: https://pypi.python.org/pypi/homeassistant/json
    name: Latest version
    value_template: ‘{{ value_json.info.version }}’
    scan_interval: 3600

  • platform: template
    sensors:
    ha_aggiornamento_disponibile:
    friendly_name: ‘Aggiornamento HA disponibile’
    value_template: >-
    {%- if states(‘sensor.latest_version’)|string != states(‘sensor.current_version’)|string -%}
    Yes
    {%- else -%}
    No
    {%- endif -%}
    icon_template: >-
    {%- if states(‘sensor.latest_version’)|string != states(‘sensor.current_version’)|string -%}
    mdi:alert-box
    {% else %}
    mdi:approval
    {% endif %}

Above script for setting the value Yes or No for update available, than follow the automation script for send notification

automations.yaml:

  • alias: Notifica Aggiornamento disponibile
    trigger:
    platform: state
    entity_id: sensor.ha_aggiornamento_disponibile
    to: ‘Yes’
    action:
    • service: notify.telegram_bot
      data:
      title: ‘Aggiornamento disponibile
      message: “E’ disponibile un aggiornamento di HA”

Why use rest instead of https://www.home-assistant.io/components/version/?