The if statement in Jinja is comparable with the Python if statement. In the simplest form, you can use it to test if a variable is defined, not empty and not false
yes, the Jinja is correct then, but the value isnt. It just takes the value to the image construction, no matter if it exists or even is unknown. rendering in m_unknown.png, or m_madeup.png if I enter the state = madeup in the dev-states…
will have to check otherwise, the file sensor as you suggested.
or maybe have a conditional value_template for the state being in the list of possible defined zones.
thanks, but that’s the exact code I tested, it simply does not do a file check, it only checks the template and fills in the state.
thanks for your effort!
This won’t work btw. Because the image is defined in the line prior to it. Is defined checks to see if the object has been created. In the case that both of you are doing, the object is a string, and the string is your path. Therefore when executing, it will always be defined and it will always be true.
You need to implement the sensor @tom_l is referencing in order to use is defined.
correct, that’s what I tried to report back
since this sensor can only create states made of Zones I have defined, it shouldn’t be too insecure relying on those states, and add one for when it happens to be out of the zones, ie moving. Thats what I have done now, creating images with overlays for those states. It shows wonderfully . very cool.
btw, id be interested to learn how the file sensor could check for file existence, thought it only would show a file size?
I mean, if the file doesn’t exist, what does the sensor do? I think the sensor wouldn’t be created, which is why @tom_l’s method would work. The sensor wouldn’t be created, so the ‘is defined’ method would work. Basically a poor mans way of checking if the file is there.
I was just wanting to see if you got this sorted out, as I am looking to do the same or something similar.
I was wanting to have the picture if it matches the place and if the picture exists, but if there was no such file/picture, then I would want it to default to a certain image.