Help with sunrise offset, and review please


#8

Well put Ike. Your examples are (hopefully) more likely than the one I mentioned.

Another way to say this:
Even if your SmartHome is running at 99.9% efficiency, then one out a thousand triggers may “skip a beat”. On a lightbulb, it’s no big deal. Just toggle or reconnect, and you are back in business. But when Disarming an Alarm with a motion sensor, (that may fire 40 times a day), then that 0.1% error could occur once a month.

Just for comparison, if it was a physical button that disarmed it, you’d likely only be pressing it once or twice a day, so that 99.9% success could take you a couple of years before you experienced an error.


Pro Tip:
If you have ActionTiles, this would make a great tile to add to your panel. (If you want to confuse any would-be-criminals, you can change the button name to an “innocent” name (such as Pantry?). You don’t want uninvited “guests” pressing the obvious Disarm button)


#9

Well, I discussed it with my SO - he says he’s fine with the alarm not disarming when he comes down (90% of the time, it’s him that wakes up and comes downstairs first!). I don’t yet have an LCD panel in my kitchen (that’s coming!) but there’s an alarm panel by the back door he said he can use - the first thing we do is let the dogs out.

SO - here’s my new one - it DID work this morning (minus the alarm, of course). We agreed we’d STILL only like it to run once a day so we don’t have to turn off a light the other turned off earlier.

Reading/researching the “once per day” thing - it seems like this weird mystery, in that there’s no one easy way to do it. No one code, no one switch, instead you have to make up virtual devices that turn on and off, etc… Am I wrong, is there an easy way? What’s the best way? I have a few other things I’d like to run once per day as well.


#10

One of the ways would be pausing the piston once it’s triggered.

IF MOTION is activated
If time is between this and that
Then 
Do some stuff
Pause piston "Morning lights"

now you wil need a second piston to resume this one

Everyday at 4.00am (lets say)
Resume piston "morning lights"

other than that, variables and simulated switches are your best friend:)))


#11

Oh that’s interesting. So, pausing, variables, and simulated switches… Can you (or is there a place to read) explain some of these? Or pros and cons of each, at least? Pausing/unpausing sounds pretty ideal, but clearly the variables and simulated switches wouldn’t be a thing if they were!

Edit: Oh, and where is “pause” located? and “Resume”?


#12

Variables and Switches are for many different things.
Coding is - in a way - like art, or singing the same song from different tones:))))
Everybody has their own way of doing it.

Let me give you an example from my home:
My main entrance door must be closed at all times (3 cats:))) and it can not be left open more than 15 seconds.
If so, alarm will go off…

The piston is very simple.
But when you start adding scenarios to the situation, switches, variables, pausing are needed for you code.

a) A friend comes by and we’re chatting in front of the door and the door is open.
I don’t want to go through my phone and click buttons so that I can shut off the alarm.
It happens automatically
If motion detected in front of the door and if the door sensor is open more than 30 seconds - which means we are talking - a variable changes from FALSE to TRUE and diverts the pistons 15 second alarm time to lets say 2 minutes. Now for two minutes alarm will not go off…
and even 15 second is not a 15 seconds it’s a variable. I don’t have to write another IF block for 30 seconds, I can just change the variable within the piston. Not manually, piston does it by itself.

b) A worker came to the house. He is in and out constantly. Cats are in the back and their door is shut.
I don’t need the door alarm.
I can pause the piston BUT i have to remember the RESUME it.
So instead I use a simulated switch that is on the wall mounted ipad on Action Tiles.
60 minute delay switch.
If I push that button (simulated switch) switch is ON now and that tells my piston to ignore any warning for the next 60 minutes.

c) I’m not home but I know that day randomly a lot is going to happen. Maid, visitors, friends kid etc.
again cats are in their side of the house. And I don’t want to try to teach people to push a god damn button every 60 minutes LOL
I just pause the piston completely. Again through a simulated switch on the Ipad.
When that feature is activated, a timer piston starts, that day after midnight, piston is RESUMED again. To make sure that we don’'t forget…

How to find PAUSE and RESUME:
When you add NEW ACTION
First choice is LOCATION
don’t scroll down the list, just click ADD TASK
now you will see a DO LIST
Scroll down, you’ll see PAUSE
and 4 after that is RESUME…


#13

Oh wow, thanks for the explanation - I get it!

So in “a”, each time motion is detected in front of the door and the door is opened more than 30 seconds, the piston’s 15 second alarm changes to 2 minutes. So after that 2 minutes, if the conditions are still met (motion and more than 30 seconds) another 2 minutes are added because that’s just how the original IF works, right? So every 2 minutes, 30 seconds, the alarm is extended 2 minutes. Then the piston takes 30 MORE seconds and THEN does another extension of 2 minutes. Do I have that right? Or are the 30 seconds wrapped into that 2 minutes.

I think I need a nap!


#14

LOL
as I said there are many different ways of writing the same piston…

This can be one way, and it’s a good one.
Mine just changes 15 seconds to 2 minutes. No adding, no extraction, just changing the time frame.
(Just because I never needed more than 2 minutes) personal preference.
IF it looks like it will be more, I’ll intive the person in.
IF i don’t have time to invite them in that means I don’t have more than 2 minutes anyway…


#15

I imported your “xb8pb” piston above, and added two lines of code plus a variable.
This addition will only allow the code to execute once each calendar day.

This method uses no virtual device, no switch, no timer nor loop. :+1:


#16

Whew! Ok, so here’s what I’ve come up with… It seems odd to me to have the resume/time (which is a minute EARLIER than the actual piston time) be at the END of it all, but as long as it works…

Curiosity - how would I have inserted the “resume” at the BEGINNING of an already-written piston? Is that necessary? If my above one was good, apparently not. If so - how?


#17

RESUME has to be a seperate piston.
Because once you pause this piston, it won’t be able to function anymore.
Morning lights 2 lets say.


#18

That’s… Pretty elegant. Can you go a bit deeper and explain what and how for me please? I can SEE it working, but I’d like to know how it’s interpreted.

Update edit: and if it’s not too much trouble, the steps you took to add what you did, so I can learn it and use it on something else when I’m ready.


#19

Would I be able to use one piston to restart multiple pistons that I want to be “once per” that I’ve paused? At different times, even?


#20

Technically YES but depending on the system load you have. That piston might cause some signal congestion problems.

I have around 300 devices in my house and if i write a piston that resumes 15 pistons at the same time, I’m sure some will be missed in the process.


#21

I have to ask, just for personal knowledge and not being snarky… Why? I mean, if there’s a page of code, it’s all basically binary “yes, no” or “1,0” or “on, off” and they’re all “at THIS time set THIS thing to resume”… How would one be missed?


#22

it’s not missed, everything you ask is in webcore and ready to use…
Just not in a format you want and/or used to… that’s all…

I can write piston and say AT THIS TIME RESUME THAT PISTON…


#23

I think I get it. Thanks for all your time! I’ve got so much to learn!

EDIT: LOL I’ve reached the maximum number of responses I can do on my first day - can’t post anymore! :slight_smile:


#24

I get what you are asking now.
This post will answer better…

When you ran a code in a computer enviroment, it reads every single line, and does what it’s told to do.
In a Smart home enviroment things are different.
Webcore sends a signal to your hub and your hub sends it to that specific device.
And webcore works like a rain drop from top to buttom AND DROPS, it has no way of controlling if LINE 35 is properly executed. It only sends the signal (unless you write a complex code with fail safes)

Lets say you said, hey webcore turn my lights ON…
Webcore sends that to ST HUB, ST hub sends that to your smart light bulb.
but no one truly knows if that bulb is really on now. (unless you are checking it with other pistons etc)

ps : I’m not and advance user so this is just my limited knowledge.


#25
  • {$day} is a system variable. It updates itself automatically
  • {day} is a local variable I created. It only updates when the code tells it to

On the first run, {day} is empty, so it is different than {$day}, and the code executes. The very last line stores the day of the month (currently 12) into the local variable. If it tries to run again on the same day, the check will fail, and the block will not execute. Once a new day begins, the system variable {$day} will be different, so the check will pass once.


Line 17 = Options > Show Variables… Then Add a new variable in the define section
Line 26 = Add a new condition
Line 42 = Add a new statement > Location > Set variable


#26

Just wanted to say thanks for the help - it worked perfectly!


#27

Glad to be able to help…