Exec binding restrict to one process (serialize/semaphore access)

Hello, i am using openHAB for a few weeks and i think it will be the solution for my home automation. I am quite happy with it but i have the following problem.

I am using the Exec binding to call some scripts but they seem to get executed in parallel when i create time based rules. This means whenever i have hardware, like a RF transmitter connected i have a race condition. Whichever rule executes the hardware first, wins.

In reality, that leads to the case that one light gets switched on while others remain off. Still the event to switch on the light gets processed by openHAB. This results in the switch in the UI/App is showing “ON” but the light is “OFF”. Is there a workaround to execute/pipeline Exec calls?

If there is not, i probably will write an own queuing mechanism… or process light events by a MQTT queue with self written consumers/producers… which i really don’t have/want to do if there is a simple solution.

Regards,
M

Move your Exec binding calls to Rules using executeCommandLine. From within your Rules you can use an ReentrantLock to only allow one to execute at a given time. Or even better, consolidate and refactor the logic so there isn’t a conflict in the first place.

Thanks for the answer.

I can’t reconsider the logic because i have several switches which can be switched using one transmitter. This means, if you flick switches in the openHAB UI potentially there is concurrent access to the RF transmitter. Since the switches might be switched manually i can not tell the familiy to “switch not so fast” or “wait a bit”.

But i think i will create some rules and call the rules. I have used the lock in other rules but was unaware of moving exec calls to rules. Thanks for that hint.

If you moved the switching off the lights to one rule and toggle them in series instead of parallel there is no need for the lock nor simultaneous access to the transceiver, nor should timing be a problem unless the switch is tighten multiple times in half a second. That is what I mean by return the logic.