In OH 1.8 I have over 100 rules with sendCommand or postUpdate.
In OH 2.1 none of these rules works
Here is an example which works in OH 1.8 but does not work in OH 2.1:
in default.items:
Number D25_alive "D25 alive [%d]"
Number D25_alive_ack “D25 alive bestaetigen [%d]”
in default.rules:
var Number D25_alive = 0
var Number D25_alive_ack = 0
// ----------- Include the data of mqtt -----------
Rule "D25 alive"
When
Item D25_alive received update // D25 sends an alive packet
Then
SendCommand (D25_alive_ack, 1) // send a 1 back
end
The error message:
2017-02-11 16: 32: 55.258 [ERROR] [.script.engine.ScriptExecutionThread] -
Rule ‘D25 alive’: An error occured during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand (org.eclipse.smarthome.core.items.Item, java.lang .number) on instance: null
Do I forget something important - a binding or something else?
Having variables and Items with the same name looks like it will end in trouble? I don’t suppose sendCommand(D25_alive_ack, … knows whether to operate on the Item or the variable of that name.
rule "test rule"
when
Item test received update
then
test.sendCommand(1)
end
It gives the following errors:
2017-02-12 17:21:17.799 [ERROR] [.script.engine.ScriptExecutionThread] - Rule ‘test rule’:
An error occured during the script execution: The name ‘.sendCommand()’ cannot be resolved to an item or type.
rule "test rule"
when
Item test10 received update
then
test11.sendCommand(1)
end
and got:
2017-02-12 17:38:33.395 [ERROR] [.script.engine.ScriptExecutionThread] - Rule ‘test rule’:
An error occured during the script execution: The name ‘.sendCommand()’ cannot be resolved to an item or type.
silly question: did you delete the var declaration in your rules?
Also you may try postUpdate rather than sendCommand, as Numbers do not really take commands
By the way, it is helpful if you use the code fences when formatting rules or logs or anything; they are at the top line of forum window where you type things in and they make for great formatting and easier reading.
Glad you got it to work.
Just one more thing: while your version works, it is more recommended (by those in the forum who know much more than me) to use item.postUpdate(value) or in your case test11.postUpdate(1)
doing so apparently can help avoid some issues down the line.