I’m unclear on how to use the availability variable when using the RESTful Sensor. I’ve read through the doc page, but there are no examples and what I’ve found here so far does not definitively tell me how to use it.
I’m either over thinking it or just missing it. Ultimately, I’m wondering if it is something that can help me tell my template sensors to not update if the payload is not there or malformed, or if that JSON part is missing.
I’m not sure but there is a plethora of info on the subject here. Look at the more recent ones first.
Try to put this search term in your search engine:
I have issue where my rest sensor doesnt receive data and it goes unavailable, but i want that to go 0 instead.
How can i make that happen, it worked in template editor but not when put into sensor.
I have tried that, it works in template editor but not in yaml.
But i spot small differense, could that make that… I used {{ 0 }} instead of 0, like this.
value_template: >
{% if value_json.DEVS[0]['MHS 5s'] is defined %}
{{ value_json.DEVS[0]['MHS 5s'] }}
{% else %}
{{ 0 }}
{% endif %}
WARNING (MainThread) [homeassistant.components.rest.util] Empty reply found when expecting JSON data
ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.0.46/cgi-bin/api.py failed with All connection attempts failed
Ok so it’s not even getting to the value_template because it cant reach the resource. Not sure there is anything you can do about that, other than work out why http://192.168.0.46/cgi-bin/api.py was offline.
What im trying to do, is access file that has same JSON message, now with zero values, but now im facing new problem… WARNING (MainThread) [homeassistant.components.rest.util] REST result could not be parsed as JSON
I get this error, i have tested this JSON message with two JSON validator, but problem seems to be that that file can not be accessed.
Im trying to access file inside HA, how i can make this work.
I tried that also, but now i got it, it was just to change POST to GET
Also my address was wrong, i had file in /config/www/ and that can be accessed with /local/, atleast that way i did see file with my browser.
And im getting error and sensor goes unavailable WARNING (MainThread) [homeassistant.components.rest.util] Empty reply found when expecting JSON data
If i look into History, it clearly shows that there is first message and then two empty messages and fourt has data again.
Why im getting unavailable, even i have is defined and this.state ??