Thanks for that, I did make my intention clear.
I am defining the variable, not the condition.
Setting modes based on time of day and presence
I have set this up but it seems to be firing Home Evening when home day should be fired.
I have four modes:
Home Day
Home Away
Home Evening
Away Evening
Evening is anytime when its dark
Day is when itâs day.
Any idea what iâm doing wrong here?
thank you
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
Haha, yeah!
â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.
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?
thank you
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
else
If less than sunrise then evening
else
if less than sunset then day
else
you left this part blank
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 ?
Thank you
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â )
Hey Robin
At sunset this evening it ran home day mode again
Any idea what else might be wrong ?
Thank you for your help.
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.