I have a problem with some calculations on negative Wh items.
My Item:
Number:Energy Solar_Today "Solarpower today [%.0f Wh]"
My Rule for testing various conversions:
rule "test"
when
Time cron "*/20 * * * * ?"
then
logInfo("Electra","{}", (Solar_Today.state as Number))
logInfo("Electra","{}", ((Solar_Today.state as Number)*-1))
logInfo("Electra","{}", ((Solar_Today.state as Number)/1000))
logInfo("Electra","{}", (Solar_Today.state.toString))
logInfo("Electra","{}", (Solar_Today as DecimalType))
logInfo("Electra","{}", (Float::parseFloat(Solar_Today.state.toString)))
end
This results in the output:
- -1410.0 Wh
- 5076000.0
- -5076.00000000
- -1410.0 Wh
- Error during the execution of rule ‘test’: Could not cast Solar_Today (Type=NumberItem, State=-1410.0 Wh, Label=Solarpower today) to org.eclipse.smarthome.core.library.types.DecimalType;
- Error during the execution of rule ‘test’: For input string: “-1410.0 Wh”
Am I doing something wrong or is there another way to convert Wh to a number that can be used in calculations.