Hello,
CC: @ThomDietrich @sjka @rlkoshak
Quite regularly I try to link two items to each other and every time I fail to do this properly at once, why is it so complex and can we improve the error message.
So I have a virtual expring switch and a normal switch:
Switch vExpiringKitchenLight { expire="2m,OFF" }
Switch CoCoKitchenLights "Keukenkastjes" { channel="rfxcom:lighting2:17634398_1:command" }
Intuitively I would expect to link them in one of the following two ways:
rule "synchronize_vExpiringKitchenLight"
when
Item vExpiringKitchenLight changed
then
CoCoKitchenLights.sendCommand(vExpiringKitchenLight.state)
end
rule "synchronize_vExpiringKitchenLight"
when
Item vExpiringKitchenLight changed
then
sendCommand(CoCoKitchenLights, vExpiringKitchenLight.state)
end
But this did not work with the error:
2017-12-15 21:35:06.038 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'synchronize_vExpiringKitchenLight': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,java.lang.String) on instance: null
I do not really understand why and remembered that one of the cases used to work, finally I ended up with:
rule "synchronize_vExpiringKitchenLight"
when
Item vExpiringKitchenLight changed
then
var state = vExpiringKitchenLight.state.toString
CoCoKitchenLights.sendCommand(state)
end
Why does this work and is this the only way it work or is there a more ‘sensible’ way to do this.
And more important and the reason to mention @sjka and @ThomDietrich can we improve error, because I do not even understand what the actual problem with the option above is.