[SOLVED] Blockly: how to strip UoM for W/m²

Hi,

How can I strip the UoM from a variable? I’ve found this but if I replace °C by W/m² it doesn’t work.

sonne_direct_radiation_max24h is read from a persistence service and comes with UoM. Then I try this:

OH_Post.png

Thanks for your help.

Best,
Bernd

First of all, why? This smells of an XY Problem.

If you don’t want to use the units, then don’t use them. Set your Items to be Number Items and there will be no units. Or, if you just don’t want to use the units in your rules, use the “get [name] from item” block and choose “numeric state”

Or, for the best solution, stay working within units by using the blocks in the Units of Measurement category.

1 Like

Thanks Rich for your answer. Well, the reason is: I do some calculations, which don’t need any UoM - something like:
compare max of direct sun radiation of last 24 h and compare it to some fix value in order to get something which tells me, if we have more like winter or summer, then adjust blind targets accordingly.
But of course it would also be possible (and somehow more correct) to calculate the ratio as max_24h W/m2 / 180 W/m2; I would get the ratio as a number without units.Unfortunately, that doesn’t seem to work. Maybe this max_24h is not handled as a number with unit blockly, only during run time?

Ah, no, my fault: I had to replace my comparison “/” by the Qty-version as well. Now its’ working as expected. Thank you again.