HTML in a global string variable

I have a global string variable that I would like to display on the dashboard in different colors depending upon some conditions in a Rule Machine rule. I tried to enter some HTML when I assign a value to the string variable in a rule, but the HTML disappears. For example when I enter something like Alert for the value to be assigned the string variable, it becomes just Alert. Is it possible to allow such HTML code to be assigned so that hopefully when shown on a dashboard, I can change the color of the string from a rule?

It looks like the forum removed the HTML from your post, so it says it was supposed to say Alert but it ended up saying Alert... I assume there were supposed to be HTML tags around the first one?

Working directly in the Settings -> Global variables I was able to get the HTML tags to show up by typing

<b>Test</b>

but that didn't translate into the dashboard as HTML

image

There is some discussion here that mentions you might be able to get it to work by storing the value with HTML as a device attribute, then displaying that device attribute in the dashboard.

2 Likes

Ha! That's funny they removed it - yes there was an HTML string to color the text. It must be a recent policy because I actually copied the HTML in my post from an older post when I went searching for an answer.

1 Like

Thanks! I'll take a look at that thread

2 Likes

Thanks for those thoughts. A string variable tile has no states in its template and I don't seem to be able to change that. Aren’t all the things dealing with CSS and the dashboard a permanent kind of solution? I want to be able to change the color dynamically based on the states of my door locks from Rule Machine. I’ll take a look at your other suggestions – many are completely new to me.

Thanks to all who tried to solve my issue. I still don’t see any easy, straight forward to do what I want so I’d like to keep this as a feature request. Please add basic formatting to a string variable – color, bold, italic, and underline. Maybe it’s not 100%, but I’m guessing a lot of cases for using a string variable is to eventually display it somewhere – and those basic formatting tools would sure be helpful. Thanks.

1 Like

I think that's a little bit too complicated for me right now - my case is really pretty simple and I have the rest of the dashboard setup. Some dynamically set colors for text sure would be nice - text that changes colors based on conditions set by a rule. Besides my door example, would it be nice if the battery tiles could change color based upon % as set with a RM rule?

1 Like

Thanks! I will...

Right now, I suspect that the only way to do what you desire is to write a custom app and do it in groovy. There are examples of apps that use custom html to change colors, etc. An example is HPM, that modifies the app list in the Hubitat UI when an update is available.

1 Like

Since I only needed two different colors for my string variable, I crudely solved my problem by making 2 string variables that are displayed on the dashboard as being one on top of the other. Each of them has CSS to set their respective colors. In RM, I set one string to a space (a null seems not to be allowed) and the other to the value I want to display; and then the values of the strings are switched when I want the other color. Seems to work – for my limited case.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.