You could check out their GIthub page: GitHub - AlexxIT/WebRTC: Home Assistant custom component for viewing almost any camera stream in real time using WebRTC and other technologies.
Or, and Iām certain there are others, you could check out @mostlychrisās video: Real Time Camera Viewing using RTSPtoWeb and Glance Cards in Home Assistant. - YouTube
First, thank you for this amazing automation! I was able to get mobile device notifications set up for smart detections and have HA notify my devices with static images and GIFs. Excellent work!
Since doing so, Iāve found that each Person Detected notification sends three alerts per detection to my Android devices, all within seconds of each other. It was great confirmation that the automation works and helped me understand the behaviour under the hood, but now the constant sounds and buzzing are annoying.
It appears that each notification is replaced by a more informative notification as it is updated with a static image, and then a GIF once the recording is complete and loaded. Or it could be three separate notifications that clear the previous one out - that would explain three alerts too.
Either way, I want the automation to only alert/buzz one time per smart detection and am stuck on how to achieve it with this blueprint.
Currently my thoughts are:
- Explore the Alert Once functionality native to HA notifications. If the behaviour works as I think it might, then adding Alert Once functionality could be the most elegant solution. It does however assume that notifications are being updated and not replaced - and to me, the alert behaviour suggests each notification is being replaced by the next. Also since it appears that every new smart detection notification erases the last one, this might mean that I only get notified by the next notification after clearing the previous one, which could cause more problems than it solves. Regardless, the blueprint would need changes to achieve this.
- Break out each sequential notification for the same instance - initial detection, then image update, and then GIF/video - into their own notification channels somehow. Then, set individual alert preferences either as sensible defaults in the blueprint/automation itself or on each device directly. This feels more like a quick and dirty solution but Iām not sure how to achieve this yet.
Iām confident enough to have a crack at forking the blueprint and trying some stuff out, but this will take me many hours because Iām relatively new to HA and not comfortable with the syntax and behaviours yet.
Before I dig too far, has anyone else experienced the same issue? Is there a simpler solution than what Iām considering?
Thanks all for reading!
Update: I went down the rabbit hole and added the following logic to the two relevant action data locations in the automation:
# Android alert once (requires tag to be set)
alert_once: |
{% if tag != "" %}
true
{% else %}
false
{% endif %}
In testing today, I can confirm that my phone now only buzzes once per detection, but still retains the desired behaviour of immediately alerting (notify/vibrate) first, followed by silently updating the original notification with an image and GIF afterwards. When a new detection fires, the notify/vibrate alert triggers again and replaces the old notification, so I donāt have to dismiss anything to be notified and alerted by the most recent detection.
Edit: itās almost perfect. My phone alerts only buzz once, but my watch still buzzes twice. Better than thrice though progress is progress!
iOS isnāt affected by this change at all since Alert Once is Android-only.
This is exactly what I want, and I suspect other Android users might also want this so Iām going to make a PR next.
2023-06-27 update:
This morning I learned more about the behaviour of HA Android notifications (with the Alert Once changes proposed in PR #8 implemented) between my Galaxy phone and my Galaxy Watch.
As of this morning, post-Alert Once change, my phone only buzzes once instead of thrice per notification, as desired, but my watch was still buzzing twice when I expected it would only buzz once.
As it turns out, this might be related to the interaction between the Home Assistant phone app and the Home Assistant wearOS app, where each app instance may not be fully aware of the notification state of the other app. It seems the wearOS app was still receiving the notification pushed via the HA wearOS app and reflecting the notification sent to my phone.
I was able to work around this bug by creating a new notify group specifically for these notifications and removing my watch from that group.
Now, when a detection triggers a notification, both my phone and watch alert once! Perfect!
My watch still alerts because it is reflecting the notification sent to my phone like any other app would, without a wearOS companion app installed.
I would rather control this more granularly with native Android app permissions. I believe itās possible to do so, because other Android/wearOS companion app combos sync their notifications and provide options to manage watch-specific notifications independently - but Home Assistant does not appear to do this yet. I hope this will be addressed in future app updates.
For me, this is problem solved. Hope this deep dive helps others using this blueprint with Android devices!
Filed issue #7 and submitted PR #8 for review.
@AngellusMortis would love your feedback on this one - thanks again for such a great blueprint!
Hallo all, is there a way to have notification action to point to event video?
There is no way to link to a media item: Introduction | Home Assistant Companion Docs
I guess this answers my question here? Getting a Unifi protect video link in a notification
The Motion / Smart Detection Notifications have been nearly perfect for me since updating to the latest, however Iāve got one camera I regularly get an error in the notification sent to iOS that reads, āFailed to load attachment Response could not be serialized, input data was nil or zero length.ā
Notifications from this camera work most of the time, but it happens probably once a day at least that I see this error from this camera (G4 Bullet). However, I donāt believe thereās anything wrong with my camera.
Does anyone have any ideas about what could be causing this sporadically when pushing notifications to iOS? This doesnāt happen on any of the other cameras.
In iOS Iām getting a notification with a very small thumbnail. Is it possible to change this, or, when clicked, to open HA to a Lovelace page with the event picture? Do you have an example?
Iām working on a solution to this.
To get the last event image Iām saving the url in input_text, and then Iām using this input_text as the url for a static_image in a āgeneric cameraā, following this example for a dyamic url Template inside a Picture Entity Card - #2 by Noto
Then Iām using a picture-card connected to this generic camera in a lovelace view.
What do you think about it?
I have a question wrt to the āMotion / Smart Detection Notificationsā blueprint
I DO receive notification messages but there is no snapshot/thumbnail attached. Kindly advise if this is a known issue or that I might have misunderstood the instructions
Hi,
I am able to have the smart detection notification working using that blueprint provided. However, when I setup the doorbell with tts notification and response, doesnāt appear to work. What Am I doing wrong?
What Service are you using for tts.speak? I was trying to use the Nabu Casa Cloud and had to change that field to ātts.cloud_sayā
[UPDATE] changed the Pull Request to support generic HA Alarm.
Iāve created additional functionality for this blueprint, to support Alarmo integration.
This pull request allows you to integrate your home alarm system through Alarmo integration. It allows to specify Alarmo entity panel and arm states that act as filters as to when to send notifications. The code respects the presence filter and works together. You can specify the presence filter and/or Alarmo entity.
This helped me to unblock several additional use cases:
- When I & my family are away and someone is looking after the home, it does not send us a notification every time the person is in camera fields, only if the home is armed. (previously, I had to disable automation)
- If the home is armed for a night, I receive notification if someone is on the territory (duplicate of the automation with presence filter off, but respecting ānight armā)
- When both the presence filter and Alarmo are enabled, it doesnāt send any notifications to you while you are leaving or entering the house even if an alarm is set.
For me, I get the small thumbnail in the notification and if I long press this notification on iOS itās supposed to show the video clip that triggered the alert. However, it sometimes just shows a black image instead of the videoā¦I really wish it would just show me a larger version of the thumbnail instead.
A history of the images would be great, or at the very least, the ability to show the larger version of the thumbnail on longpress. Does anyone have any pointers on how to adjust the blueprint to do either of these?
The video clips are cool when they work, but it fails enough for me that Iād rather just have the image.
If you want to watch the live stream from the notification, I suggest using a low-res stream, which you can get using the ffmpeg (go2rtc integration) via the RTMP streams. In fact, if you wait on that black screen, eventually, it will start streaming.
Regarding the history of the images, itās stored on your Protect app, which I would use in case you need to check on something that happened instead of relying on HA.
Great suggestion regarding the stream qualityā¦how do you configure these push alerts from the automation to pull from the low-res stream only? Yes, the black eventually loads, but Iād like quicker alerts that are more reliable, so getting that to be low-res should be fine if I can figure it out.
All of my UniFi Protect cameras in HA are set up with High by default through the Protect integration and then a WebRTC camera pulling from the Medium RTSP stream. So which camera feed is this blueprint pulling from?
Do I have to disable the High and make it so all of my cameras only have the low stream available via the integration? Iād like the ability to still have the WebRTC camera feeds to access via my dashboards in higher resolution.
For example, you set this stream
go2rtc:
streams:
g4_pro_med:
- rtspx://192.168.200.200:7441/q8fWgdupi2tXdckv
and the camera
g4_pro_med:
ffmpeg:
inputs:
- path: rtsp://127.0.0.1:8554/g4_pro_med?video=copy&audio=aac
Then your automation should look something like this:
- service: notify.mobile_app_user_iphone
data:
title: Notification
message: Person detected
data:
image: >-
/api/unifiprotect/thumbnail/{{ config_entry_id(trigger.entity_id)
}}/{{ state_attr(trigger.entity_id, 'event_id') }}
channel: Motion
icon: mdi:cctv
entity_id: camera.g4_pro_med
actions:
- action: URI
title: Open Camera
uri: /lovelace/cameras
- action: DISABLE_ALARM
title: Disable Alarm
icon: mdi:shield-home
- action: URI
title: HA Security
uri: /lovelace-security/home
I hope it helps
I noticed some lag with the med resolution as well, I didnāt try the low yet.
Thank you. How do you use this with the UniFi Protect Motion / Smart Detection Notifications blueprint from this thread? I only have the options in the automation to set the smart detection and it automatically figures out which camera to show as I understand it. Are you not using this blue print and just set it up directly as you shared here?
To clarify my original message above, Iām using the Blueprint from this thread, so Iām trying to find a way to either modify it to image only or switch it to the low res stream to avoid the black screen when long pressing on the iOS notification.
I am not using that Blueprint. I think I tried it at some point, but it is very limited for what I needed. So I have done my automation on my own. If you want to use the blueprint you just need to pick the low/med res camera instead of the regular one and stick with all the other options in the blueprint.
Just ignore my last piece of the automation config.