Can't easily test this piston, does it look like it will work?


#1

1) Give a description of the problem
As per the title, I can’t easily test this piston - the trigger is a notification of lightning being detected via a Smart Weather Station and IFTTT. Later this year, WeatherFlow plans to have ST integration, but until then, I want to create a simpler rule using IFTTT.

With that being the case does the code look OK?

2) What is the expected behavior?
Only activate the rule If the Pool Sonos status is Playing.
If Lightning is detected/reported via IFTTT, speak a message and resume.

3) What is happening/not happening?
Can’t tell as there is no lightning - how does the piston look?

**4) Post a Green Snapshot of the piston

5) Attach any logs (From ST IDE and by turning logging level to Full)
N/A

(PASTE YOUR LOGS HERE BETWEEN THE MARKS THEN HIGHLIGHT ALL OF THE LOGS SND CLICK ON THE </> ICON TO FORMAT THEM)

@Mike1616


Sonos - How do you check/report the play state of Sonos (to set a variable)?
#2

I’m not sure how to judge if your pistonnwill work but are you aware that webCoRE has built in integration with weather underground?

https://wiki.webcore.co/Weather

Though I’m also not sure if WU alerts contain lightning information?? @ahndee might know?


#3

Unless something has changed apparently not :cry:


#4

The statement in the red box will never execute. It’s nested inside a “If Sonos changes to playing” statement, which will evaluate false as soon as it “moves away from playing”.

I’d drag that IF/Then statement outside the first IF, so it’s a standalone condition.

I’d also change the first IF statement to “is playing”, otherwise you’ll only get the warning if lightning is detected at the moment you start playing your Sonos. If lightning is detected even 30 seconds later, it wouldn’t be announced by the piston because “changes to playing” would evaluate false.


#5

@Robin and @ahndee, thanks for the suggestion and the feedback. Looks like I will stay with this temporary solution until WeatherFlow implements their ST integration.

@michicago, thanks for both bits of info. I have updated it below, but just for clarification, line 18 should still use the comparison ‘changes to’, EDIT: or should it be the condition ‘is’?


#6

You got it on the 2nd one… Change the condition to “is.” That will evaluate true any time the Sonos is playing. “Changes to” only evaluates true briefly was the Sonos switches from not playing to playing.


#7

Line 18 has been changed, and for one last confirmation, line 29 will still stay as;

status changes away from ‘playing’


#8

Ah, I’m glad you pointed out status. That’s usually for online vs offline status, but I don’t have a Sonos to confirm.

Can you so me a favor, click on one of your IF conditions for your Sonos, then click the drop down menu where you have Status collected, and post a screen shot so I can see what parameters are available?

Everything else looks good!


#9


#10

all you should you need is:

if IFTTT executes 'TempRisesAbove'
and
Music Player 1 status is 'playing'
   with Music Player 1
      Speak text
   end with
end if

why use the @poolBBQSonosIsPlaying variable?


#11

I am new to all of this and thought Iit needed a variable in there?? My whole experience with code is from what I have learned here in the past 2 weeks. Looking at other pistons and also some help from some other members here with a couple of other topics I posted in.


#12

ok. no dont need a variable. just use the snippet i posted above and it will work fine. that should be the entire piston.

btw are you trying to play the same message on multiple sonos players?


#13

No, just on the one speaker.

The eventual plan (once WeatherFlow gets ST integration) will be to have different messages based on how far away the lightning has been detected. For each of the 35km, 20km, and 10km distances that are reported, I will only want specific messages for each of those distances announced once, and then each time the less than 5km alerts are received, I will want its message played each time.

It might be something like;
35kms - It looks like some weather might be on the way
20kms - the storm is getting closer, consider getting out
10kms - it is getting pretty close now, get out of the pool
5kms - ok, the party’s over, get out now you fool! Do you have a death wish? etc etc.

I love the random function which I have used in my reminder loops, and will probably have several different messages randomly chosen for each of the distance steps.


#14

ok. have fun :slight_smile:


#15

So just this simple?


#16

yep


#17

Looks like it works OK. Was in the pool the other day and messages we being played on the right speak. :slight_smile: Thanks for your help.


#18

I didn’t think that the Sonos integration of resume playing after a speaking command worked? Is it working now? I’d love t use it if so. I figured you’d have to save your trackURI in a variable and then have it play that variable at the end of the piston.


#19

Yeah, it was working back in Feb when I reported on it. Haven’t used it since then as I haven’t been in the pool when a storm was coming, but it was working.