Use JSON output as value_template compare

Hi All,

I have some rest sensors like this:

- platform: rest
  resource: !secret supervisor_addon_1
  name: "Adguard Version Update"
  value_template: "{{ value_json.data.state }}"
  scan_interval: 14400
  headers:
    Authorization: !secret longlifetoken
    Content-Type: application/json
  json_attributes_path: "$.data"
  json_attributes:
    - version
    - version_latest

Will it be possible to change the value_template to something like this:

{% if is_state(version < version_latest) %} on
{% else %} off
{% endif %}

When the current version is lower then the latest one, the sensor will be ON
With this state you can create other automations around it.

Cheers,

I think I have any solution. Will try this and see if this will work:

"{{ state_attr('sensor.mailserver_version_update','version') < state_attr('sensor.mailserver_version_update','version_latest')  }}"

p.s. it is not working :frowning: grrr

I doubt this will work. The version numbering system is not a number. e.g. v3.0.0 is not a number and therefore you can not use the number comparison operations < or >. Best you can do is compare strings (== or !=) unless you come up with some way of converting the version to a number (the filters |int and |float will not work).

With != the line is working

"{{ state_attr('sensor.version_update_adguard','version') != state_attr('sensor.version_update_adguard','version_latest')  }}"