This is just a general which way should I do this and why type question…
I have a piston where I want to compare $now to a time range and then base the response on where the current time falls. For example…
Between 10 PM & Midnight light is 100%
Between Midnight & 2 AM light is 75%
Between 2 AM & 5 AM light is 50%
…
Since we are comparing to the same value it makes sense to me to use a switch statement. But when I try to design a switch statement using a virtual time device I get this dialog…
No virtual device for Time is available
However, if I use an IF statement I get this dialog…
Is this webCoRE’s way of telling me it’s a bad idea to use a SWITCH (and I may cause the heat death of the universe if I do), webCoRE never thought anyone would try this with a SWITCH statement, it wouldn’t work for some other reason, or for some reason it’s just better to us multiple IF statements and do each comparison individually.
Using multiple IF statements will work - it just doesn’t seem quite as elegant as a SWITCH statement.
More of a inquiring minds want to know question
==================
Follow up question. When using an IF statement you are presented with a dialog that allows you to set hours:minutes for the comparison:
However the code shows hh:mm:ss:
Is there a way to set the seconds in the evaluation to avoid overlaps (and webCoRE freaking over two incompatible statements)?
If I use a time comparison of
20:00 and 00:00
I get code
Time is between 8:00:00 PM and 12:00:00 AM
and a time comparison of 00:00 and 0500
I get code
Time is between 12:00:00 AM and 5:00:00 AM
Those two comparisons give me an overlap for each condition fro 00:00:00 AM until 00:00:59. It seems to me to be better to use 23:59:59 as the ending for the first statement to remove ambiguity from the time comparison.