Play announcement if SmartThings Multisensor is open for period of time


#1

I am new to WebCoRE, so I apologize if this is really simple, but I can’t figure it out.

I have a SmartThings Multisensor attached to our freezer, which keeps being left open. I can have Alexa notify us if it opens through the Alexa app, which is useless in this case. I have added the Something Left Open app to ST, and it can send a push notification to my phone if something has been left open for a specified period of time. I have also added Echo Speaks, because I have read several times that it is easy to use WebCoRE and Echo Speaks to get this to work.

I have gotten this far:
execute

if /* #1 */

Freezer’s DeviceWatch-DeviceStatus stays Freezer’s contact for 2 minutes /* #2 */

then

with /* #3 */Echo - Family Room Echo Dot, Echo - Living Room Echo Dot, and Echo - Office Echo Dot
do

playAnnouncement() (only while Night, Home, or Away) ; /* #4 */

end with;

end if;

end execute;

I think that my biggest problem is that I can’t figure out how to add text to the () after playAnnouncement. When I click on it, it just opens the window for the GUI. I assume I am supposed to put the script I want said into the (), but I don’t know how. If someone could please tell me what I am missing, I would greatly appreciate it. If there is a better way, I am wide open to ideas.

Thank you in advance!


#2

Hello, and welcome to the club… :sunglasses:

When learning here in webCoRE, it really helps to break it down a bit. For example, since Echo Speaks is new to you, it helps to create a single line piston, with no IF block. Just a single command going to a single Echo device. You can easily save that piston, and press Test to see (hear) the results.

This is a great way to play around testing the various commands available.
(without thawing out your freezer, LOL)

Note: some commands only work with certain versions of Alexa.


There is a nice breakdown of the Speech commands over here.


Once you are happy with the speech results, I think this basic structure would do the trick:

IF Freezer's contact stays open for 2 minutes
Then
    With Echo1 and Echo2
    Do (speak command from your last test)
END IF

#3

I haven’t had luck with playAnnouncement, but executeSequenceCommand(..) works for many people.

You can add a string parameter by pressing “Parameters” at the bottom:

pic

If you want to copy paste, here is that Value field:
volume::50,, speak::The ice cream is melting,, volume::30
(the double commas and double colons are required)


Other commands from my previous link work the same way.


#4

Thank you! First, the comment to do one thing first was a really good point. I was able to get Alexa to say “Go close the freezer.” The component I was missing was the parameters drop-down. Like I said, it had to be something obvious…to someone who is not a complete noob. In fact, I was able to use the play Announcement command with no problem.

Of course, now I am completely doubting myself as to the actual if statement. I want the announcement to play if the sensor has been open for 2 minutes. (It is pointless to get an announcement every time someone opens the freezer to get something.) I’m not sure if I should be using DeviceWatch-device status or if I should be using contact as the what to compare, and I am not sure what kind of comparison I should use. I fully recognize that this syntax will all make sense once you explain it, but I am stuck.

Thanks again!


#5

I have figured out that what I had as my condition is definitely NOT correct. Instead of playing a message when the freezer has been open for 2 minutes, it plays a message 2 minutes after it has been open for any length of time. Oops. :blush:


#6

I would probably start out with my earlier suggestion…

IF Freezer's contact stays open for 2 minutes
Then
    With Echo1 and Echo2
    Do (speak command from your last test)
END IF

#7

Then I am missing something else basic. Is there a way to type rather than using the drop-downs? What I have not been able to figure out is how to put “stays open for 2 minutes” into the argument.


#8

No problem at all… Here are the steps:

+ add a new statement
Add an IF
Add a condition

… then use this pic as a reference:

pic


Not really… Although certain code can be typed out in an Expression box
(usually saved for advanced coding)


#9

Sorry it has taken so long to get back on here. I actually thought I had the piston running, but I went to my garage and realized that the freezer door was open. I changed it to play an alert if the freezer door is open for 10 seconds, and nothing is happening.

Thank you in advance for any help!


#10

Your trigger looks good. Perhaps your issue is with your speech command?


Pro Tip:

You can set your Log Level to Full to see what is happening behind the scenes.


#11

I did this:

When I test this one, it works in my office (which is Music Player 3).

I tried redoing the freezer one to match more closely:

However, it still doesn’t work. I then tried something simpler, with just open status instead of a timer:

That is also not working. I did notice that some of my pistons say “true” next to their names and others say “false.” I don’t know what that means.

What should I be looking for in the log? Also, what else should I be doing to troubleshoot?

Thank you again!


#12

I would edit line 18

pic

and make sure the right device is selected. (notice the gibberish here?)


As far as logs go, setting it to Full will write whatever is happening down below.
(you could post the text here after any errors)

Once your piston is working well, you can return Logs to a lower level, or off.


#13

Success!!! Thank you, thank you, thank you!


#14

No problem. Glad to help.

Perhaps you can solution one of my posts above to help others?