CoRE - Get peer assistance here with setting up Pistons

enough sense for me

1 Like

Hi I have just moved my whole smart things setup to core but I am having trouble. I have modes for morning afternoon evening and night setup. I want a piston where I can say if movement is detected, and it’s in this mode then turn light in with xxx brightness, idea is different bright was for each Mode, then want the light to go off after a different amount of time for each Mode. Wanted to try and do this in 1 piston but nothing works, end up having ; pistons for each light for each Mode. Help really appreciated

Would it be possible to make this welcome home piston speak a random phrase from a list?
The monotony of hearing the same message everyday won’t last long.

Simplest way without major modification to your piston is to change the Speak task to something like… use Expression instead of Value

Speak text random(“text1”, “text2”, “text3”)

2 Likes

Thanks. Let’s see what I can figure out.

OK I’m getting nowhere. Would you please give me an example.

In your existing piston, click on the Speak text "Hello Barbara, welcome home."; task towards the end of your piston. In the value field, replace this:

Hello Barbara, welcome home.

with this:

{random(“Hello Barbara, welcome home.”, “Hi honey, welcome, you’ve been expected…”, “Hi sweetheart, so good to see you…”, “Hi Barbara, it’s so good you came home…”, “Hi Barbara, home arrived you have”)}

Copy and paste that text varbatim. Then save and enjoy your random text. You can add as many as you want, just add another comma and another “text” before the closing parenthesis ).

The { } signify you’re using an expression inside that value. The random() function will randomly selected one of your arguments - it works differently if you pass 1 or 2 arguments, so make sure you have at least three. random(10) will give a number between 0 and 10, random(10, 20) will give a number between 10 and 20, random(a, b, c, d, e, … z) will give one random item from the list provided. And since this is an expression, you need to encapsulate all strings in either single quotes ' or double quotes " - I prefer double quotes so that you can use apostrophes in your text.

You can also use an Expression field (which is more natural given the context). For that, you no longer need to use the { } curly brackets:

random(“Hello Barbara, welcome home.”, “Hi honey, welcome, you’ve been expected…”, “Hi sweetheart, so good to see you…”, “Hi Barbara, it’s so good you came home…”, “Hi Barbara, home arrived you have”)

It’s up to you, if you want to use a value field, or an expression field. They will both do the same thing.

2 Likes

You forgot “Hi Barbara, Make me a sandwich”

1 Like

Honey! I’m hoooooome! Hide the youngling, or else…

1 Like

That was so much simpler than what I was doing wrong. Thanks very much.

1 Like

I’m on my phone, hopefully this image will show up. I’m new to coding all together, new to core.

This is the first simple one I’ve done however I have issues with it. It’s doing what is suppose to do by running the THEN actions when a sensor leaves however I want it to run only when the last person leaves.
. It almost seems like it needs an IF action. My wife and I differ our mornings when we leave so it could be either one of us leaving first any given day.

Change it from ‘any of’ to ‘all of’ ‘is not’ present.
Then you will both have to be away for it to be true.

So changing the values to evaluation mode to “all”, comparison to “is” and value to “not present” gives me “Each of Anthony or Shayna presence is not present”

That logic would work to address what I’m looking for? I can’t find anything to change the condition to read “all of name or name presence is not present”.

To answer the first part of your question, then yes, I think it should work.
You both have to be away and that will only be when the last person leaves.
I’m not quite sure what you mean in the second part.

Hoping someone can help me out here. I am trying to have a light turn on when a door is opened, and turn off when closed, except that if the light was already on prior to the door opening, I do not want it switching off when the door closes - so basically do nothing if the light was switched on manually prior to the door opening. The only way I could figure it out was to use two pistons. But the 2nd piston (follow-up) seems to trigger when the door is closed, no matter what and turns off the light.

This is one ingenious bit of coding!

If I’m reading this correctly the presence sensor changing to present starts a 20 minute timer and only if the door opens in that 20 minute window it plays the welcome home notification, correct?

And also, what is the 6 second wait right before the play command for? And why is it tagged as “only while”?

Thanks in advance, this could get major brownie points with the wife lol

The original code was written by @Townsmcp. I modified it with the help of @ady624 and @eibyer.
I have no coding experience (until now) and owe it all to them. I’ve added 60 greetings, inspirational messages, and one liners in hopes of not getting the same message to often. I owe that to insomnia.
Edit: The 6 seconds wait (increased to 10sec) was added to give time to get to through the entry to the main kitchen where the speaker is

Ahhh gotcha, does it work like I described above? And any clue as to that 6 second timer?

Yes works just as you described.
The 6 seconds wait (increased to 10 sec.) was added to give time to get through the entry to the main kitchen where the speaker is located

Ahhhh I see, thank you very much!