Get a sound to repeat over and over until an event change?


#1

So I’m working on a fire alarm piston. I think I have everything good to go but the sounds. I know how to play sound through my Google Home speaker. I’ve done it before when it came to my garage door being open/closed. But I don’t know how to get a sound to repeat over and over until some event happens.

Like I want the sound to blast over the Google Home speakers over and over until the smoke alarm gives a clear or I press a trigger. How would I go about this?


#2

Can you show the piston that begins the sound?


#3

Sure. Music player in this is the google home speakers.

There is a rule for smoke and another for CO2 for each detector. I only have 2.


#4

Oh, it is simply “Play Track”…?

Have you tried sending “Stop”, “Pause” or “Cancel”…?
(every handler is worded a bit different)

If those fail, why not simply play another track to stop the current?
(A 1 sec silent MP3 should do the trick)


#5

I am currently using something like this http://techreviewsandhelp.com/wp-content/uploads/2019/06/Garage-door-open-online-audio-converter.com_.mp3

Where i tell it to go there and get the sound. I would like to find a local area, but in any case. What I want is where I can make my own alarm and just have it on repeat until the smoke is cleared or I hit some trigger. Like I can get it to shut up if it’s a false alarm. I will have to work on that last bit later. But the repeat part I can’t figure out


#6

Let’s try this from a different angle:

Once webCoRE sends a command to the hub, it has no way of knowing anything about the track. It does not know the length, or whether it worked or not… and it has no clue when the track has finished playing…

What this means for us: To loop a sound, there has to be some kind of “controller”:

  • The device may be able to loop natively, or…
  • It could be looped via a third party app/service, or…
  • your Device Handler could *ahem* handle it…
  • or you could code it manually in webCoRE.
    (IE: Learn the length of the track & program webCoRE to periodically keep sending commands… adding a bit extra delay to account for buffering etc)

Any of the first 3 are decent possibilities, but personally, I would avoid using webCoRE to spam devices.


If the first 3 fail, what I prefer is to acquire (or create) a longer sound clip.
(longer than you would ever need)

Then webCoRE can send a single command to begin playing that long track.

… and your focus will only be on the aborting aspect, as mentioned in my last post.


#7

Google home treats it as a broadcast, so I don’t think it will loop it. I will test it later to figure it out.

Anyways, I think I kinda figured it out. Just do a repeat loop with a wait. The thing was hidden under advance statements.


UPDATE: It seems I can’t put a wait command before the repeat loop. What I was wanting is to put a wait before the repeat to give everything time to do what it needs (unmute and max volume). How can I do this?


#8

My apologies, but I do not want to give bad advice.


#9

It’s OK. Do you know how to make a wait command within a Do command? I’m trying to make the repeat loop wait before it starts.


#10

A WAIT can be added any place you see:
+ add a new task


#11

This is what I’m seeing. I’m trying to add it before the repeat (where the arrow is) so the repeat doesn’t have to wait when it’s repeating. I’m just trying to get it to repeat the first go around so a few other things can happen.

As you can see, it is looking for a statement and not task.


#12

Add a new statement using ‘Location’ as the device

image


#13

You need a “container” to be able to “add a new task”

For generic commands like WAIT, I use “Location” as the device, as @fieldsjm mentions above.


#14

@fieldsjm @WCmore Would this work? Where it pauses it for a few seconds prior, and then it starts the repeat loop?


#15

That little tiny snippet looks ok for the first loop…
… but what do you expect to happen on loop 2 or 3?
(remember, weCoRE has no clue when the track ends)


#16

From my understanding the repeat will keep repeating until it the condition is met.
I’m still working on the audio, but when I figure out how long the audio will be. I will have the Google Home devices broadcast the audio. Based on how long the audio is, it will have a wait so hopefully the repeat will wait slightly longer than the audio, and it will report the last 2 steps (pay audio and wait).

The condition to stop this is when the smoke alarm isn’t going off anymore. I’m going to make another where when you press a button it stops that too. Like if someone is cooking in the kitchen, and triggers the alarm, but everything is under control.

image


#17

You see where I was heading with that… :grin:


#18

I’m thinking the 2 wait times will be different. The wait time for the sound to start needs to be about 6 seconds in. Around the first second or 2, it will save the settings (volume, mute, etc). After 5 sec it will change all this to unmute the devices and max volume. After the 6 second it starts this audio blast. I’m thinking the audio most likely will be closer to 3 seconds. So after 4 seconds after it will repeat the loop until the alarm is cleared.

Once the alarm is cleared, it will put everything back to how it was. Speaking of, will a simple if statement allow for this?


#19

You are going to hate me for pointing this out… but it deserves repeating.

SmartThings (and webCoRE by association) is horrible at spamming.
Absolutely. Freaking. Horrible.

A 4 sec WAIT on repeat can be anywhere from 2 to 12 seconds between actions.

  • Your audio clip will sound choppy.
  • The spaces between will not be consistant
  • Sometimes, a sound will begin before the old one finishes
  • Your pistons will often get semaphore delays
  • Your logic will often be misinterpreted due to said semaphore delays.

I really wish you gave more stock to my previous post.
(I am trying to prevent you from getting grey hair, LOL)


… That being said, you are more than welcome to ignore everything I have said, and see for yourself.


#20

I see what you’re saying. The exact timing isn’t actually as important as it is for

  • All lights to turn on bright, and a given color.
  • Speakers announce what is going on and which alarm. It being exactly 4 or 12 seconds doesn’t matter to me. It is more of can it alert you out of a dead sleep if you’re next to a speaker but away from the alarm. And will you have an idea on the situation within a timely matter.