home-assistant / android

:iphone: Home Assistant Companion for Android
https://companion.home-assistant.io/
Apache License 2.0
2.26k stars 628 forks source link

[FR] allow relative URL to /media file in clickAction (of notifications) #1672

Open HIT2022 opened 3 years ago

HIT2022 commented 3 years ago

On Android, is it possible to click through a notification, to display a media file located within the /media directory? This could already be supported, but I haven't been able to do so successfully.

With, for example:

        "image": "/media/local/amazon_order_2021-08-03_XXXX.jpg",
        "clickAction": "/media/local/amazon_order_2021-08-03_XXXX.jpg"

The notification image displays fine, but a click leads to a 401: Unauth response (in the Companion app).

dshokouhi commented 3 years ago

This is already supported and documented https://companion.home-assistant.io/docs/notifications/notification-attachments#media_source-recommended

For help reach out on forums or discord, there is also a troubleshooting section on the docs site as well.

HIT2022 commented 3 years ago

I did see that relative URLs to /media were already documented for use w/ image attachments -- but as I described, "/media/local/" is not working w/ tap to open a URL (via clickAction). I'll ask for input in the forums.

dshokouhi commented 3 years ago

Re-opening this request per discussion in: https://community.home-assistant.io/t/how-to-open-media-image-via-relative-url-in-clickaction/328792

dshokouhi commented 3 years ago

Looks like /media does not like the authorization provided by the authenticated webview which is strange. Might need to add the auth header in this case unless its something that should be handled by HA core as the webview is already authenticated.

brubaked commented 2 years ago

Any further info on where this needs to be fixed?

dshokouhi commented 2 years ago

Any further info on where this needs to be fixed?

we need to either add the special kind of auth to the app here: https://github.com/home-assistant/android/blob/master/app/src/main/java/io/homeassistant/companion/android/util/NotificationActionContentHandler.kt

or determine if this is a core issue that should be resolved in HA core. IMHO authenticated webview should be good enough here.

braddo99 commented 7 months ago

Looks like /media does not like the authorization provided by the authenticated webview which is strange. Might need to add the auth header in this case unless its something that should be handled by HA core as the webview is already authenticated.

I would like to respectfully suggest that /Media should not be the recommended location for storing notification images in the docs, since clickaction appears not to be functional for that directory. At least for me the docs are confusing because the /www location is claimed to be "open to the internet" but isnt this just a folder on my personal mobile device? My own HA instance isnt exposed to the net.

dshokouhi commented 7 months ago

My own HA instance isnt exposed to the net.

The feature will never work in that case. Images need to be remotely accessible from the server.

The docs are fine as they also include iOS which does support it AFAIK. This is just a feature that needs to be implemented.

braddo99 commented 7 months ago

Thanks for the response, appreciated. I respectfully disagree. It's a bug in the recommended method but you pointed out above that it is broken somehow. Bugs are normal and fine! I do think it raises the priority to either change the docs (there are already differences in behavior for iOS amd Android) or fix the bug.

Then on the feature not working in any case, you would be in the best position to know, but I've seen people reporting it does work and I dont know why it wouldn't. The file has already been sent to the device, so showing it could/should be straightforward and not involve the server.

crowbarsolutions commented 5 months ago

With frigate's API allowing for accessing snapshots/clips it is noticeable when a generic camera device doesn't have the same functionality when it comes to accessing media. And since it seems that this works in iOS, would this then be classified as a fragmentation in functionality and therefore be a bug?