Hi,
I have just integrated my entrance gates into openHAB via a Shelly Plus 1. For determining the status of the gates I have connected the device to a gate open indicator terminal, which is actually intended to drive a light, in openHAB I have a Point of type Switch for that, with ON indicating the gate is open and OFF indicating the gate is closed.
Now, the challenge: while the gate is moving, the light is flashing, so the Switch goes ON/OFF in circles until the gate is fully opened or closed.
I would like to translate this into a proxy Point, which has three statuses: OPEN, MOVING and CLOSED.
I have been mulling this a bit, and the only thing I could come up with is a rule that is triggered on a change of the gate indicator switch, then waits for a time that is longer than the flashing interval and then checks using the gate indicator switch’s status history if the state has changed in that time.
However, this does not seem to be very elegant, and also I could not really get it to work so far.
So my first question would be: does anyone have alternative ideas how to solve this?
And my second, maybe someone knows why my attempt is not working. I tried to test it with this code, but even if I flip the switch during the sleep time, the changedSince always returns false.
var sleepTime = 5000;
var openIndicatorName = "TestSwitch";
console.info( "TestSwitch: *** Start ***");
var openIndicator = items.getItem( openIndicatorName );
var checkTime = new Date();
console.info( "TestSwitch: State=" + openIndicator.state );
java.lang.Thread.sleep( sleepTime );
console.info( "TestSwitch: State=" + openIndicator.state );
console.info( "TestSwitch: ChangedSince=" + openIndicator.history.changedSince( checkTime ) );
console.info( "TestSwitch: *** End ***");
The output looks like this, the state changes, but the changedSince still returns false.
2023-01-22 21:34:48.401 [INFO ] [nhab.automation.script.ui.7556f69259] - TestSwitch: *** Start ***
2023-01-22 21:34:48.402 [INFO ] [nhab.automation.script.ui.7556f69259] - TestSwitch: State=OFF
2023-01-22 21:34:53.403 [INFO ] [nhab.automation.script.ui.7556f69259] - TestSwitch: State=ON
2023-01-22 21:34:53.486 [INFO ] [nhab.automation.script.ui.7556f69259] - TestSwitch: ChangedSince=false
2023-01-22 21:34:53.487 [INFO ] [nhab.automation.script.ui.7556f69259] - TestSwitch: *** End ***