Rule error

In the openHAB designer there was an error for Weight.sendUpdate():
Couldn’t resolve reference to JvmIdentifiableElement ‘sendUpdate’

Items:
String Arduino “Arduino [%s]” (arduino) {serial="/dev/ttyACM0"}
Number Weight “[%s]” (arduino)

Rules:
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import java.lang.Integer.*

rule "Arduino sends to Openhab"
when
Item Arduino received update
then
var Integer newWeight = Integer::parseInt(Arduino.state.toString)
Weight.sendUpdate(newWeight)
end

change “sendUpdate” to “postUpdate”

Will do, I assumed it was, just relatively new to all this Home Automation business. Also doesn’t it require two variables inside the function? Or does it not?

That depends on how you use it!

item.postUpdate(the update)

…is directly attached to the item you’re updating, so you only specify what you’re sending. Whereas …

postUpdate(item,the update)

…isn’t directly attached to anything, so you have to specify what you want to send an update to as the first argument.

1 Like

Thank you! :slight_smile: