Allow NO INTERRUPT during for-loop in a rule

Good evening. I set up an audio clock by using my sonos multiroom speaker system.
So, every hour this rule executes:
for(var i=1; i<hour+1; i++) {playSound (Sonos_Uhr,“Glocke_1.mp3”) }

(ofcourse, the variable ‘hour’ is set previous automatically dependig on the actual time, 0…23).

Depending on the duration of my single audiofile ‘Glocke_1.mp3’ (approx 3 seconds) this rule may take up to several seconds , 24 * 3 sec, worth case = 1.5 Minutes approx.
My challenge: To get a harmonic sound by playing continuously the bell I like to ‘supress’ events which disturb this for-loop.
How may I achive this? warm regards in advance, Dirk

The rule will run as written uninterrupted. However, if you have other rules running at the same time that are interacting with the Sonos device or have previously started the Sonos speaker playing something then the two activities will become interlaced. I assume this is what you are trying to fix.

Unfortunately, there are only really complicated solutions I can think of right now involving ReentrantLocks, proxy Items, and several rules to coordinate how all of these rules interact with one another. And I’m not even certain it would ever work.

Or there is the very simple solution of just creating 24 versions of your sound file, one for each hour, and choosing to play that one continuous file on the hour. This would end up being far less work, much easier to implement, and be less error prone than trying to make it work through code.

Rich, you pointed it out - many thanks. Also I already thought about making 24 files …I think, this will be the best way to fix this interlacing.
Again, many thanks !

Dear @dikahab,

Can you please mark Rich’s post as a solution and not yours?
I think it would be fair at least!

Thanks in advance!



@rlkoshak already has 5 times more solutions marked than the second community member.
We are trying to catch him… don’t promote him ! :slight_smile: (just joking)

1 Like

No way you can beat that. I’m not even trying (I have only one! :star_struck:)!


ofcourse ! my fault - sorry for that!

1 Like