Whilst testing this rule to convert an item state value (String) to a float (Number) , I get the error below; why can the rules system not convert a string to number? The string value is “3.1324”.
(using this guide Type Conversions) from the guru @rlkoshak
Rule:
rule "Scale voltages"
when
Time cron "0 0/1 * 1/1 * ? *"
then
i_TRV_Lounge_Scaled_Voltage.sendCommand(new DecimalType((i_TRV_Lounge_Get_Voltage.state as DecimalType) * 28.8) )
end
Error
2020-01-10 21:32:00.417 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Scale voltages': Could not cast 3.19141 to java.lang.Number; line 6, column 62, length 40
Item:
String i_TRV_Lounge_Get_Voltage "Current voltage [%s]V" <battery> (g_HVAC, g_TRV) {channel="mqtt:topic:b_MQTT_Broker:t_TRV_Dad:c_Voltage"}
Number i_TRV_Lounge_Scaled_Voltage "Voltage" <battery> (g_HVAC, g_TRV, g_Diagnostics)
What’s wrong?
I’ve tried DecimalType, PercentType
I’m no good with Java so please just a quick line - not a link to pages of Java - but just a quick few words on why it has to be a certain way.