Here’s a video of it in action…
Thanks for sharing.
I’ll look into it, I like the idea of showing triggered cameras.
Great idea! I didn’t write it though, @lukevink did.
I’ve never published to HACS but after looking at the docs it seems like very little would be needed. In fact, I think only hacs.json
needs to be added:
{
"name": "Custom iFrame card",
"content_in_root": true,
"filename": "custom-iframe-card.js",
"render_readme": true
}
Do you have any insight, @sparkydave?
Sorry, I haven’t done such a thing so can’t help
Hello again,
can you share your hode-red automation to popup the image for a triggered motion camera.
thanks for your help.
Mine was pretty complex and wouldn’t match your configuration, but here’s a basic flow that you should be able to build on:
[{"id":"ed2223e.93199e","type":"server-state-changed","z":"96e6770e.107828","name":"Courtyard Motion","server":"e9beaddb.fc24e","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.motion_courtyard","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":140,"y":120,"wires":[["41214db2.e987e4"]]},{"id":"41214db2.e987e4","type":"switch","z":"96e6770e.107828","name":"on / off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":120,"wires":[["d75c1931.874688"],["22b17b6a.761844"]]},{"id":"d75c1931.874688","type":"change","z":"96e6770e.107828","name":"view_path: courtyard_camera","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"view_path\":\"\"}}","tot":"json"},{"t":"set","p":"payload.data.view_path","pt":"msg","to":"courtyard_camera","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":80,"wires":[["178dabc5.a9d914"]],"info":" - Change `msg.data.new_state.entity_id` from `input_select.${camera_short_name}_cast` to `${camera_short_name}_feed`\n - Move `msg.data.new_state.entity_id` to `payload.data.view_path`"},{"id":"22b17b6a.761844","type":"change","z":"96e6770e.107828","name":"view_path: dashboard","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"view_path\":\"\"}}","tot":"json"},{"t":"set","p":"payload.data.view_path","pt":"msg","to":"dashboard","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":160,"wires":[["178dabc5.a9d914"]],"info":" - Change `msg.data.new_state.entity_id` from `input_select.${camera_short_name}_cast` to `${camera_short_name}_feed`\n - Move `msg.data.new_state.entity_id` to `payload.data.view_path`"},{"id":"178dabc5.a9d914","type":"api-call-service","z":"96e6770e.107828","name":"Living Area Hub","server":"e9beaddb.fc24e","version":1,"debugenabled":false,"service_domain":"cast","service":"show_lovelace_view","entityId":"media_player.living_area_hub","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":840,"y":120,"wires":[[]]},{"id":"e9beaddb.fc24e","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
Or…
This has the same functionality with a smaller footprint:
[{"id":"acad3577.b332a8","type":"server-state-changed","z":"96e6770e.107828","name":"Courtyard Motion","server":"e9beaddb.fc24e","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.motion_courtyard","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":240,"y":300,"wires":[["f7489dfd.58b0f"]]},{"id":"f7489dfd.58b0f","type":"change","z":"96e6770e.107828","name":"Syntax: view_path","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"view_path\":\"\"}}","tot":"json"},{"t":"move","p":"payload","pt":"msg","to":"payload.data.view_path","tot":"msg"},{"t":"change","p":"payload.data.view_path","pt":"msg","from":"on","fromt":"str","to":"courtyard_camera","tot":"str"},{"t":"change","p":"payload.data.view_path","pt":"msg","from":"off","fromt":"str","to":"dashboard","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":300,"wires":[["642cd823.4a0648"]],"info":" - Change `msg.data.new_state.entity_id` from `input_select.${camera_short_name}_cast` to `${camera_short_name}_feed`\n - Move `msg.data.new_state.entity_id` to `payload.data.view_path`"},{"id":"642cd823.4a0648","type":"api-call-service","z":"96e6770e.107828","name":"Living Area Hub","server":"e9beaddb.fc24e","version":1,"debugenabled":false,"service_domain":"cast","service":"show_lovelace_view","entityId":"media_player.living_area_hub","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":700,"y":300,"wires":[[]]},{"id":"e9beaddb.fc24e","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
You’ll need to have node-red-contrib-home-assistant-websocket installed and configured, and have camera/motion sensors configured in HA (or alternatively, use http in
nodes).
I also had switches configured to prevent casting based on various criteria (presence detection, other media already being cast, etc.), and I had a ‘timeout’ configured in case the motion off
signal wasn’t received. Let me know if this helps and I can post any of those too if you’re interested.
Thanks, that’s really helpful, and I think I got the idea how it works.
I have wyze cameras integrated in motioneye, and motioneye does the motion detection and the recording (it works very well). I have to figure out how to integrate this as a binary sensor in home assistant so I can trigger the camera view.
I’m not too familiar with Motioneye but it may be easier to have your motion trigger sent to NR, then (if needed) to an input_boolean
in HA:
[{"id":"7bfcf0d5.b9e02","type":"http in","z":"43d5ef6e.4b6a9","name":"","url":"/courtyard_camera","method":"post","upload":false,"swaggerDoc":"","x":170,"y":80,"wires":[["230812e0.66a52e","efff12ab.54db4","f9ac8bcc.6d82e8"]]},{"id":"230812e0.66a52e","type":"change","z":"43d5ef6e.4b6a9","name":"Syntax: view_path","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"view_path\":\"\"}}","tot":"json"},{"t":"move","p":"payload","pt":"msg","to":"payload.data.view_path","tot":"msg"},{"t":"change","p":"payload.data.view_path","pt":"msg","from":"on","fromt":"str","to":"courtyard_camera","tot":"str"},{"t":"change","p":"payload.data.view_path","pt":"msg","from":"off","fromt":"str","to":"dashboard","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":80,"wires":[["d0c7c4bd.11b7b8"]],"info":" - Change `msg.data.new_state.entity_id` from `input_select.${camera_short_name}_cast` to `${camera_short_name}_feed`\n - Move `msg.data.new_state.entity_id` to `payload.data.view_path`"},{"id":"efff12ab.54db4","type":"http response","z":"43d5ef6e.4b6a9","name":"","statusCode":"","headers":{},"x":230,"y":140,"wires":[]},{"id":"f9ac8bcc.6d82e8","type":"mapper","z":"43d5ef6e.4b6a9","name":"Toggle","property":"payload","map":[{"search":"on","replace":"{\"service\":\"turn_on\"}"},{"search":"off","replace":"{\"service\":\"turn_off\"}"}],"passthrough":false,"x":470,"y":140,"wires":[["f2b9be8b.676c2"]]},{"id":"d0c7c4bd.11b7b8","type":"api-call-service","z":"43d5ef6e.4b6a9","name":"Living Area Hub","server":"e9beaddb.fc24e","version":1,"debugenabled":false,"service_domain":"cast","service":"show_lovelace_view","entityId":"media_player.living_area_hub","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":680,"y":80,"wires":[[]]},{"id":"f2b9be8b.676c2","type":"api-call-service","z":"43d5ef6e.4b6a9","name":"Courtyard Motion","server":"e9beaddb.fc24e","version":1,"debugenabled":false,"service_domain":"input_boolean","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":670,"y":140,"wires":[[]]},{"id":"e9beaddb.fc24e","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
Motioneye would be configured to ‘Call A Web Hook’, and the ‘Web Hook URL’ would be the IP/Port for NR followed by the path you put in URL
field of the http in
node (eg: 192.168.1.100:1880/courtyard_camera
). I’m not sure what the payload
from Motioneye would look like or if it sends a second off
payload, but a Debug node should give some more direction.
Are you running Dafang-Hacks firmware on your Wyze Cams?
On wyze cams I have the RTSP firmware:
I have to check the Dafang-Hacks to see if is any different.
I know motioneye can ‘call a web hook’ but I didn’t knew how works, I have to try it.
Thanks again for your help.
I just read thru the Dafang-Hacks , and is really interesting what can do …
I will give it a try.
Hi,
do you know witch of the http method can I use for the call?
I would assume json but I’m not sure what the others do.
It won’t hurt anything to try them all, just attach a Debug node to the http in
node to see the output.
In the previous image you have /notifycam2
as the path instead of /endpoint/notifycam2
…?
Thanks, now I’m getting a call, but the payload is empty.
I get it work by running a command to mosquitto … just have to create a binary sensor for it to trigger the NR automation.
Run A Command
mosquitto_pub -h 172.16.10.12 -t cam2/motion -m ON
Run An End Command
mosquitto_pub -h 172.16.10.12 -t cam2/motion -m OFF
Hmm, it’s weird that the payload is empty. NR might be be parsing the JSON so that the output ends up somewhere besides msg.payload
. How are you confirming that you’re getting a call?
If you change the Output option of your Debug node to complete msg object
you should get msg.req
(request) and msg.res
(response) in your output, along with whatever JSON is parsed. msg.req.body
will show the entire body of the message sent from Motioneye.
I’m getting the calls as I can see on the debug area.I did the changes to see the msg object, but I can’t see any msg info that toggles to the motion status.
Thanks again for your help.
Without access to the Motioneye interface I’m kind of ‘flying blind’, but I’m guessing the interface is pretty rudimentary and may not offer any other fields or options to define the payload.
Try adding some parameters to the end of your URL in Motioneye. eg: If you currently have, http://172.16.10.12:1880/endpoint/notifycam2
, add ?test=1
to make it, http://172.16.10.12:1880/endpoint/notifycam2?test=1
.
Hopefully NR will receive msg.payload.test
(or possibly msg.test
) with a value of 1
.