Automatically pick light/dark theme for Grafana panels

I’m just getting started with Grafana. Apologies if I’ve missed a post that has already covered the following, but at least when I was looking at resources setting it up, I didn’t see such. That is, how to get Grafana panels to automatically switch from light to dark theme.

So. Once Grafana is up and running, and you have your fancy (or, in my case, less fancy) graphs in place [this was a great post, by the way, getting going], there might be a mismatch between your themes? Especially if you have HA automatically switching between light and dark.

Well, it’s pretty easy to get your Grafana panels to follow suit! I’m sure there are other, possibly better ways to achieve it (tips are appreciated!), but here’s how I did it:

(1) Create two camera entities, one for pulling a light Grafana panel, the other for pulling a dark Grafana panel.

(2) Have a true/false sensor of some kind (I made a binary template sensor) for when you want light or dark theme.

(3) Use the conditional card in Lovelace to show “camera light panel” or “camera dark panel” depending on the state of the aforementioned true/false sensor.

Here is a gist with the code for (1), (2), and (3).

The dark theme in the screenshot is Blackened. The light one is clear (light).

faced same problem. You can pass to grafana variables, like shown on my screenshot. If i can get user theme variable i can pass it to grafana and interpritate
So questions is:
How to get current user theme value. Like dark, light or whatever?

I havent found a decent solution for this anywhere. It would be great if you could get the active themes mode and pass that in the url.