I’ve got a strange issue but am sure it’s because of my lack of experience with Jinja2.
Goal: check if I’m running the current version of NC.
Therefor I have two sensors, sensor.ncver with the current version of nextcloud:production-fpm available on docker hub (currently 23.0.5) and sensor.nextcloud_json.attributes.nextcloud.system.version with the version I’m running (currently 23.0.5.1).
Problem (checked in Developer Tools / Template): {{states('sensor.ncver') in states('sensor.nextcloud_json.attributes.nextcloud.system.version')}} results in False, which I deem wrong because {{'23.0.5' in '23.0.5.1'}} is True.
Thank you Taras, that did the trick.
I tried state_attr('sensor.nextcloud_json','nextcloud.system.version') within the template playground but it errors out with TypeError: argument of type 'NoneType' is not iterable.
Never thought of attaching it after the function, though. state_attr('sensor.nextcloud_json','nextcloud')['system']['version'] works too, btw.
Yes, that’s called “bracket notation” and the other one is “dot notation”. You can use one or the other, even a mix of both. However, use bracket notation if the word begins with a number. Reference: Entity ID begins with a number