Help with mobile notifications

Hi Guys
Can anyone point me at what i should use to create notification with a snapshot when my gate opens.
I have a gate contact sensor (binary_sensor.gate) and a camera already integrated into HA (camera.front_camera) and i’m wanting a notification sent from the HA app with a still image of the camera when the gate opens.
I’ve tried editing other peoples examples but i;m not getting anywhere with it.
Any help appreciated
Thanks

Show what you have so far

Does it need to be node-red?

Got some good experiences with 📸 Send camera snapshot notification on motion
(guess you can modify it for your own needs, using the gate as trigger instead of motion :wink:)

This is one of them

[{"id":"a96192b4.2bac3","type":"api-call-service","z":"5cf46ea5.05dcc","name":"Take snapshot","server":"8a3231e1.3f0e1","version":3,"debugenabled":true,"service_domain":"camera","service":"snapshot","entityId":"camera.front_camera","data":"{\"filename\":\"/config/www/image/snapshots/{{filename}}.jpg\"}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":250,"y":380,"wires":[["cf44700b.9a012"]]},{"id":"63912512.e8d06c","type":"api-call-service","z":"5cf46ea5.05dcc","name":"Send photo","server":"8a3231e1.3f0e1","version":3,"debugenabled":false,"service_domain":"notify","service":"mobile_app_steve_mobile","entityId":"","data":"{\"title\":\"Gate Opened\",\"message\":\"The front gate has opened\",\"data\":{\"image\":\"http://192.168.1.24/local/image/snapshots/{{filename}}.jpg\"}}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":740,"y":380,"wires":[[]]},{"id":"cf44700b.9a012","type":"delay","z":"5cf46ea5.05dcc","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":490,"y":380,"wires":[["63912512.e8d06c"]]},{"id":"993314b5.28ba48","type":"inject","z":"5cf46ea5.05dcc","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":80,"y":380,"wires":[["a96192b4.2bac3"]]},{"id":"8a3231e1.3f0e1","type":"server","name":"Hassio","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

It doesn’thave to be no i just find it easier to when organising.
I’ve actually tried that last week and modified the blueprint to a sensor but i couldn’t get that working either lol

I have 2 call service nodes with this data in each one and i do get a notification but not with the picture although the picture does get saved into the relevant folder

Hi guys i actually got it working all i had to do is delete the IP address and http:// from the 2nd call service node.
Could anyone say how i add a click action to the notification so when i click on the snapshot it takes me to the camera lovelace tab
cheers

Search node red actionable notification.

Add clickAction: path/to/dashboard after data:

Thanks managed to work it out eventually :slight_smile:
if anyone else is interested create 2 call service nodes , 1 to capture the and 1 to send the snapshot to my HA mobile app.
This is the code i used.
This one to capture and save the snapshot

{
    "filename": "/config/www/image/snapshots/{{filename}}.jpg"
}

and copy this into the JSON data to send the snaphot.

{
    "message": "The front gate has opened",
    "title": "Gate Opened",
    "data": {
        "image": "/local/image/snapshots/{{filename}}.jpg",
        "actions": [
            {
                "action": "URI",
                "title": "Open Camera",
                "uri": "/lovelace-mobile/cameras"
            }
        ]
    }
}

:+1: that gives you a button on the text, to click through to the page. Just for reference you can add up to 3 buttons and clickAction: will execute when pressing anywhere on the text message.

1 Like

Thanks changed to that instead i was using the buttons as i was hoping i could put 2 buttons one for each camera i have and then have the stream load for that camera when i click the button but i couldn’t find out if that’s possible.

Don’t know if you ever figured this out but this is what im using to have it open the companion app and then have it load the live stream for the camera

where topic is just the camera entity id (camera.thiscamerahere}

{
    "message": "motion detected on {{data.attributes.friendly_name}}",
    "title": "Automated Motion Alert!",
    "data": {
        "image": "/local/image/snapshots/{{data.attributes.friendly_name}}/alert.jpg",
        "actions": [
            {
                "action": "URI",
                "title": "Open Camera",
                "uri": "entityId:{{topic}}"
            }
        ]
    }
}
1 Like

Hi, could you please share more detail on how you have done this? I am starting oit in HA and node red and this is one of the first things I’d like to tackle but I don’t fully follow the above conversation on the two service nodes and how to tie it all together, what the {{ }} variables are, etc.

Hi yeah ill find the code what is it you’re are wanting to do ?
you don’t have to use the variables above that’s mainly if names change etc that will display the friendly name no matter what you change it to etc…
You want to start off with a
state node - and set it to a trigger (like motion detected etc)
Call service node - use this to take the snapshot (still image ) of the camera
delay node - i use this to give the image enough to actually save on the system before you try sending.
call service node again - use this to send to snapshop you saved before.
in the final call service node on the data box click the drop down arrow and make sure Json is selected then the 3 dots and paste in the code above and save.

Great, thank you, I got this working.

1 Like