Sensor and notification showing if update to Hassio is available - I’m using this at the moment:
- platform: template
sensors:
hass_update_available:
friendly_name: 'Hass Update Available'
value_template: >-
{%- if states.sensor.hass_current_version.state != states.sensor.hass_installed_version.state -%}
Yes
{%- else -%}
No
{%- endif -%}
icon_template: >-
{%- if states.sensor.hass_current_version.state != states.sensor.hass_installed_version.state -%}
mdi:alert-box
{% else %}
mdi:approval
{% endif %}
This seems to work well.
I also have an automation to notify me if there is an update available:
- alias: Update Available
trigger:
- platform: state
entity_id: sensor.hass_current_version
condition:
- condition: template
value_template: '{{ states.sensor.hass_current_version.state != states.sensor.hass_installed_version.state
}}'
action:
- service: notify.notify
data:
title: Home Assistant Update
message: Home Assistant {{ states.sensor.hass_current_version.state }} is now
available
This is driving me crazy as OFTEN (like 20 times a day) the current version shows as ‘unavailable’ and I get a notification saying:
Home Assistant Update
Home Assistant unavailable is now available
Then the status will change back to the correct current version ID and then again at some time become unavailable again and rinse and repeat.
How do I edit the automation/template so that it ignores a current version of ‘unavailable’?
keithh666
(Keith Hull)
February 16, 2018, 1:46am
2
put a condition in after the action to check for available, then it will exit if the state is unavailable thereby not sending a notification
So this…
- alias: Update Available
trigger:
- entity_id: sensor.hass_current_version
platform: state
condition:
- condition: template
value_template: '{{ states.sensor.hass_current_version.state != states.sensor.hass_installed_version.state
}}'
- condition: template
value_template: '{{ states.sensor.hass_current_version.state != "unavailable"
}}'
action:
- data:
message: Home Assistant {{ states.sensor.hass_current_version.state }} is now
available
title: Home Assistant Update
service: notify.notify
keithh666
(Keith Hull)
February 16, 2018, 1:52am
4
That should work or as I said put it immediately after the action:
I was using the template editor (the graphical one) and that’s how it formats it
keithh666
(Keith Hull)
February 16, 2018, 1:54am
6
That’s a horrible thing, it formats everything all wrong I only use notepad++ to hand code everything
1 Like
Someone in chat suggested using this:
'{{ states.sensor.hass_current_version.state != states.sensor.hass_installed_version.state and states.sensor.hass_current_version.state = "unavailable" }}'
But I think the second test should be != (not equal to) rather than = (equal to)
But my logic might be flawed?
keithh666
(Keith Hull)
February 16, 2018, 2:01am
8
a single = wont work anyway it needs == but I think you are right != would work for unavailable or == for available
Thanks. I’ll give that a shot.
1 Like
Looks like this…
- alias: Update Available
trigger:
- entity_id: sensor.hass_current_version
platform: state
condition:
- condition: template
value_template: '{{ states.sensor.hass_current_version.state != states.sensor.hass_installed_version.state
and states.sensor.hass_current_version.state != "unavailable"}}'
action:
- data:
message: Home Assistant {{ states.sensor.hass_current_version.state }} is now
available
title: Home Assistant Update
service: notify.notify
1 Like
Just to confirm, the above works and it stopped all the spurious notifications but I got the upgrade available notification correctly.