I’m trying to create an expression in YAML to create a dynamic label for a gauge in the overview page of main UI. My problem is that I need to compare something with a Unit of Measurement (Watts) on it. The typecasting you can find in the forums does not work here. The version below does something, but is behaving unexpected. For example:
I don’t think there is any UoM support here.
You must process the states yourself. Split the value and units, either trust the unit is what you hoped for, or process that and scale the value.
Check that very closely. What does ‘not work’ mean?
There’s a longer discussion here
But it doesn’t, the code has no idea at all about quantities and units. These are just strings. “0.00001 lx” > “5 lx” is true, because it has more characters.
Actually, the first suggestion of using split hasn’t worked. I think there’s a bug in here. It’s acting very strange. A simple expression of if A < B then color green. As I incrrease and decrese the A value, I get green randomly.
You intend to do a numerical comparison, yes? Remember that Item states arrive here as strings, not numbers. Splitting them results in strings of digits, not real numbers. Parse the strings to get numbers.
I have a fully functional home heating system UI built with loads of conditional colors and other things like icon sizes etc all reacting to Number:Temperature items with no problems.
I can not get even simple maths or comparisons to happen with a Number:Illuminance item
That works, thank you.
But it still doesn’t explain why I need to do this with Illuminance numbers and not temperature numbers. It reads like it shouldn’t work with temperatures either, but like I said, my heating system UI changes through blue, yellow, orange, pink, red as the temp rises and it works perfectly.
I seem to be able to get numbers from the Developer Sidebar by losing the split bit, but it doesn’t work in my UI expressions
Why, what are you doing with it? What does ‘not work’ mean happens instead? Tip, now it is parsed to a number don’t try comparing to some other string like “20”.