I did log everything…
newState updates to value STOPPED and CLOSED. currState and prevState both update to the value of newState… It doesnt make any sense.
This is what happens, when I hit the button to open the door, and I hit the button again to stop:
2019-11-29 00:49:34.928 [INFO ] [eclipse.smarthome.model.script.debug] - newstate is UNDEF prevState is newState currState is newState
2019-11-29 00:49:34.965 [INFO ] [smarthome.model.script.debug STOPPED] - newstate is STOPPED prevState is newState currState is newState garage door is newState
2019-11-29 00:49:34.970 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Garage door status': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.State) on instance: null
This is what happens, when I hit the button again to close the door.
2019-11-29 00:51:03.887 [INFO ] [eclipse.smarthome.model.script.debug] - newstate is UNDEF prevState is newState currState is newState
2019-11-29 00:51:03.904 [INFO ] [smarthome.model.script.debug STOPPED] - newstate is STOPPED prevState is newState currState is newState garage door is newState
2019-11-29 00:51:03.909 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Garage door status': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.State) on instance: null
And when it closed:
2019-11-29 00:51:11.697 [INFO ] [eclipse.smarthome.model.script.debug] - newstate is UNDEF prevState is newState currState is newState
2019-11-29 00:51:11.709 [INFO ] [.smarthome.model.script.debug CLOSED] - newstate is CLOSED prevState is newState currState is newState
2019-11-29 00:51:11.727 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Garage door status': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.State) on instance: null
2019-11-29 00:51:11.962 [INFO ] [eclipse.smarthome.model.script.debug] - newstate is UNDEF prevState is newState currState is newState
2019-11-29 00:51:11.976 [INFO ] [smarthome.model.script.debug STOPPED] - newstate is STOPPED prevState is newState currState is newState garage door is newState
2019-11-29 00:51:11.982 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Garage door status': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.State) on instance: null
2019-11-29 00:51:12.008 [INFO ] [eclipse.smarthome.model.script.debug] - newstate is UNDEF prevState is newState currState is newState
2019-11-29 00:51:12.021 [INFO ] [.smarthome.model.script.debug CLOSED] - newstate is CLOSED prevState is newState currState is newState
2019-11-29 00:51:12.025 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Garage door status': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.postUpdate(org.eclipse.smarthome.core.items.Item,org.eclipse.smarthome.core.types.State) on instance: null
The sensors are “flapping” but that can hardly be the reason why the item doesnt update.
This is the rule incl logging:
var String prevState = null
rule "Garage door status"
when
Item GaragePortBottomSensor changed or
Item GaragePortTopSensor changed or
Item garage_bryggers_NV changed from OFF to ON
then
var newState = UNDEF
val currState = GarageDoorState.state.toString
logInfo("debug", " newstate is " + newState + " prevState is " + prevState + " currState is " + currState)
// Garage door fully closed
if(GaragePortBottomSensor.state.toString == "CLOSED" ) {
newState = "CLOSED"
logInfo("debug CLOSED", " newstate is " + newState + " prevState is " + prevState + " currState is " + currState)
}
else
// Garage door fully open
if(GaragePortTopSensor.state.toString == "CLOSED" ) {
newState = "OPEN"
logInfo("debug OPEN", " newstate is " + newState + " prevState is " + prevState + " currState is " + currState)
}
else
// Door is in motion
if(currState != "STOPPED") {
newState = "STOPPED"
logInfo("debug STOPPED", " newstate is " + newState + " prevState is " + prevState + " currState is " + currState + " garage door is " + GarageDoorState.state.toString)
}
else
// Door is partially open but not moving
if(prevState == "CLOSING") {
newState = "OPENING"
logInfo("debug OPENING", " newstate is " + newState + " prevState is " + prevState, " currState is " + currState)
}
else {
newState = "CLOSING"
logInfo("debug CLOSING", " newstate is " + newState + " prevState is " + prevState, " currState is " + currState)
}
// Could use persistence for this, keep track of the previous state so we can handle the STOPPED case
prevState = currState
GarageDoorState.postUpdate(newState)
logInfo("debug PostUpdate", " newstate is " + newState + " prevState is " + prevState, " currState is " + currState)
end
// Proxy items
// String GarageDoorState