Hello world. With a rest: statement I read data from a resource that responds with json output. In fact that is my old Homewizard hardware with loads of sensors, that I want to integratie in HA. This hardware is connected to the LAN via Wifi only.
I do that every 6 seconds and all my sensors get the proper values. So far so good.
However sometimes (a couple of times per day, probably because of the wifi connection) there apparently is no response. I notice that in the logs of each sensor there appears a “became unavailable”. 6 seconds later the info comes in again.
I would like to detect in the value_json if the data is unavailable. If true I would like to skip that sequence in order to avoid “became unavailable” in the logs.
I tried several examples to detect this but I fail to get it working. Below I check if value_json is defined (one of the examples/solutions I found). This still shows “data not available” in the log. I also saw other examples testing for unavailable, unknown, etc, but I fail to get it working.
Can anyone help me here? Maybe I am close to the solution but I just don’t see/get it
rest:
- resource: http://IP/PW/get-status
scan_interval: 6
timeout: 4
binary_sensor:
- name: Backdoor
unique_id: backdoor
value_template: >-
{% if value_json is defined %}
{{ value_json.response.kakusensors[4].status == 'yes' }}
{% endif %}