Camera motion detection to trigger device (IMOU) Topic is solved

Moderator: leecollings

User avatar
jvdz
Posts: 2206
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Camera motion detection to trigger device (IMOU)

Post by jvdz »

Ah that "invalid properties" error is something that needs to be solved before you publish your flow!
I don't see that in my flow, so please post the exact content of the js code in that formula object so I can check if there is anything obvious.

PS: You can also send info in PM in case you don't want to publicly share stuff and put it info a file to save all the back-out work. ;)
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Camera motion detection to trigger device (IMOU)

Post by QNTL »

The code in the function node is uneddited from the export you've shared:

Code: Select all

//  Build Domoticz MQTT message when motionAlarm
msgd = null;
if (msg.payload.labelType == "motionAlarm" ) {
	// {"command": "switchlight", "idx": 236, "switchcmd": "On" }
	msgd = {};
	msgd.payload = {};
	msgd.payload.command = 'switchlight';
	msgd.payload.idx = 236;
	msgd.payload.switchcmd = 'On';
}
// Return OK for Web post request
msg.payload = "ok"; 
return [msg,msgd];
Should I have eddited something?
User avatar
jvdz
Posts: 2206
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Camera motion detection to trigger device (IMOU)

Post by jvdz »

QNTL wrote: Saturday 29 April 2023 10:33 Should I have eddited something?
Yea guess so as I've posted an update if to test for undefined, but I do not get any error when I cut&paste that code into a formula object, so don't understand why you do.

This is the changed version:

Code: Select all

//  Build Domoticz MQTT message when motionAlarm
msgd = null;
if (msg.payload.labelType !== undefined 
    && msg.payload.labelType == "motionAlarm" ) {
	// {"command": "switchlight", "idx": 236, "switchcmd": "On" }
	msgd = {};
	msgd.payload = {};
	msgd.payload.command = 'switchlight';
	msgd.payload.idx = 236;
	msgd.payload.switchcmd = 'On';
}
// Return OK for Web post request
msg.payload = "ok"; 
return [msg,msgd];
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Camera motion detection to trigger device (IMOU)

Post by QNTL »

I still have that error :(

But..
I've looked into another option.
Putting a switch node after the message.

where the property is 'msg.payload.labelType' == motionAlarm.
After that node i've made a http request, which is just a json call to my domoticzs server

Code: Select all

http://user:password@domoticzip:domoticzport/json.htm?type=command&param=switchlight&idx=236&switchcmd=On
This does the trick. The device is switched on when there is motion.
Is there a reason it would be better to do a mqtt out node, instead of a http request? Security? Usage without internet?
User avatar
jvdz
Posts: 2206
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Camera motion detection to trigger device (IMOU)

Post by jvdz »

Should work too! :)
QNTL wrote: Saturday 29 April 2023 11:30 Is there a reason it would be better to do a mqtt out node, instead of a http request? Security? Usage without internet?
Not really much difference really ... MQTT feels somewhat cleaner, but there are also advantages to use HTTP/JSON call like getting an update event via MQTT DOMOTICZ/OUT.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Camera motion detection to trigger device (IMOU)

Post by QNTL »

Great, Then I think the search is over.

What I have achieved:
My IMOU cam, sends a message to Node-Red.
Node-Red triggers a device in Domoticz.

When the device is triggered, I see it in the Domoticz log.
Also, when the device is triggered, it starts a script, making a video.
The video gets send through telegram, but only if within 30 seconds, someone presses my doorbell or opens my letterbox.

I was searching for a good zigbee powered outdoor motion sensor, to do the same, but now it is within my camera.
Joy o Joy.

Thanks for anyone helping.
Especially jvdz :mrgreen:
User avatar
jvdz
Posts: 2206
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Camera motion detection to trigger device (IMOU)

Post by jvdz »

You are welcome! :)

Question: What are you using to recording the video from the IMOU cam in batch?
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Camera motion detection to trigger device (IMOU)

Post by QNTL »

I'm just using the RTSP stream in combinatie with ffmpeg to make the videos.
I'll delete the file after 30 seconds or so.

It is a script to store the video in a direction on my pi.
I have it so, that if Video1.mp4 is already present in the folder, it automatically renamed the file to Video2.mp4 if the script runs before the first file gets deleted.

It probably won't happen, since I have the script tied to the motion sensor. IMOU doesn't trigger everytime there is motion, but rather when there has been no motion in the last minute. This would be another improvement. So that, if let says, a person's walks in the area but doesn't press my doorbell, then leaves, and someone within 1 minute enters and presses my doorbell, I'll only have the footage of the latter.

Now I'll have to make the video at least 60s. And there'd still be a chance I miss the one person pressing my bell. But I have another script that makes a snapshot opun pressing my doorbell. Sometimes it wasn't clear who it was, that is why I went this route of making a video when there is motion.

A long story. Did it answer your question? I can share the script when I'm back at my laptop of needed!
User avatar
jvdz
Posts: 2206
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Camera motion detection to trigger device (IMOU)

Post by jvdz »

Yes you did, thanks for the explanation. I am still hoping that one day somebody is able to break open there closed setup and we will be able to simply download the videos from the camera when they are saved. The capture info is already in the event message you get when I understand it correctly, so one would assume you should be able to download it like the app is capable of doing.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
QNTL
Posts: 59
Joined: Sunday 19 January 2020 11:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Camera motion detection to trigger device (IMOU)

Post by QNTL »

Maybe it is reserverd for those who have the IMOU cloud subscription?
But no, unfortunately it is just the RTSP stream..
lost
Posts: 643
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Camera motion detection to trigger device (IMOU)

Post by lost »

QNTL wrote: Saturday 29 April 2023 15:28 Maybe it is reserverd for those who have the IMOU cloud subscription?
Dahua's that are not branded Imou sends a text file with many lines with some capture info included (zone that triggered etc...) along their .dav video file (looks like a customized mp4 that VLC can now read). I don't use it as I already used photo captures before adding video (reason is dav files could not be read easily in the past+image captures resulting from internal cam motion detection are sent much sooner than videos that somehow gets merged till motion is detected during video setup time) so as any motion results in a photo capture I already have their nb!

Everything is sent by cam using ftp or even sftp and smb for recent devices (less than 3 years).
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests