HASS.Agent
HASS.Agent copied to clipboard
Bug: Notifications sent to hass.agent do not contain camera thumbnail when using /api/camera_proxy/
Notifications send to hass.agent do not contain camera thumbnail. This is working when sending the same notification to the mobile companion app. The log complains it is only allowed to process "HTTP uri's" but if you prefix the api with your HA domain you get a 403 error.
The below is based on the instructions provided: https://hassagent.readthedocs.io/en/latest/notifications/notification-usage-and-examples/#camera-proxy
NOT Working script
service: notify.desktop_lucas
data:
data:
image: /api/camera_proxy/camera.deurbel
message: test
title: Doorbell
Working script
service: notify.mobile_app_pixel_7_pro
data:
data:
image: /api/camera_proxy/camera.deurbel
message: test
title: Doorbell
Expected behavior Windows hass.agent is expected to show thumbnail
Screenshots
Misc info (please complete the following information):
- Windows 11
- Windows' UI language: Dutch
- HASS.Agent version: 2022.14.0
Please check what's applicable (multiple answers possible):
- [x] Installed via installer
- [ ] Installed manually
- [x] Problem occurs in HASS.Agent
- [ ] Problem occurs in Satellite Service
Logs
2023-08-16 15:47:05.143 +02:00 [ERR] [STORAGE] Unable to download image: only HTTP uri's are allowed, got: /api/camera_proxy/camera.deurbel
2023-08-16 15:47:05.143 +02:00 [ERR] [NOTIFIER] Image download failed, dropping: /api/camera_proxy/camera.deurbel
This is not a bug. HASS.Agent does not function exactly the same as Companion App. (+kinda duplicate of https://github.com/LAB02-Research/HASS.Agent/issues/306) You receive 403 when using the full URL because it requires authentication token which is provided by default by Companion App. This is addressed by https://github.com/LAB02-Research/HASS.Agent.Staging/pull/18 - please close this issue.
This is not a bug. HASS.Agent does not function exactly the same as Companion App. (+kinda duplicate of #306) You receive 403 when using the full URL because it requires authentication token which is provided by default by Companion App. This is addressed by LAB02-Research/HASS.Agent.Staging#18 - please close this issue.
Hi @amadeo-alex Please comment on the example provided:
What am I doing differently?
Sorry but I have not used this nor I know the author of this snippet. My best assumption is that something changed either on HASS.Agent or HA side since this snippet was posted (this can be kinda proven by missing "hass.local" and "garden" which is mentioned in the last paragraph visible on the screenshot).
The StorageManager on HASS.Agent side (on current public master build) tries to fetch the image as a HTTP resource - it's also mentioned in the logs you've provided.
Unable to download image: only HTTP uri's are allowed
That's why I suggested on discord to use full path to the resource, this ended up with 403 so my assumption is that the "api/camera_proxy/..." requires authentication (this can be easily checked by opening new tab on a browser where you're logged in to HA and then opening the HA url with "api/camera_proxy/..." added at the end. If this works then it will be remediated by feature added in PR I mentioned above.
Sorry but I have not used this nor I know the author of this snippet. My best assumption is that something changed either on HASS.Agent or HA side since this snippet was posted (this can be kinda proven by missing "hass.local" and "garden" which is mentioned in the last paragraph visible on the screenshot).
The StorageManager on HASS.Agent side (on current public master build) tries to fetch the image as a HTTP resource - it's also mentioned in the logs you've provided.
Unable to download image: only HTTP uri's are allowed
That's why I suggested on discord to use full path to the resource, this ended up with 403 so my assumption is that the "api/camera_proxy/..." requires authentication (this can be easily checked by opening new tab on a browser where you're logged in to HA and then opening the HA url with "api/camera_proxy/..." added at the end. If this works then it will be remediated by feature added in PR I mentioned above.
I appreciate your help but if I can trust hass.agents own documentation: https://hassagent.readthedocs.io/en/latest/notifications/notification-usage-and-examples/#camera-proxy this is still a bug (or the documentation is at fault). I already have implemented a workaround, this is just for the record :)
@LAB02-Admin you'll probably remember the origins of this snippet :D Looks like it might need some adjustments/removal.
@simkin I assume this is the workaround. If not this is what worked for me ...just in case somebody wants to save a few hours trying to figure it out.
service: notify.hassagent data: message: Someone is at the door title: Doorbell data: image: >- https://domain.xyz{{(state_attr("camera.front_door_camera", "entity_picture"))}} duration: 3
EDIT: I fixed this issue, see bottom edit
Hey, I stumbled upon this thread to ask about the documentation not being super accurate with the code snippets anymore but I see it was already talked about.
@eMeF1 I tried your suggestion and I was able to use your example to get a URL that in my browser will send me to the snapshot I'm looking for. However, when I try to use it the notification it doesn't actually display the thumbnail. Any suggestions? Below is my notify action for reference
service: notify.hassagent
data:
message: >-
A {{trigger.payload_json['after']['label']}} was detected on the Front Door
Camera
title: "{{trigger.payload_json['after']['label']}} Detected"
data:
image: >-
{{states('input_text.local_url')}}{{state_attr("camera.front_door", "entity_picture")}}
# "{{states('input_text.external_url')}}/api/frigate/notifications/{{trigger.payload_json['after']['id']}}/thumbnail.jpg?format=android"
input_text.local_url and input_text.external_url are both set and are what you would think they are based on the name. Neither works for the notifications but both work in the browser (private)
Edit: 2 seconds after sending this comment I tried to add the duration key to my action config, with a value of 3, and it worked immediately. I had assumed the duration had something to do with the time the notification is present on screen before removing it self. I was okay with whatever the default was so I didn't think I needed it. But, for whatever reason, it is.