Thanks for that, I did make my intention clear.
I am defining the variable, not the condition.
I have set this up but it seems to be firing Home Evening when home day should be fired.
I have four modes:
Evening is anytime when its dark
Day is when it’s day.
Any idea what i’m doing wrong here?
Assume you meant to type “I did not make my intention clear” lol??
Anyway… just use an expression instead of a preset:
addMinutes($sunset, 30) should offset sunset by 30 minutes.
You could also use addHours or addSeconds
“Robin, DIDNT I MAKE MY INTENTIONS CLEAR?? NOW GO CLEAN YOUR ROOM!”
Ill try that! Thanks a lot!
In your string for timeofDayHome you are saying that IF time is less than sunset (time2), then set location mode to Home Evening. Change this to set location mode to Home Day.
If you would like Home Evening to be set after sunset you need to add that if time is less than time3, then set location mode Home Evening.
With your modes, and the condition that “evening is anytime when its dark” and “day is when its day”, it could look like this:
($time24 < time0 ? ‘Home Evening’ : ($time24 < time1 ? ‘Home Evening’ : ($time24 < time2 ? ‘Home Day’ : ($time24 < time3 ? ‘Home - Evening’ : ))))
I have made the assumption that its only day between sunrise and sunset in the above example.
Ahh got it thank you very much.
I’ve been playing with this and haven’t been able to get it to work. No matter how I do it, it seems to do the opposite of what I want.
It setting home evening when it should be setting home day (at approx 8am today)
Any idea what i’m doing wrong here?
i’m getting this error in the logs over and over so i’m obvisuly doing something wrong
0/09/2018, 07:28:51 +109ms +325ms ║Invalid ternary operator. Ternary operator's syntax is ( condition ? trueValue : falseValue ). Please check your syntax and try again. +348ms ║Error setting location mode. Mode 'false' does not exist.
I am not at a computer at the moment, but all Ternary operators must have both a true and false available in the code.
So, for example
must have something after the last colon. It will fall back on that if the other 3 cases do not match
What @WCmore said.
Read it like this:
If less than dawntime then evening
If less than sunrise then evening
if less than sunset then day
you left this part blank
Thanks. That makes sense
Firstly this is a great piston, well it was prior to my hacks! I’ve put comments in the parts I’ve added to try to explain what I was trying to do in the snapshot but i’ll try to explain it a bit better here.
I’ve been trying to make the sleep time and wake time variable.
The sleep time one seems to work in so far as it changes the variable SleepTime to the correct time i.e. time now +10 minutes as per line 69 but here’s the problem, when this time comes it does not change the mode to sleep. All I’d really like this part to do is only change to sleep mode 10 minutes after global variable @SleepReady changes to true regardless of the time. This variable is set from another piston which checks who is home and then once all the people who are home have pressed their respective sleep buttons then it sets the variable to true. This is so when The wife goes to bed at 9pm for work the next day and I’m still up then the lights to not go out on me and all the motion detectors still work until I go to bed.
Now for the wake up time this is “supposed” to compare Wakeup time with dawn time and if wake up time is earlier than dawntime change the dawn time to whatever WakeUpTime is but only on a Tuesday, Wednesday, Thursday & Friday or a Monday if switch 7 is on at any other time i.e. weekends or not work Mondays then dawn time should be sunrise -1 hour. Last night I watched this one change the dawn time variable to 05:30:00 then this morning the mode did not change to home dawn until 05:50.
No laughing at my amateur hacks coding is sorcery to me.
I thought I had this working but home day is being set when home evening should be.
Home day works fine during day though.
Any idea what im doing wrong ?
Your expressions are all over the place and out of sequence… mixing < and > across the options is confusing. Should flow through the day in order, but you seem to be going backwards, starting with <sunset.
You should start with <dawn, then <sunset, with fall back of evening:
$time24 < dawntime ? 'Away Evening’ : ($time24 < sunset? ‘Away Day’ : ‘Away Evening’ )
At sunset this evening it ran home day mode again
Any idea what else might be wrong ?
Thank you for your help.
any chance you can have a look at the issue in my piston in posted above?
If you take a look at the screenshot, you’ll see how I am setting the various parts of the day. In your piston, you are setting variables that are already set within webCoRE itself.
That might be what is causing your issue.
On line 63 you are firing the piston at 20 minutes to sunset, should be after sunset (my example used 20 seconds after to avoid the piston running too early).
My only guess would be to drag and drop the scheduling part of the piston down to the very bottom (lines 54-64).
Pistons allways run from the top down, so it’s probably scheduling sleep time before changing the sleep time.