[SOLVED] Using UoM / QuantityType in rules where used DecimalType Previously

Number temperature items (2.3.x) seem to have moved over to UoM regardless of whether i wanted them to or not :stuck_out_tongue: if I use the degree symbol in the item definitionā€¦which is fine if I can get them back to decimals or whatever.
perhaps someone can tell me a better way to do thisā€¦
I have a temperature and a setpoint. I want to set the hysteresis for opening/closing a vent but now with the numbers as QuantityType I cant get everything to play nice.

Number:Temperature  Master_Temperature 		"Master Bedroom    [%.1f %unit%]"   <temperature>	(gMainTemps)                        [ "CurrentTemperature" ]    { mqtt="<[oh2:/MasterSensor/Master_Temp/MBD_TEMP:state:default]", expire="20m,-1" }

even if I use it as just ā€œNumberā€ if i have the degree F in the description it seems to have shifted over to a QT regardless of not having :Temperature attached to Number. so again, whatever, thatā€™s fine if I can work with just the number, i just donā€™t know how to.


		//var setpointMA = VT_Setpoint_Master.state as DecimalType
		var setpointMA = new DecimalType(VT_Setpoint_Master.doubleValue)
		var Number turnOntempMA = setpointMA - 0.5
		var Number turnOfftempMA = setpointMA + 0.5
		//var tempMA = Master_Temperature.state as DecimalType
		var tempMA = new DecimalType(Master_Temperature.doubleValue)
		if ( tempMA <= turnOntempMA && FF_Master_Vent_Trigger.state != ON ) {

I got that out of https://docs.openhab.org/configuration/rules-dsl.html (search quantitytype)
but no love. i tried a few other things but none of them work:
Rule ā€˜Master Vent Control Strategyā€™: An error occurred during the script execution: Could not invoke constructor: org.eclipse.smarthome.core.library.types.DecimalType.DecimalType(java.lang.String)

any suggestions?

I thought I had tried this already but maybe notā€¦
anyway, this thread has the answer:

So my

var setpointMA = VT_Setpoint_Master.state as DecimalType

needs to become

var Number setpointMA = (VT_Setpoint_Master.state as QuantityType<Number>).doubleValue
1 Like

This no longer seems to work. From the logs

Could not cast 63 to org.eclipse.smarthome.core.library.types.QuantityType

The code

var Number temp = (FamilyRoom_FamilyRoomHVACTemperature.state as QuantityType<Number>).doubleValue

But this now works

var Number temp = (FamilyRoom_FamilyRoomHVACTemperature.state as Number).doubleValue```

Donā€™t seem to be any units there.

What kind of Item is FamilyRoom_FamilyRoomHVACTemperature ?

It is setup through Paper UI as a Number

Although I do not have a Dimension there. Not sure if that matters

If itā€™s just a Number type Item, itā€™s just a number.
If itā€™s just a number there is no dimension, and you cannot simply use as QuantityType.

All seems to be working as designed.