Can I put an IF inside a With/Do statement?


#1

I figured out what is probably the right way to do this (see below) while typing this, but my question is: Can I put an IF statement inside of a With/Do block? Like this:

With
MyLight
Do
If Date is 12/25 then
Turn Red
Else
Turn White
Endif
End With

I can’t see how to do that in the dashboard and maybe it’s not possible. But, I’ve been working on this a whole hour so far, so I’m no expert. Give me another hour or two for that.

I’m more curious about my missing something obvious because the right way to do this is probably to have an IF or CASE up front that sets a variable to a value, then use that value inside the Do part of that statement above.


#2

Try this

Just add your color change and your else statement


#3

Yeah, I saw I could do that, no problem. It would just be a little cleaner to invert that: IF inside the WITH, not the WITH inside the IF. Because in your way (and the only way I could figure), you have to repeat the WITH part of the statement over and over for each situation. If they’re flipped, it’s only the DO part that gets repeated, if that makes sense.

However, thank you.

And you actually answered something else I was going to have to figure out–how to specify a date, so thank you for that too!


#4

So in the end, you have a list of dates you want to set different colors for? If that’s your end-goal, I have an example of an array of dates that you could use to implement the same thing.

You should be able to set color using an expression, too. I don’t have any color capable bulbs though so I’ll attach a sample using piston tile colors instead.


#5

Here’s a sample… when you’re setting your bulb colors, can you select “expression” in the box? If you can, you can do something like this using the date as your condition the way @Gopack2 did above:


#6

Thank you for the pointers. No time to work on it now (and probably not until next week) but I’ll start playing around with it.

I’ve got two Hue Light Strips installed, one on either side of a 8’ sliding door. Now, they just come on in at 20% around sunrise as sort of a nightlight, but then I got to thinking…hey, maybe I can adjust the color on the temperature. Or make them blue if rain is in the forecast. And then I got to thinking, maybe I can make them red and green for Christmas and pink for Valentines. And maybe I can lookup the Cleveland Indians schedule and make them red and blue if they play that day (or won the day before). So…I don’t really have a specific plan. Just thinking about options.

Again…I appreciate the time!