Hi all,
I have a problem with a binary sensor which I can’t get to work.
My heatpump has some digital outputs where it reports the status of its pumps.
It is either 1 or 0.
If I set it up as rest sensor it works perfectly, but I don’t get the benefits of binary_sensor.
sensor
- platform: rest
name: Zusatzumwälzpumpe
resource_template: http://192.168.0.27/usr-cgi/xml.cgi?D|49|49
scan_interval: 60
value_template: "{{ value_json.PCOWEB.PCO.DIGITAL.VARIABLE.VALUE }}"
This is the debug log for the rest data:
2022-09-21 11:02:26.683 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.0.27/usr-cgi/xml.cgi?D|49|49
2022-09-21 11:02:27.241 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <PCOWEB>
<PCO>
<DIGITAL>
<VARIABLE>
<INDEX>49</INDEX>
<VALUE>0</VALUE>
</VARIABLE>
</DIGITAL>
</PCO>
</PCOWEB>
2022-09-21 11:02:27.242 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"PCOWEB":{"PCO":{"DIGITAL":{"VARIABLE":{"INDEX":"49","VALUE":"0"}}}}}
But when I set it up as restful binary_sensor, like described here:
binary_sensor:
- platform: rest
name: Zusatzumwälzpumpe
resource_template: http://192.168.0.27/usr-cgi/xml.cgi?D|49|49
scan_interval: 60
value_template: "{{ value_json.PCOWEB.PCO.DIGITAL.VARIABLE.VALUE }}"
I get the following error and I don’t understand why.
2022-09-21 11:12:12.143 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.rest
2022-09-21 11:12:12.183 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.0.27/usr-cgi/xml.cgi?D|49|49
2022-09-21 11:12:12.872 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'value_json' is undefined when rendering '{{ value_json.PCOWEB.PCO.DIGITAL.VARIABLE.VALUE }}'
Why is it not working?
Has anyone an idea what I’m doing wrong?