Take a snapshot from a ffmpeg camera

Is that any easy nice way in Node-Red to take a snapshot from my ffmpeg camera?

I have add so the camera show in Home Assistant (I can see it from lovelace) but after that I’m not sure.

There is a service called camera.snapshot, have you looked at it?

Thanks for the replay

Yes I have, but have no idea how to connect that to Node-RED.

Change the entity to your camera notify your phone. Also change the camera in the data portion.

[{"id":"369b3bc42a7cfbd4","type":"debug","z":"f80b6c338afd5483","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2030,"y":320,"wires":[]},{"id":"e3774f41205b8832","type":"api-call-service","z":"f80b6c338afd5483","name":"Notify Phone","server":"6b1110b5.183a4","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_pixel_3","areaId":[],"deviceId":[],"entityId":[],"data":"{\t   \"title\":\"Title\",\t   \"message\":\"message body\",\t   \"data\":{\t       \"image\": $entities('camera.g3_instant_high').attributes.entity_picture\t   }\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1770,"y":360,"wires":[["369b3bc42a7cfbd4"]]},{"id":"eee87d98697d1aa3","type":"inject","z":"f80b6c338afd5483","name":"","props":[{"p":"payload"},{"p":"entity_id","v":"light1","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"on","payloadType":"str","x":1570,"y":480,"wires":[["e3774f41205b8832"]]},{"id":"6b1110b5.183a4","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"30"}]

I use Pushbullet and when I edit your data code so it fit Pushbullet nothing happend.

{
“title”:“Testing”,
“message”:“Send a Pic”,
“data”:{
“file”: $entities(‘camera.kameraframsidan’).attributes.entity_picture
}
}

I think it have to take a snapshot from ffmpeg stream, save it local on the server and then send that picture with pushbullet.

I have this one:

[
    {
        "id": "f064b1c8.79676",
        "type": "api-call-service",
        "z": "d4d658ef.680968",
        "name": "Record 15s",
        "server": "5eeca57f.edcfdc",
        "version": 5,
        "debugenabled": false,
        "domain": "camera",
        "service": "record",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "camera.{{payload}}"
        ],
        "data": "{\"duration\": \"15\", \"entity_id\":\"camera.{{payload}}\",\"filename\":\"/config/www/images/camera/{{payload}}.mp4\"}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 650,
        "y": 80,
        "wires": [
            [
                "cc1ccf0a.c0f16"
            ]
        ]
    },
    {
        "id": "e17e11ae.d7f7a",
        "type": "inject",
        "z": "d4d658ef.680968",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 160,
        "y": 120,
        "wires": [
            [
                "e2677d76.e4bf"
            ]
        ]
    },
    {
        "id": "51e2d6d4.7f3d88",
        "type": "function",
        "z": "d4d658ef.680968",
        "name": "",
        "func": "msg.payload = \"voordeur_hd zijgevel_hd voortuin_hd\";\n\nvar outputMsgs = [];\nvar words = msg.payload.split(\" \");\nfor (var w in words) {\n    outputMsgs.push({payload:words[w],camera:words[w]});\n}\nreturn [ outputMsgs ];",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 460,
        "y": 80,
        "wires": [
            [
                "f064b1c8.79676",
                "d825a97.cd41958"
            ]
        ]
    },
    {
        "id": "cc1ccf0a.c0f16",
        "type": "delay",
        "z": "d4d658ef.680968",
        "name": "",
        "pauseType": "delay",
        "timeout": "40",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "outputs": 1,
        "x": 800,
        "y": 80,
        "wires": [
            [
                "76c6c166.f5ddb"
            ]
        ]
    },
    {
        "id": "76c6c166.f5ddb",
        "type": "api-call-service",
        "z": "d4d658ef.680968",
        "name": "Send to telegram",
        "server": "5eeca57f.edcfdc",
        "version": 5,
        "debugenabled": false,
        "domain": "notify",
        "service": "telegram_voordeur",
        "areaId": [],
        "deviceId": [],
        "entityId": [],
        "data": "{\"message\":\"Dummy\",\"data\":{\"video\":{\"file\":\"/config/www/images/camera/{{camera}}.mp4\",\"caption\":\"Opname van {{camera}}\",\"timeout\":180}}}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 970,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "940e4107.350de",
        "type": "link in",
        "z": "d4d658ef.680968",
        "name": "Snapshot camera's => Telegram",
        "links": [
            "94082261.9f664"
        ],
        "x": 195,
        "y": 60,
        "wires": [
            [
                "e2677d76.e4bf"
            ]
        ]
    },
    {
        "id": "d825a97.cd41958",
        "type": "api-call-service",
        "z": "d4d658ef.680968",
        "name": "Snapshot",
        "server": "5eeca57f.edcfdc",
        "version": 5,
        "debugenabled": false,
        "domain": "camera",
        "service": "snapshot",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "camera.{{payload}}"
        ],
        "data": "{\"filename\":\"/config/www/images/camera/{{payload}}.jpg\"}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 640,
        "y": 140,
        "wires": [
            [
                "d78e8772.226728"
            ]
        ]
    },
    {
        "id": "d78e8772.226728",
        "type": "delay",
        "z": "d4d658ef.680968",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "outputs": 1,
        "x": 800,
        "y": 140,
        "wires": [
            [
                "2ea83f6d.9dbde"
            ]
        ]
    },
    {
        "id": "2ea83f6d.9dbde",
        "type": "api-call-service",
        "z": "d4d658ef.680968",
        "name": "Send to telegram",
        "server": "5eeca57f.edcfdc",
        "version": 5,
        "debugenabled": false,
        "domain": "notify",
        "service": "telegram_voordeur",
        "areaId": [],
        "deviceId": [],
        "entityId": [],
        "data": "{\"message\":\"Dummy\",\"data\":{\"photo\":{\"file\":\"/config/www/images/camera/{{camera}}.jpg\",\"caption\":\"Snapshot van {{camera}}\"}}}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 970,
        "y": 140,
        "wires": [
            []
        ]
    },
    {
        "id": "e2677d76.e4bf",
        "type": "api-current-state",
        "z": "d4d658ef.680968",
        "name": "Thuis?",
        "server": "5eeca57f.edcfdc",
        "version": 3,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "input_boolean.thuisaanwezig",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [],
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "x": 310,
        "y": 100,
        "wires": [
            [
                "51e2d6d4.7f3d88"
            ],
            [
                "b3510ef9.fea81"
            ]
        ],
        "inputLabels": [
            "Afwezig triggered"
        ]
    },
    {
        "id": "b3510ef9.fea81",
        "type": "function",
        "z": "d4d658ef.680968",
        "name": "",
        "func": "msg.payload = \"voordeur_hd zijgevel_hd voortuin_hd achtergevel_hd\";\n\nvar outputMsgs = [];\nvar words = msg.payload.split(\" \");\nfor (var w in words) {\n    outputMsgs.push({payload:words[w],camera:words[w]});\n}\nreturn [ outputMsgs ];",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 460,
        "y": 140,
        "wires": [
            [
                "f064b1c8.79676",
                "d825a97.cd41958"
            ]
        ]
    },
    {
        "id": "5eeca57f.edcfdc",
        "type": "server",
        "name": "Home Assistant",
        "version": 2,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": 30
    }
]

You probably can find some inspiration in it, if questions, don’t hesitate

1 Like

Hi and thanks for the code
Not sure why because you code does look like my but yours is working :slight_smile:
So now I have got it to work so thanks alot for all the help guys.

1 Like

Is this a cut and paste from the node? The formatting is wrong so it definitely won’t work the way it is. If there is a red line around any box there is an error there.


try

{
   "title":"Title",
   "message":"message body",
   "data":{
       "file": $entities('camera.kameraframsidan').attributes.entity_picture
   }
}

I do not remember any red line, I have try alot of code over one day that I don’t remember :slight_smile:
But now it works and I’m very happy with that.