This worked, I think. I have the sensor now but I am away from home and cannot force motion.
Thank you, I will play with this!
This worked, I think. I have the sensor now but I am away from home and cannot force motion.
Thank you, I will play with this!
I don’t suppose you have ever done the same for Amcrest cameras? I saw the component but I have all my cameras ported through Zoneminder so I do not want to use the Amcrest component just to get motion.
The Foscam worked like a charm btw!
Unfortunately no. I don’t have any Amcrest cameras.
Hi,
Can someone explain to me how grep -oP "(?<=isEnable>).*?(?=</isEnable>)"'
and value_template: '{{ value == "1" }}'"
work?
I need to get the state of a PIR Sensor in a Hikvision camera who’s output looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<PIRAlarm version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema">
<enabled>true</enabled>
<name>PIR Alarm</name>
</PIRAlarm>
The status is “true” or “false” on the 3rd line of the output
You’ll probably have to change this to grep -oP "(?<=enabled>).*?(?=</enabled>)"
There is no need to template the value of the command when the value is true
or false
already, so just leave this bit out.
Nop, still not working.
The state line looks now like this:
command_state: 'curl -X GET http://user:pass@IP/ISAPI/WLAlarm/PIR | grep -oP "(?<=enabled>).*?(?=</enabled>)"'
and the HA switch state is frozen on “OFF” state
Anyone else noticed that the Blink motion sensing isn’t working?
Continuing the discussion from Cameras and Motion:
Hi, everybody. This is my first post, although I usually read this forum.
I’ve had the same problem and I’ve just found how I might to solve the problem.
In the recent versions, the command “grep -oP” don’t work. You must change this command to this other:
command_state: 'curl -k --silent "http://myip:88/cgi-bin/CGIProxy.fcgi?cmd=getMotionDetectConfig&usr=myusuer&pwd=mypass" | grep -E -o "<isEnable>(.*)</isEnable>" | sed -e "s,.*<isEnable>\([^<]*\)</isEnable>.*,\1,g"`'
value_template: '{{ value == "1" }}'`
I get my switch work well. And I hope that It will be useful for you.
Which “recent versions” are you referring to?
I found a similar problem on this topic
And I supposed that the problem that I had was the same.
When you execute the command “grep -oP” directly in the terminal SSH don`t work.
Those trying to get the Foscam motion sensor to work with hassio, hassio’s docker image does not support the “P” option used in the grep command.
changing it to something like:
command: 'curl -k --silent "https://ip:443/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=USER&pwd=PASSWORD" | grep motionDetectAlarm | cut -b 24'
Should bypass the issue.
For those gooogling. My solution (rather than polling) was to set up a FTP server in HASSIO. Have snapshots on motion sent to the FTP server and than watch the FTP directory for file writes. I am using node red to do the automation and it is pretty quick (normally file write starts < 1 sec from motion. See to be vworking for me. Seems better to me than polling but each has its pros and cons
HA 0.98 includes Minio support, allowing files to be Put to the server and events triggered
Great, seems like a great idea, looking forward to checking it out
I have a cheapy Vstarcam which uses the same API/Commands and from the command line I can get it to return a “0” or a “1” if motion is detected but when creating a command line binary sensor it never updates… also the returned value from command line comes up in red text which I thought was odd… was wondering if anyone can tell if I’m missing something simple…
- platform: command_line
name: Vstarcam Motion
command: 'curl -k --silent "http://192.168.1.XX:XXXX/get_status.cgi?user=XXXXX&pwd=XXXXXX" | grep -oP "(?<=alarm_status=).*?(?=;)"'
value_template: '{{ value == "1" }}'
I got it to work with a rest binary_sensor I found in another post, just wanted to post it for anyone else looking in the future… thanks. (Would still appreciate if anyone knows why the command_line sensor didn’t work)
- platform: rest
name: "Vstarcam Motion"
resource: http://192.168.1.XX:XXXX/get_status.cgi?user=XXXXX&pwd=XXXXXX
device_class: motion
scan_interval: 2
value_template: >-
{%- if "alarm_status=1" in value -%}
{{ true }}
{%- else -%}
{{ false }}
{%- endif -%}
Never updates, or always shows no motion ?
Unless you set scan_interval:
it defaults to 60 second updates.
I’ve set mine at 5 seconds.
I’ll have to try again, I did set a scan interval but not until a time I had also changed the value template to be more like the “rest” one… so maybe the value template change broke it enough that the scan interval didn’t matter…
So I just tried the command line sensor again with the scan interval set to 3 seconds (same as current rest sensor) and the rest sensor shows motion and binary sensor shows nothing, no errors in log…
I don’t use a binary_sensor. I use a regular sensor since it’s possible to have other values get returned.
But here’s an example of my sensor:
sensor:
- platform: command_line
name: "Kitchen Camera Motion"
command: curl -k --silent "http://192.168.1.51:8001/get_status.cgi?user=xxxx&pwd=yyyyyyyy"
value_template: >-
{% set status = value | regex_findall_index('alarm_status=(\d+);') %}
{%- if status == "0" -%}
None
{%- elif status == "1" -%}
Detected
{% else %}
Not Determined
{%- endif -%}
scan_interval: 3