Hi all.
I have been searching around, but I’m a bit confused on whether I should create a blueprint for this, a template, a script, or something else. I understand HA is rapidly evolving and so 2 year old posts may not reflect the current state of things, so I’d appreciate a little bit of guidance.
In summary, I have 5 reolink cameras, and I have set up an automation for each of them that does exactly the same thing: after detecting a person, it will notify me through the Android app, and optionally turn on the floodlight if it’s dark. Each automation uses the entities, triggers and IDs associated with that particular camera.
Here’s the full yaml for one of the cameras, mostly created through the GUI:
alias: Person detected in garage
description: ""
triggers:
- type: turned_on
device_id: DEVICE_ID
entity_id: ENTITY_ID
domain: binary_sensor
trigger: device
conditions: []
actions:
- action: camera.snapshot
metadata: {}
data:
filename: /config/www/snapshots/garage.jpg
target:
device_id: DEVICE_ID
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- action: notify.mobile_app_pixel_9_pro
metadata: {}
data:
message: Person detected in garage
data:
image: http://my_local_ip:8123/local/snapshots/garage.jpg
clickAction: >-
intent://scan/#Intent;scheme=reolink;package=com.mcu.reolink;action=android.intent.action.VIEW;S.UID=REOLINK_DEVICE_UID;S.DEVNAME=Garage;S.ALMTYPE=PEOPLE;S.ALMCHN=1;S.ALMNAME=Detection;S.ALMTIME={{now().isoformat()}};end
ttl: 0
priority: high
- delay:
hours: 0
minutes: 0
seconds: 30
milliseconds: 0
- if:
- condition: time
after: sensor.sun_next_dusk
before: sensor.sun_next_dawn
then:
- action: light.turn_on
metadata: {}
data:
brightness_pct: 50
target:
device_id: DEVICE_ID
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- action: light.turn_off
metadata: {}
data: {}
target:
device_id: DEVICE_ID
mode: single
As a result, here are the “variables” that I would need to somehow map to each device:
DEVICE_ID
: Right now, this is a long UUID that identifies my camera in HA (e.g.:7989927d494...
). Can I perhaps replace this with a string that can be easily mapped?ENTITY_ID
: Same as above, but I assume this is the entity ID corresponding to the person detection trigger of this camera.http://my_local_ip:8123/local/snapshots/garage.jpg
: I’m keeping it simple and just saving a screenshot to a file with the same name as the camera (+ .jpg). In this case, “garage” would be the string to use.UID=REOLINK_DEVICE_UID
: This is a long UID (e.g.:9527000...
that Reolink assigns to each camera. It allows me to add a deep link in the phone notification that will take me straight to that camera’s live view within the Reolink app, which is pretty neat. Unfortunately that means I’d need to somehow map that UID to each camera in the automation.S.DEVNAME=Garage
: The name of the camera within the Reolink app. I’ve made this consistent with everything else, so again, just the same string with an initial uppercase.
Could anybody point me to a resource where I can see how to merge all this into a single automation?
I assume most of the variables could be simplified to variants of each camera’s “friendly name”, then accessed through basic string manipulation: garage.light
, garage.person
, garage.jpg
, Garage
, etc. So I could probably just pass those friendly names like this:
- garage
- entrance
- porche
etc
However, I’m unsure if I can also somehow map Reolink’s UID to each of those cameras for the deep linking part.
Appreciate any help!