Hi there,
I have my units of measure specified in the tag attributes.
Is there a way to use template in the Labels of charts?
It would be nice to setup the unit automatically, something like this in terms of syntax?
Hi there,
I have my units of measure specified in the tag attributes.
Is there a way to use template in the Labels of charts?
It would be nice to setup the unit automatically, something like this in terms of syntax?
You can obtain this by using a device Context Variable. In production applications, it’s common for customers to have many identical devices. A context variable provides a way to build a dashboard once and then pass in the device to display. You also get access to the device’s details, including attribute tags.
Below is an example of setting that context variable. You’ll need to select Include full device info in context.
Here’s that device with an attribute tag:
Here’s how to use that device on a gauge block:
The template is:
{{ctx.device.attributes.manifold_temperature.tags.units}}
One of the best ways I’ve found to explore what’s available on the context is by looking at the Custom HTML Block’s default configuration, which prints all available context.
Oh do you mean I can only do that by defining a device context in the dashboard?
So if in my case I already specified the device, then there is no way to retrieve the units?
Correct, at the moment, device details are only available if that device is provided as a context variable. Part of the challenge is that most blocks support selecting multiple devices and the data will be aggregated together. Not sure how to expose device details for that scenario.
When selecting a single device, which is the most common case, having access to that device’s details automatically does make sense. Something we’ll have to think about.
Makes sense, for now I will use the context approach. Thanks.