Simplistic LUMIX Camera control

very simplistic Panasonic LUMIX camera control.

Commands are simple over HTTP GET, as described here https://github.com/fibasile/lx100-api/blob/master/docs/commands.md This flow presents two inject nodes, one to take a photo, and one to start 30s of video. The payload is immaterial, so these could be replaced with MQTT nodes, or any other mechanism of trigger. I'm going to trigger from a PIR sensor :).

It notes the time of the last camera command, and if no further commands are received within 30s, switches the camera to 'play' mode (so closing the lens).

For my Lumix DMC-TZ60, I can attach it to my home wifi, and give it a name of 'LUMIX', so providing a simple way to send commands to it.

[{"id":"48ef7c6f.5781d4","type":"http request","z":"e5a3d346.f94bd","name":"request recmode","method":"GET","ret":"txt","url":"http://LUMIX/cam.cgi?mode=camcmd&value=recmode","tls":"","x":354,"y":155,"wires":[["2cde2745.5f6e48","4fc436da.6959e8"]]},{"id":"e64e4c6.fa1d3b","type":"inject","z":"e5a3d346.f94bd","name":"PHOTO","topic":"","payload":"PHOTO","payloadType":"str","repeat":"","crontab":"","once":false,"x":122,"y":154,"wires":[["48ef7c6f.5781d4"]]},{"id":"2cde2745.5f6e48","type":"debug","z":"e5a3d346.f94bd","name":"","active":true,"console":"false","complete":"false","x":922,"y":178,"wires":[]},{"id":"e3c09c7d.2a515","type":"http request","z":"e5a3d346.f94bd","name":"take photo","method":"GET","ret":"txt","url":"http://LUMIX/cam.cgi?mode=camcmd&value=capture","tls":"","x":372,"y":235,"wires":[["2cde2745.5f6e48","ab785bfa.45d118"]]},{"id":"4fc436da.6959e8","type":"change","z":"e5a3d346.f94bd","name":"clear payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":193,"wires":[["e3c09c7d.2a515"]]},{"id":"f3bdb30a.4505e","type":"http request","z":"e5a3d346.f94bd","name":"request recmode","method":"GET","ret":"txt","url":"http://LUMIX/cam.cgi?mode=camcmd&value=recmode","tls":"","x":355,"y":355,"wires":[["11eb56bf.f7c419","b81b81ad.deb1e"]]},{"id":"6bcf5322.ab358c","type":"inject","z":"e5a3d346.f94bd","name":"VIDEO","topic":"","payload":"VIDEO","payloadType":"str","repeat":"","crontab":"","once":false,"x":128,"y":311,"wires":[["5ccfc7a.582cb38"]]},{"id":"11eb56bf.f7c419","type":"debug","z":"e5a3d346.f94bd","name":"","active":true,"console":"false","complete":"false","x":950,"y":431,"wires":[]},{"id":"ffa720b6.8e34a","type":"http request","z":"e5a3d346.f94bd","name":"start video","method":"GET","ret":"txt","url":"http://LUMIX/cam.cgi?mode=camcmd&value=video_recstart","tls":"","x":400,"y":488,"wires":[["11eb56bf.f7c419","a9c5453b.d2d318"]]},{"id":"ef986df7.82082","type":"change","z":"e5a3d346.f94bd","name":"clear payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":344,"y":426,"wires":[["ffa720b6.8e34a"]]},{"id":"f51157ed.097de8","type":"http request","z":"e5a3d346.f94bd","name":"stop video","method":"GET","ret":"txt","url":"http://LUMIX/cam.cgi?mode=camcmd&value=video_recstop","tls":"","x":399,"y":594,"wires":[["11eb56bf.f7c419","ab785bfa.45d118"]]},{"id":"a9c5453b.d2d318","type":"change","z":"e5a3d346.f94bd","name":"clear payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":411,"y":522,"wires":[["e2b0a622.51de38"]]},{"id":"e2b0a622.51de38","type":"delay","z":"e5a3d346.f94bd","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":400,"y":558,"wires":[["f51157ed.097de8"]]},{"id":"3bcd614a.351cbe","type":"http request","z":"e5a3d346.f94bd","name":"request playmode (close lens)","method":"GET","ret":"txt","url":"http://LUMIX/cam.cgi?mode=camcmd&value=playmode","tls":"","x":940,"y":347,"wires":[["11eb56bf.f7c419"]]},{"id":"5ccfc7a.582cb38","type":"change","z":"e5a3d346.f94bd","name":"clear payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":345,"y":317,"wires":[["f3bdb30a.4505e"]]},{"id":"b81b81ad.deb1e","type":"delay","z":"e5a3d346.f94bd","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":325,"y":392,"wires":[["ef986df7.82082"]]},{"id":"ab785bfa.45d118","type":"function","z":"e5a3d346.f94bd","name":"note last cmd time","func":"var now = new Date();\n\n\nif (msg.topic === 'poll'){\n    then = flow.get(\"lastcameracommand\") || 0;\n    if (then){\n        var togo = (30000 + then.valueOf()) - msg.payload;\n        if (togo <= 0){\n            node.warn(\"closing lens\");\n            msg.payload = '';\n            flow.set(\"lastcameracommand\", 0);\n            // trigger close of lens\n            return msg;    \n        } else {\n            node.warn(\"togo \" + togo);\n        }\n    }\n} else {\n    flow.set(\"lastcameracommand\", now);\n}\n\nreturn null;\n","outputs":1,"noerr":0,"x":892,"y":303,"wires":[["3bcd614a.351cbe"]]},{"id":"75384b04.41a6f4","type":"inject","z":"e5a3d346.f94bd","name":"","topic":"poll","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"x":714,"y":240,"wires":[["ab785bfa.45d118"]]}]

Flow Info

Created 7 years, 9 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x4)
  • debug (x2)
  • delay (x2)
  • function (x1)
  • http request (x6)
  • inject (x3)

Tags

  • Panasonic
  • lumix
  • camera
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option