Hello everyone,
When I configured a sensor to detect motion it works perfect like this:
# Camera motion detection
command_line:
- sensor:
name: "Motion Detection Foscam"
unique_id: "Motion_Detection_Foscam"
command: curl -k --silent "http://192.168.2.32:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=zuidervos&pwd=xxx"
value_template: >
{% set status = value | regex_findall_index('Alarm>(\d+)</motion') %}
{% set values = {'0':'Disabled', '1':'Clear', '2':'Detected'} %}
{{ values[status] if status in values.keys() else 'Not Determined'}}
scan_interval: 5
But since the blueprint I want to use uses a binary_sensor, I tried to set it up like this:
# Camera motion detection
command_line:
- binary_sensor:
name: "Motion Detection Foscam"
unique_id: "Motion_Detection_Foscam"
command: curl -k --silent "http://192.168.2.32:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=zuidervos&pwd=xxx"
value_template: >
{% set status = value | regex_findall_index('Alarm>(\d+)</motion') %}
{% set values = {'0':'Disabled', '1':'off', '2':'on'} %}
{{ values[status] if status in values.keys() else 'Not Determined'}}
scan_interval: 5
device_class: motion
This gives me a permanently "unknown’’ status, which should be the binary “off” . I am a bit new to this, so I am unsure if I used these values correctly or if there is another format I need to use. Can anyone help me with this?
Thank you for helping. I did put the password back in. This is what the output looks like and the highlighted 1 does become a 2 when motion is triggered:
I do know that my previous sensor code definitely worked for a normal sensor and it set the correct “Clear” and “Detected” values when triggered. The problem I’m facing is that I do not know the syntax for assigning a “true” or “false” value to the binary sensor:
{% set values = {'0':'Disabled', '1':'off', '2':'on'} %}