Hello all!
I am quite new to the Hassio, but have been able to solve many problems already with existing resources. Now I am trying to get a binary sensor configured so that it would reflect the state of the infrared led on my Foscam camera. My configuration.yaml entry for this sensor is as follows:
binary_sensor:
- platform: command_line
name: IR Led State
command: 'curl -k --silent "https://192.168.10.59/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=user&pwd=password" | grep -oE "<infraLedState>.*</infraLedState>" | sed "s/\(<infraLedState>\|<\/infraLedState>\)//g" | tr -d "\n"'
value_template: '{{ value == "1" }}'
I used example here, but it didn’t work as such as Busybox does not have grep with option -P. So, to break the command down, it first gets XML state of the camera, then selects infraLedState with regex, then removes tags with sed and finally removes extra line ending sed produces with tr. The command works just fine when I ssh to my Hassio and run it from command line. But, no matter what I do, the state of “IR Led State” will always be off. I even went so far as to change template to:
value_template: '{{ value != "1" }}'
And it still remains off. There must be something with the templates that I am getting same off state whether I test {{ value == "1" }}
or {{ value != "1" }}
Any idea what I am missing here? I have no idea how I can debug the template part. Everything else was somehow testable on the system. I use the ‘States’ menu in ‘Developer tools’ part to see the state of the sensor.
I have Rasperry Pi 3B+ with 32bit with Home Assistant 0.92.2
Anyways, thanks in advance!