Value_Template not containing beta

I’m using this condition in an automation to notify me if a new version is available:

i’m using a value_template to notify me if there is a new version available - is there any way I can set it so that it won’t notify me if the available version contains beta?

  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"}}'

so == means equal
!= means not equal
Is there a code for does not contain?

that’s my current so i’d like to add a condition to ignore it if it contains beta as well
I’m sub’d to beta but rolled back due to xiaomi issues and I keep getting notifications every 5 mins. I know I could unsub to beta…

Would this work?

  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" and beta in states.sensor.hass_current_version.state != true }}'

I think maybe I need this:

{{ states.sensor.hass_current_version.state != states.sensor.hass_installed_version.state and states.sensor.hass_current_version.state != "unavailable" and not "beta" in states.sensor.hass_current_version.state != true }}

In the template checker this comes up as False and if I change and not to and it is true

This may work. It depends on what hass_current_version.state returns. I’m guessing a string.

With that in mind, the only typo i see is that you don’t have quotes around beta. Also, you can simplify the last and check and reorganize the order. Reorganizing the order will save time make it so checks are done in the appropriate order:

"{{ states.sensor.hass_current_version.state != 'unavailable' and 'beta' not in states.sensor.hass_current_version.state and states.sensor.hass_current_version.state != states.sensor.hass_installed_version.state }}"

the order is done like this because if its ‘unavailable’, it will return false without evaluating the other and statements.

I’, using the template in the post above yours with Beta in " " and changed condition to and not instead of just and.

Using the template function in the dev tools this seems to return true or false correctly.

1 Like

I was looking for the same logic as your condition.

I can’t find the sensor sensor.hass_current_version and sensor.hass_installed_version in my Hassio- instalation.
Any idea if Hassio has some similar sensor hidden in the system?

In think you can use a command line sensor to get hassio ha info

Pretty sure he is using this component:

I don’t use it but it appears to add the entities that @DavidFW1960 is talking about.

1 Like

Thanks! : D

  - platform: version
    name: HA Current Version

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

The automation:

  trigger:
    platform: state
    entity_id: sensor.ha_upstream
  condition:
    condition: template
    value_template: "{{ states.sensor.ha_current_version.state != states.sensor.ha_upstream.state and 
                        states.sensor.ha_current_version.state != 'unavailable' and 
                        'b' in states.sensor.sensor.ha_upstream != true }}"

I’m using these defined in configuration.yaml to ‘create’ the sensors.

# Version and Availability
  - platform: rest
    resource: https://raw.githubusercontent.com/home-assistant/hassio/dev/version.json
    name: Hass Current Version
    value_template: '{{ value_json.homeassistant }}'

  - platform: version
    name: Hass Installed Version

  - 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 and states.sensor.hass_current_version.state != "unavailable"-%}
             Yes
          {%- else -%}
             No
          {%- endif -%}
        icon_template: >-
          {%- if states.sensor.hass_current_version.state != states.sensor.hass_installed_version.state and states.sensor.hass_current_version.state != "unavailable"-%}
            mdi:alert-box
          {% else %}
            mdi:approval
          {% endif %}

And the above automation for the notifications.

Sorry I was a bit cryptic!

2 Likes