Arrival of people including multiple people at once


#21

just restore it and set the presence sensors, names and contact sensor and it will work. :smiley:


#22

OK, I have imported it and set everything up. I added a Push Notification also right under the Speak Text. I will let you know tomorrow if it works.


#23

I think your piston is missing something. There is nothing that makes the contact sensor Closed.


#24

So I changed the contact sensor to “is closed” and that worked but when both my hubbie and I came home together, the push notification came through on the phones as Welcome home Tom and then Welcome Home Tom and Jane. However the speaking said Welcome Home Tom and Jane.:grin:
So it works for the most part just the push notification needs some adjusting. Any suggestions?


#25

Yes, setting the sensor to “is closed” is what I originally suggested.

But because the whole section IF section is async, it’s going to run through all of the code it when Tom arrives and then rerun it through when Jane arrives. Each time it runs through, the PUSH is sending what the variable is at that time. But the speaking is delayed, so it’ll only speak what the variable is at that time, which is the accumulated StringWho. Technically, I think it should be trying to make both spoken announcements, but maybe because they come right on top of each other the speaker is only playing the most recent one. Your PUSH also needs to wait for the variable to update in case there is a second/third person arriving within the same window of time.

But I still don’t think I know how to fix this though, because whatever you do is going to run through the entire piston each time it executes. So it’s not like adding another variable for number of people > 1 will fix it; the first time it executes the number of people will be 1. You need it to stop executing for the first of multiple people, so maybe use global variables (remember to reset them after a time) and change the second IF to synchronous.


#26

I set a wait of 20 seconds to send to push notification so maybe that will let it gather the multiple people arriving and then just send the one notification. Trial and error. But we are much further ahead that is for sure! I wouldn’t have been able to get this one in my own. Thanks so much for the help!


#27

If you want to do more testing without kicking Tom & Lauren out and begging them to return, create a couple of virtual switches (don’t forget to share them to webcore, but I know you know how to do this from another thread) and change the presence sensors to those switches (and use “on” instead of “present”) in your piston. Then you can flip the virtual switches from the app on your phone and see what happens. You can try flipping the VirtualJane switch, count to 10, then flip VirtualTom, etc. Once the piston and all resulting actions work the way you expect for every combination of events, change them back to presence sensors and you should be good to go.


#28

That is a good idea! Right now this is the piston I am using. I will test it using jsducote method.


#29

sorry to tag on but i have been trying to do the same with one that wasn’t working fully. I have taken @pcgirl65 and adapted it to mine would this work correctly with also letting you know who left?

The only thing I don’t understand is the GET request, what is that for?


#30

The GET request allows me to connect through my Sonos speakers through a node server on my unraid server. I can do more with the speakers and the speech is more natural.


#31

Like the sound of that how do I do it :smile:


#32

I posted how I did it here . If you need help, let me know.


#33

Is your piston working?


#34

yes but i made a few changes to get it working better will edit my post again when i’m done. The only thing that doesn’t seem to work quite right is on the leave if we both leave it says “emma, steven” rather than “and” where as the arive does “and”.


Presence senor info and advice needed
#35

Edit: piston superseded

Hoping this will work with my ring doorbell but still have to do some tests not sure if the add 1 to the variable on each loop is right or not yet. also still need to work out the “and” bit. @bangali could you shed any light on that?


#36

lines 46 thru 51 does the and part. was that what you were looking for?


#37

Not quite, I straight copied that and it works but because I use it twice ( for the else) it doesn’t seem to work the 2nd time. I’m also struggling to count every times it runs on the arrive side. I wanted it to count every time it ran and added that too the speakerCount variable so that if it looks more than twice it breaks and clears the variables.


#38

sorry didnt quite get this part?


#39

I copied your code for “then” and used it twice on the same piston. 1st where it originally was then again on the else part of the IF.

IF pressence changes to present
Then do X (run your code for whoArived)
Else do Y (run your code for whoLeft)


#40

This should work now it also has protection in it to stop it looping if you use a presence detector to trigger the speaker like I have.

@bangali I created another integer of “ii” and swapped that in you code for my else part so the and should work now :slight_smile:

edit: the “and” still doesn’t quite work :frowning: