Home Assistant - Reolink Doorbell rich notification - Snapshot with timestamp + external link

Hello,

I have a Reolink Wifi Doorbell, works fine but the rich notification has a cloud platform fee.
So I decided to look for a solution and found one, but it has a flaw.

  1. Internet decided to cache the image, that means when doorbell makes a snapshot and overwrite the previous one, it shows the previous picture, that means if Friend A ringed at 10AM and Friend B rings at 11AM I still get the image of Friend A. :slight_smile:
  2. Someone mentioned that I could use ?i= in the external link, but sadly I have no idea how to put a random number there.
  3. The other and would be the best way to fix it, to make it use a timestamp like this: "YYYY.MM.DD - mm:ss", and as easy it seems I couldn't find a way how. Tried many ways and failed even more.

Can someone help my current flow to use timestamp on snapshot and the external link at the same time?

[{"id":"b83835ceaa08e8cc","type":"api-call-service","z":"b0334f5a6d891812","name":"Doorbell Snapshot","server":"f6a86a23.b6858","version":1,"debugenabled":false,"service_domain":"camera","service":"snapshot","entityId":"camera.doorbell_sub","data":"{\"filename\":\"/config/www/doorbell.jpg\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":490,"y":1300,"wires":[["d437d868d5f02bdb"]]},{"id":"0166a0488c01638c","type":"api-call-service","z":"b0334f5a6d891812","name":"Dani Csengő","server":"f6a86a23.b6858","version":1,"debugenabled":true,"service_domain":"notify","service":"mobile_app_m2102k1g","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":970,"y":1300,"wires":[[]]},{"id":"b25f8066f59ddfcb","type":"function","z":"b0334f5a6d891812","name":"Doorbell","func":"msg.payload = {\n    data: {\n        \"message\":\"Someone is ringing !\",\n        \"data\":\n            {\n            \"image\": \"https://inter.net/local/doorbell.jpg?i=<random>\",\n            \"channel\":\"Front Doorbell\",\n            \"priority\":\"high\",\n            \"ttl\": 0,\n            \"actions\":\n                [{\n                \"action\": \"URI\",\n                \"title\": \"Open Camera\",\n                    \"uri\": \"app://com.mcu.reolink\"\n                }]\n            }\n    }\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":800,"y":1300,"wires":[["0166a0488c01638c"]]},{"id":"ebf6961cd21e025a","type":"server-state-changed","z":"b0334f5a6d891812","name":"Doorbell Visitor","server":"f6a86a23.b6858","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.doorbell_visitor","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":230,"y":1330,"wires":[["b83835ceaa08e8cc"],[]]},{"id":"d437d868d5f02bdb","type":"stoptimer","z":"b0334f5a6d891812","duration":"1","units":"Second","payloadtype":"num","payloadval":"0","name":"1s","x":650,"y":1300,"wires":[["b25f8066f59ddfcb"],[]]},{"id":"f6419242b2bd1a3d","type":"inject","z":"b0334f5a6d891812","name":"Start","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":1280,"wires":[["b83835ceaa08e8cc"]]},{"id":"f6a86a23.b6858","type":"server","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

So this is really a hard thing to do :smiley:
In some ways it makes me happy that I'm not THAT dumb and it is not a 30 sec fix :wink:

Could also be that there are not too many having the same setup & combo like you; using HA, having a Reolink Doorbell and need to control it via NR

Try

msg.payload = {
    data: {
        "message":"Someone is ringing !",
        "data":
            {
            "image": "https://inter.net/local/doorbell.jpg?i=" + Math.random().toString().slice(2),
            "channel":"Front Doorbell",
            "priority":"high",
            "ttl": 0,
            "actions":
                [{
                "action": "URI",
                "title": "Open Camera",
                    "uri": "app://com.mcu.reolink"
                }]
            }
    }
}

return msg;

That should add a random number eg https://inter.net/local/doorbell.jpg?i=8445158252631018

Or for a unix timestamp in milliseconds you could use new Date().getTime()

Can not help with HA as not a user, sorry.

Well it is not depending on the hardware, Doing snapshot sending rich notification should work with all the devices, even with a security camera. :slight_smile:
The image caching is also independent from device.
I'm not using NVR, just a doorbell + Wifi router + HomeAssistant :slight_smile:

Thank you E1cid, found another way to save the snapshots, and with YOUR solution the rich notification works flawlessly! :smiley:

Thanks for the trip (and the proper syntax)!

1 Like

Can you share the solution?

It is a simple automation in Home Assistant.
Gave up the NodeRed solution, because it seemed impossible to do.

Put this in configuration.yaml

input_text:
  doorbell_timestamp:
    name: Doorbell Timestamp

And this to the automation.yaml


- id: doorbell_snapshot
  alias: Doorbell Snapshot
  trigger:
  - platform: state
    entity_id: binary_sensor.doorbell_visitor
    to: 'on'
  action:
  - service: input_text.set_value
    entity_id: input_text.doorbell_timestamp
    data:
      value: '{{ now().strftime("%Y%m%d_%H%M%S") }}'
  - service: camera.snapshot
    entity_id: camera.doorbell_main
    data:
      filename: /config/www/Snapshots/Doorbell_{{ states.input_text.doorbell_timestamp.state }}.jpg

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.