Arrival of people including multiple people at once


#41

ahh ok. shouldnt require a copy of the entire code … using a conditional setting for arrived or departed should also work.


#42

how would that be done?


#43

i will post an example later.

just to be sure - you are looking to announce arrivals and departures. arrivals with contact sensor closing and departures after 30 secs from last departure?


#44

This piston is working great so far, apart from the and I think. Let me know if you can improve it.

Yes to arrivals /departures for single and multiple people. But log and announce arrivals (log only once but announce up to twice (just in case not in building yet)).

For departures log someone or more than one leaves and announce only if someone is still in the house and only once for both.

For me im using the motion stopping as I don’t have a door contact installed yet. But yes it would be better if i could have it so it happens 30 secs from last departure (at the moment its the same as arrive).

All this happens on my current piston apart from the departure after 30 seconds bit.

Edit: would this do that, ($now - lastNow) is equal to 30000?


#45

well if its working for you i dont need to write up another example. :slight_smile:

sorry thought you had some issues with the double copy portions of the code and that needed fixing or something.


#46

Yeah still having a issue with the text bit but the main bit I think it running well. Still need to run it abit more to be sure. I would also like to trigger the leave bit 30s after the last departure, rather than the contact, could you show me how to do that please?


#47

try this:


How to send random text messages from a list
Help with Arrival Piston (Sonos Welcome Home)
#48

Just testing this out and seems to be working well, thanks for your help!

But I can’t understand the santex for the announce in order to change it to my liking if i wanted to so something like this for arive how would i do it?

Welcome home ($name or $name and $name), ($name or $name and $name) (is or are) in the house! woop woop, woop woop!

from this:
(whoI == 1 ? β€˜Welcome home ’ : β€˜β€™) + (i > 0 ? left(who[whoI], i) + ’ and ’ + right(who[whoI], length(who[whoI]) - i - 2) : who[whoI]) + (whoI == 2 ? ’ has left the building!’ : β€˜β€™)

Was thinking once i understood it would it be possible if it was set to on events from current place. you could announce when the person left and when they arrived at a new place?


#49

try this:

(whoI == 1 ? β€˜Welcome home ’ : β€˜β€™) + (i > 0 ? left(who[whoI], i) + ’ and ’ + right(who[whoI], length(who[whoI]) - i - 2) + ’ are’ : who[whoI] + ’ is ') + (whoI == 2 ? ’ has left the building!’ : β€˜ in the house! woop woop, woop woop!’)


#50

Don’t know how you do it! Awesome thank you! but it now makes even less sense to me :rofl::joy:


#51

mostly practice. you are welcome.

there are 3 parts to this.

this is what to say before the name(s):
(whoI == 1 ? β€˜Welcome home ’ : β€˜β€™)

this removes the last ',' if there and replaces it with 'and' in the names. also adds 'is' or 'are' after the name(s):
(i > 0 ? left(who[whoI], i) + ’ and ’ + right(who[whoI], length(who[whoI]) - i - 2) + ’ are’ : who[whoI] + ’ is ')

this is what to say after the name(s):
(whoI == 2 ? ’ has left the building!’ : β€˜ in the house! woop woop, woop woop!’)

whoI = 1 for who came home
whoI = 2 for who left home


#52

Yeah I think i’m starting to read it better i missed the closed brackets and didn’t read the equation correctly.

where do we put the names if we want to use them more than once?


#53

create another variable called names so:

names = (i > 0 ? left(who[whoI], i) + ’ and ’ + right(who[whoI], length(who[whoI]) - i - 2) + ’ are’ : who[whoI] + ’ is ')

then:

(whoI == 1 ? β€˜Welcome home ’ : β€˜β€™) + names + (whoI == 2 ? ’ has left the building!’ : β€˜ in the house! woop woop, woop woop!’)

also lets you use names as many times as you want in the message.


#54

Do i set the variable as that or do i set it as that during the piston run?


#55

run time.


#56

will i also need to wipe it on line 51 and 212?


#57

that piston is less than 100 lines so not sure what you mean?

please post snapshot.


#58

line 39 and 84 i must have been looking at the edit page, sorry :slight_smile:


#59

ahh … no you dont need to because the names variable will get set when its time to speak it.


#60

great :smile: So almost there so with the piston above i just departed and got this on the announce.

Goodbye Emma is Emma is has left the building!