Trouble returning Foscam camera motion detect state

I was just rtying to help another user a few days ago that was trying to extract a valu from a command_line sensor and we could never get the “grep” command to work while it was embedded in the curl command line.

They were using hassio while i am using HA in Docker but non-hassio. So there may be something screwy in the way grep is used in hassio that doesn’t quite work correctly. But it works fine in my set up and I’m successfully using pretty much the exact command as you for my Foscam camera’s to check the status of motion enabled and mine is working perfectly fine.

I think the bottom line for that discussion was to use the “regex_findall_index” filter.

So I think based on that the following should get you what you want:

switches: 
  foscam_motion: 
    command_on: 'curl -k "http://yourip:88/cgi-bin/CGIProxy.fcgi?usr=username&pwd=password&cmd=setMotionDetectConfig&isEnable=1" ' 
    command_off: 'curl -k "http://yourip:88/cgi-bin/CGIProxy.fcgi?usr=username&pwd=password&cmd=setMotionDetectConfig&isEnable=0" '
    command_state: 'curl -k --silent "http://yourip:88/cgi-bin/CGIProxy.fcgi?usr=username&pwd=password&cmd=getMotionDetectConfig" '
    value_template: "{{ value | regex_findall_index('<isEnable>(.*)</isEnable>') == '1' }}"