OpenHAB2 Parsing Strings

I’m trying to evaluate the SetPoint of a Nest thermostat. The item state is a string “70.0 °F”. I can’t figure out how to convert the SetPoint to a decimal so I can send alerts if someone sets the thermostat too low or high. I can’t figure out how to parse out the first 4 characters and convert the string to a value.

I think it should also be possible to do these comparisons without any parsing:

if (SetPointItem.state >= 77|°F) {
    // insert alert code here
}

See also Scripts & Rules in this Eclipse SmartHome blog.

No, the item state is a QuantityType:Temperature.
What @wborn said should work

wborn - thanks for the reply. Yes I can do string comparisons which is what I’m doing currently. I would like to be able to parse out the numeric value so I can evaluate the difference of outside, inside and set temps and send alerts when ever the variance is outside of an acceptable range.

CAn you post your items, please?

These are from paper UI not an items file:

Nest (Type=GroupItem, BaseType=StringItem, Members=1, State=NULL, Label=null, Category=null)
DownstairsThermostat_TimeToTarget (Type=NumberItem, State=NULL, Label=Time To Target, Category=null)
DownstairsThermostat_SetTemperature (Type=NumberItem, State=75.0, Label=Nest_Max_Set_Temp, Category=Temperature)
Home_RushHourRewards (Type=SwitchItem, State=OFF, Label=Rush Hour Rewards, Category=null)
Nest_SetPoint (Type=NumberItem, State=72.0 °F, Label=Nest Set Point, Category=Temperature)
DownstairsThermostat_HasLeaf (Type=SwitchItem, State=OFF, Label=Nest Has Leaf, Category=Nest, Groups=[Nest])
DownstairsThermostat_Humidity (Type=NumberItem, State=45, Label=Nest_Humidity, Category=Humidity)
Home_Away (Type=StringItem, State=HOME, Label=Nest Away, Category=Nest)
Home_TimeZone (Type=StringItem, State=NULL, Label=Nest Time Zone, Category=null)
DownstairsThermostat_Temperature (Type=NumberItem, State=72.0, Label=Nest_Temp, Category=Temperature)
DownstairsThermostat_Mode (Type=StringItem, State=COOL, Label=Nest_Mode, Category=Nest)
LocalWeather_ForecastToday_MinimumTemperature (Type=NumberItem, State=72, Label=Minimum Temperature, Category=Temperature)
DownstairsThermostat_AmbientTemperature (Type=NumberItem, State=68.0, Label=Nest_Min_Set_Temp, Category=Temperature)
DownstairsThermostat_SetPoint_Nbr (Type=NumberItem, State=72.0 °F, Label=Set Point, Category=null)

It’s a number item, you can do things like:

if (DownstairsThermostat_AmbientTemperature.state > 70) {
}

The evaluation I want to perform includes Nest_SetPoint. It’s a NumberItem but the state includes " °F". I think I may need to manually create a new item for the setpoint which should give me more control over the formatting.