String pwrFeedInSt "Feed-In Power : [%s W] " <energy> (PowerCons) {channel="exec:command:pwrFeedIn:output"}
Number pwrFeedIn "Feed-In Power "
My rule
rule "powers to number"
when
Item pwrFeedInSt changed
then
pwrFeedIn.postUpdate((pwrFeedInSt.state) as Number)
end
Result from log
10:23:49.189 [INFO ] [smarthome.event.ItemStateChangedEvent] - pwrFeedInSt changed from 1073 to 336
10:23:49.224 [ERROR] [untime.internal.engine.RuleEngineImpl] - Rule 'powers to number': Could not cast 336 to java.lang.Number; line 224, column 26, length 29
And
pwrFeedInSt (Type=StringItem, State=94, Label=Feed-In Power :, Category=energy, Groups=[PowerCons])
pwrFeedIn (Type=NumberItem, State=NULL, Label=Feed-In Power , Category=null)
I have tried restarting the Influxdb service as these items are read by Influxdb and have tried forcing a change to the .persist file as they are also persisted.
Yeh, a state object is a state object. Some parts of rules DSL are smart enough to do necessary conversions from state to more everyday types - others are not.
I think in this case, being a state object, postUpdate tries to use it directly without conversion but of course a “stringy flavoured” state doesn’t fit a Number Item state.
Give it a proper string object, and it knows to perform a conversion.