Hi!
I want to send an image along with my temperature readings from a sensor to my iPhone as a notification. It seems to work alright when I hardcode the url, but since its symbol can wary I wanted to do some if, else statement. (The best option would be if I could send the sensor.yr_symbol state directly into the url, but that doesn’t seems to work either.)
Her is my try that still sends the temperature readings correct to my phone but the image attachment is missing. I even put en else at the bottom but it didn’t pick that last url either.
It seems there is two problems here. The first you pointed out, I do need to use data_template.
But having everything on several rows does not seem to work for a reason. Pasting everything on one line fixes the problem.
I suppose it is a problem with indentation or something when having it on several rows.
I’ve got several places that I use similarly coded templates and they always work fine if I indent them a couple of spaces if for no other reason than easier readability.
For example, the following works fine:
value_template: >
{% if value_json is defined and value_json.zones.INZ009 is defined %}
{{ value_json.zones.INZ009 }}
{% elif value_json is defined and value_json.zones.INC033 is defined %}
{{ value_json.zones.INC033 }}
{% else %}
0
{% endif %}
I noticed you dropped the quotation marks on your last example. If that works then maybe that was the problem.