import org.eclipse.smarthome.core.library.types.DecimalType
rule "test"
when
Item TEMP_WOHNZIMMER_STRING changed
then
TEMP_WOHNZIMMER2.postUpdate((TEMP_WOHNZIMMER_STRING.state as DecimalType))
end
If you are on OH2, I don’t think you need that import. It should be included by default. I don’t have access to my OH installation right now, so I can’t test it, but, could you try this syntax:
rule "test"
when
Item TEMP_WOHNZIMMER_STRING changed
then
TEMP_WOHNZIMMER2.postUpdate(new DecimalType(TEMP_WOHNZIMMER_STRING.state))
end
openhab.log:
2016-12-27 09:27:13.081 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'test': An error occured during the script execution: Could not invoke constructor: org.eclipse.smarthome.core.library.types.DecimalType.DecimalType(long)
In the sitemap:
TEMP_WOHNZIMMER_STRING: %14.90
TEMP_WOHNZIMMER2: - °C
Sorry for the trial and error method, but, since I can’t test it myself, there is no other way to do this. The only other way I can think of is using this:
Double colon sign is ok. I know those kind of syntax.
I still get an error in my openhab.log and nothing is displayed.
2016-12-27 09:46:00.175 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'test': An error occured during the script execution: Could not invoke method: java.lang.Double.parseDouble(java.lang.String) on instance: null
Wait a second, do you have a percent sign in the String item? If you do, you can’t just convert it to number, because it contains alphanumeric character. From the earlier messages I thought you said you get a number as the result of exec command.
Well, it looks like that’s the case. It was just my conclusion, not something explicitly written in the documentation. But it wasn’t working the other way.
Is there any improvement to the Exec 2 binding planed? In my opinion, it’s a big backward step too. With the 1.x Exec binding it’s totally easy to bind such string script output to Number items. In OH2 with Exec 2 we have to use proxy items and rules?!?! I’m absolutely unhappy with this.
I’ll stay at Exec 1 then and looking forward to any improvement to the Exec 2 binding.