Can you provide a solution for Grafana cards appearing as 401: Unauthorized after a reboot or some time has passed since I last accessed Grafana Web UI
I setup my cards in HA as iFrames with an URL, using the provided embedded link. Example with my domain removed: https://[local-HA-DNS]/api/hassio_ingress/DV_UHGmIIMcNPABt5sKeT9EPIt438P0BvTQujnxLMrc/d-solo/edd3be32-7643-409f-8f43-bb359f9ddcf9/temperatures?orgId=1&panelId=1" width=“450” height=“200” frameborder=“0”
# make sure that your dns has a cname set for grafana and that your grafana container is not using a base url
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name grafana.*;
include /config/nginx/ssl.conf;
client_max_body_size 0;
# enable for ldap auth, fill in ldap details in ldap.conf
#include /config/nginx/ldap.conf;
location / {
# enable the next two lines for http auth
#auth_basic "Restricted";
#auth_basic_user_file /config/nginx/.htpasswd;
# enable the next two lines for ldap auth
#auth_request /auth;
#error_page 401 =200 /login;
include /config/nginx/proxy.conf;
resolver 127.0.0.11 valid=30s;
set $upstream_app grafana;
set $upstream_port 3000;
set $upstream_proto http;
proxy_pass $upstream_proto://10.0.0.67:$upstream_port;
}
}
I just installed it and will test with great optimism! I’ll update you soon! But if your addon works as expected, I guess it shows there is a real WTH issue with integrating Grafana cards inside dashboards. I believe it should be considered as one of the picks for the next wave of solutions to HA users issues collected with this WTH 2024 edition!
Quick update, on the HA-Companion App, when I navigate to my dashboard where the Grafana card should appear, it displays the 401: Unauthorized message. The card below with TEST as a name is the one using your iFrame HACS.
I’m sorry to say but it seems your HACS does not work for me on the Companion App. I will update you if the same happens with my browser on local network with my HA domain address.
Show me your url please, you must replace the scheme://host:port/random part with the addon slug, otherwise it’s the same as the original webpage card.
And since I use an https:// DNS domain, I must change localhost:3000 for MY-HA-URL
https://[MY-HA-URL]/api/hassio_ingress/DV_UHGmIIMcNPABt5sKeT9EPIt438P0BvTQujnxLMrc/d/edd3be32-7643-409f-8f43-bb359f9ddcf9/temperatures?orgId=1&from=2023-10-19T22:15:00.000Z&to=now&viewPanel=panel-1
By the way, while using [MY-HA-URL], I cannot keep the port :3000 part otherwise it will not work:
http://[MY-HA-URL]:3000/api/hassio_ingress/DV_UHGmIIMcNPABt5sKeT9EPIt438P0BvTQujnxLMrc/d/edd3be32-7643-409f-8f43-bb359f9ddcf9/temperatures?orgId=1&from=2023-10-19T22:15:00.000Z&to=now&viewPanel=panel-1
Ok, I just did. By the way, if I remove the domain and keep this part ‘/api/hassio_ingress/’ with the regular web card, it’s also working. But I haven’t saved the regular web card to see if your trick will work. I’ll keep an eye as to when the regular web card shows the 401 message and update if your HACS iFrame card keeps working correctly.
It’s easy to verify.
Remove my card, keep only the offical webpage card, then restart browser, see 401 unauthorized.
Change card type to mine, then restart browser.
I had another Home Assistant system on which I tested your iFrame HACS. Accessing it remotely from the HA Companion App, I could see the standard iFrame Web card was showing the 401: Unauthorized message, but your iFrame card was able to access my Granafa card. I took 2 individual screenshots, and while I wanted those 2 cards in the same screenshot, I started editing the dashboard and when I entered edit mode, the standard iFrame Web card could access Grafana. So your HACS also helps the standard iFrame Web card to access Grafana without the user actually accessing Grafana Web UI. Here is a montage of the two screenshots put together so you can see your card was working while the standard iFrame Web card wasn’t.