Hi all,
I have written a script to update recursively the status of all items of a group (and subgroups).
This is mainly because binding do not accept the “all lights off” from the scenary controller, so i’ve set the scenary controller to also send a specific command to openhab to update the light status.
The script spend about 1,5 sec to run. During this time an item should receive an “ON” command, but the script will overwrite the status although the status has arrived after the script invocation.
In java i can use the ReentrantLock object, but i can’t find anything similar in js scripting.
No, scenaries controller turns lights On/off during scenary activation. Sometime this is done by sending a special comand to all lights to turn all off. This command is however not recognized by openHAB binding so the light are off but the status in openHAB is still on. To overcome this problem i created the script that only update the status of items (do not send the command). Script is invoked everytime the scenaries controller send the ‘All off’ command. Problem is that the script needs about 1,5 sec. to complete and If during this time a light receive another status update, this is overwritten by the script.
What i need is a way to handle concurrency (like in databases for example) so that items will be locked at script start and any other update will wait until the item has been unlocked.
The scenaries controller is faster than openHAB so it send an ‘all off’ to all light (and lights switch off) and few milliseconds later it send a light On to specific lights and that switch On.
After few milliseconds openHAB send a switch off to all lights as the rule triggers, and all lights switch off again
I am wondering why the lights don’t report their status back correctly to openHAB. E.g. my KNX installation reports the status of a light when that light changes, no matter of the reason.
What binding are you using and which system are your lights?