How to play a sound at randomized time intervals

I have a large wooden barn which is much appreciated by the woodpeckers around here, making quite large holes. Until now, nothing worked to repell these birds: different kinds of paint, reflective material, fake birds of prey. One thing I didn’t try yet, is playing the woodpecker alarm call. This seems to scare them off, especially if played in early spring, when territories are set.

So, now I have a track of the alarm call and 2 old sonos speakers in my barn, that are connected with my homey. The alarm call is most effective if it is played between sunrise and sunset, at randomized time intervals, say between 1 minute and 1 hour.

I guess I have to make an advanced flow that states that if it is between sunrise and sunset the alarm call must be played on the 2 sonos speakers in randomized intervals.

How should I go at this? What does the flow look like? What must I script (like the time interval) and are there scripts readily available?

Something like this?

You could also use FlowBits to set a timer, that would improve stability. Since the flow isn’t in a waiting state, but will be triggered when timer is done, like this:

1 Like

My app FlowBits has a randomized timer card. Your flow could look like this.

1 Like

Lol i was just editing my own post with that suggestion :stuck_out_tongue:

1 Like

For testing I have set the delay between 1 and 60 seconds. It works so I can change the seconds to minutes

Edit 15:00; it’s better to switch the wait and ‘it’s before sunset’ card.
In the screenprint is possible that the flow restarts 10 minutes before sunset and waits for 60 minutes. In that case the sound will be played 50 minutes after sunset

1 Like

Thanks for the Flowbits tip!