What driver is this? While you could probably do some naive operations in RM to modify this text (substring involving > and <, maybe?), it would be a lot easier to tackle this at the driver level--and if you share what that driver actually is, maybe someone already knows a way.
I believe this has something to do with how the variable is set (HTML tags migrate from the original string), where the value is not stored as a “plain” string value.
No, this has everything to do with how the driver is setting the value. The attribute value includes HTML. The device detail page renders this. A hub variable is going to just give you the underlying string value, which includes the visible HTML tags. The hub variable is doing what it is supposed to do.
One solution is to ask the driver author for an option to disable HTML and set the values as plain text.
Another solution is to use the AQI itself and create your own string from that, given that this value is simply a human-friendly convenient display of that same information.
A third option is the one I mentioned above, using some string operations in Rule Machine to cut the variable value down to just what you need. Since this HTML is fairly simple (i.e., the complexities of a full parser are unlikely to really matter), breaking the string apart using tokenizers on < and then > (or the other way around) using the appropriate indicies should also help you get the text you're really after.
I think the best way forward is to remove the HTML code from the existing attribute. Since it was a custom attribute, I took the liberty to be creative; looks like it was a bad call since the HTML color brings more problems than benefits. I'll include the changes in the next release. Thank you for the feedback!