SmartApp to automatically change bulb between colors

0-100 are valid values. Most RGB bulbs operate using Hue/Sat to set color instead of the hex representation of RGB, so that’s the format used in most device handlers. The color value in Rule Machine represents the Hue value (and assumes 100 Sat for full colors).

I believe Rule Machine also allows for Red and Green to be selected directly instead of custom color values, so that might be easier. Alternatively, you could find the colors you want with your bulb, then record the Hue values at those colors and use them.

1 Like

Tried using the predefined color names, but didn’t work.
I’ve got an AEONLabs ZW098-A52 bulb. Using the app to set the color to green, here are the values I get from the devices details in the IDE.

switch: on
level: 99 %
hue: 32.48366013071895
saturation: 100
color: #0dff00

Does that look right for the Hue value, or is the bulb doing something non-standard

It’s right. You can use either 32 or 33 for the color value in Rule Machine and it should give you something very close to that shade of green.

You have the one bulb that works a bit differently for color since it’s zwave, so the Aeon bulb calculates the Hue value in the device handler which is why it’s not an integer. Most color bulbs are zigbee.

With the Rule Machine, I’m trying to figure out how to have this run only when the light is on.
Or does that not really matter? Let it continue changing the color values even though the light is off?

Edit - found a solution. I created another virtual on off tile(vSwitch B). I created a rule that will turn vSwitch B off, when the light is turned on. Then turns vSwitch B on when the light is off. Finally on the original rule, under “Switch to disable rule when ON”, added vSwitch B. so when the Light is on, vSwitch B is off, and the color changing rule is enabled and runs.

1 Like

Thanks for sharing this Bruce. I’m finding your app to be super powerful!

I’m, unfortunately, not well versed on virtual switches. Can the “Virtual Color Control” device be used to enable this scenario for more than 2 devices? (Not sure what “Virtual Color Control” really does and if Rule Machine even supports it)

Here is the FAQ about virtual switches:

You just need a simple virtual switch for this, nothing about “Color Control”.

I totally get you only need a Virtual On/Off switch in order to switch between 2 colors, but what if you wanted to loop between 3 devices?

Things just get more complicated. You probably need 2 switches and 2 rules. Not sure, haven’t worked it out. Certainly doable.

Do you want all three devices to be the same color?

Nope, the problem is getting 1 light strip to loop between 3 colors. With Bruce’s original post/solution only 2 colors are supported. Adding a 2nd virtual switch does add additional cases that MAY allow for a solution but it does become more complicated.

Ya, it’s going to get geometrically more complicated! Problem for the student: How many rules and switches does it take to have n colors? :grinning:

2 Likes

Or, it could be stupid simple:

Create a virtual dimmer.

One trigger per color: trigger is dimmer level = [1…n]; action is change to color i, set dimmer level to next value, delay for x minutes.

The last one sets the dimmer level to 1 instead of next value.

Start the whole thing up by setting the dimmer to one of the values, then the triggers would take over. Uses the virtual dimmer as a counter/trigger. Try this @EeriePhen0men0n!

2 Likes

Great idea! I’ll try this when I get home later :slight_smile:

Brilliant!!!

20 char

Well, guess what, it doesn’t work as intended. I believe there are race conditions within the cloud. Back to the drawing board…

I have a modified version of the above that works:

virtual dimmer
virtual momentary button

One trigger per color: trigger is momentary on; conditions as needed to separate dimmer levels; rule as needed for same (e.g. x >10 AND x < 20); actions for true are delayed turn on of momentary button in 1 minute, set new color, set new dim level.

Each trigger will respond to the button push, but only the one with the right dimmer level will do anything. The one that runs changes the dimmer level, sets the color, and pushes the button 1 minute later.

You can push the virtual button in the mobile app to change the color whenever you want, but not too fast without odd behavior.

Interesting. One thing I’m confused about. In this example what would “virtual momentary button” map to in the “Type” list? I don’t see Simulated Momentary Button as an option but I do see Momentary Button Tile and Simulated Button.

My assumption is “virtual momentary button” == Simulated Button.

This is what you want. These are all “virtual” devices, that only exist in the cloud, but otherwise act like devices. So SmartApps can turn them on and off, and test their state, etc. The “momentary” part is that these particular devices turn themselves off after a couple of seconds. So you “push” the button, so to speak, it’s virtual switch turns “on”, and then turns “off”. That’s handy so you can use turning them on over and over to send a signal to an app or apps.

Hey Bruce, I got a chance to try you 2 color loop rule last night. Have you ever gotten reports of the rule getting stuck? At some point shortly after the rule started running, it stopped working for me. :frowning:

Also, what’s generally the best way to diagnose these problems?

Yes, it can die. What happens is timer drift. At some point two timers sort of collide, and one of the triggers doesn’t run. This particular method is a bit prone to that. You can get it going by pressing the button. I spaced 3 out, 20 seconds apart, and they ran all night. Keep pushing the button to get them spaced out better. Later I’m going to try with six of them.

I had another method that was super reliable, but that uses an external timer source, which isn’t generally available (uses a ThingShield).