Automating EcoSmart recessed bulbs with "night light" mode

I just picked up these can light LED bulbs. I'd like guidance on the best approach to automate this. Here's how they work. The modes are controlled by the switch. When the bulb is on in full-brightness mode, then you quickly turn it off then on, it switches to a night light mode (a ring around the outside with warmer light). In night light mode, it's the same: with the switch on, turn it quickly off-on, and it switches to normal mode. The modes will remain in place until switched. That is, if you turn off the switch when in night light mode, and some time later turn the switch on, it is on in night light mode. Not until you do the quick off-on thing does it switch modes. Oh they are also dimmable.

Since this is all controlled by the switch, I will put in a z-wave dimmer switch to control them. Ideally, I'd like to encapsulate the behavior somehow so that:

  • I can specify which mode to turn them on in (normal or night-light)
  • The mode they are in is tracked
  • It's just a nice-to-have but when I tell it to turn on in night light mode (when having been in normal mode), I'd rather not have it flash in full brightness before switching modes. So I'd want it to turn on at like 5%, then do the quick off-on, then return to 100% for the full nightlight mode.

So my question is, what's the best approach to encapsulate that logic? There's some state management and some sequences. I'd like to automate those and ideally make it so that I can create scenes that just tell those lights to go into night-light mode, for example, without the scene having to know what state the lights are currently in or otherwise having to re-implement any of that logic in each scene.

Any ideas?

The first thing you'll need to do is confirm that Hubitat can control the dimmer fast enough to trigger the flipping of the light. Can you set up a rule that fires the off/on (or on/off/on) command without putting in a delay and have the switch still be controllable. Depending on your mesh, you are firing up to three commands within milliseconds of each other. Not every device can handle that. If you had to put in a one second delay between each command, would that still work to switch the light?

If so, almost everything you want can be done. The only part that cannot be done easily is Hubitat knowing which mode (full brightness or night light) the bulbs are in. To solve that issue, you'll probably need to create a Hub Variable that gets changed each time the light bulb switches modes. Basically, any time you initiate the command sequence to switch the bulb, you'll also add an action to set the Hub Variable.

Okay I have the switch in place now. A one-second delay seems to work. If it didn't, I could have configured a fade rate which would have bought me time. I experimented with an RM rule as follows:

It works, but not as consistently as I hoped. I think I initially misunderstood the Delayed parameter. After experimenting with it I think it sets an independent timer at the beginning of the action for each step with a delay? So the delay is specified as a delta from the start of the rule? Is there a way to just say do one action, wait 1 sec, do the next action? Also, I'm not sure the difference between Toggle and Dim actions with respect to the dimmer; they seem to do the same thing. Is there a difference?

My next steps are to do the first action only if the switch is off, and also track state. Hub variable, you say? I'll look into that.

Delayed on an action like you have is just a delay from the start of the rule running. So, when it gets triggered, the toggle is delayed one second and the second dim is delayed for two seconds immediately before running. Instead of a delay, you would also use "wait for event - elapsed time" between each action. This would functionally give you the same thing. It would probably be a little cleaner to use the wait in order to troubleshoot in the logs, but either should work for your needs.

Dim will set the light level of the dimmer. Toggle, will either turn on or off the switch depending on its current state (basically turn it off it is on and on if it is off). I don't know if I would recommend using toggle as it might add a little bit of complexity.

What happens to your lights if you do the following in rule machine:

1.) Turn on switch
2.) Turn off switch
3.) Turn on switch

Have no delays or waits. Does it flip the lights? If not, you'll need to use the delay or wait command in the rule.

OK, I'll use the wait. With the independent timers I think they weren't firing at precisely one second apart every time. Hopefully that will help with the consistency.

But even the toggle asks for a Dim Level to set. Which is why I'm confused. They don't seem to behave differently.

I should have mentioned. I first did the rule above with no delays and it didn't work at all. In fact the end state would be indeterminate almost like they ran in arbitrary order. So some delay is necessary. At first I was questioning whether RM was the right tool for the job.

The dim level is for the on command. With dimmers, Hubitat will send a setLevel command when it is toggling them on. Most dimmers turn on directly to the level when issued this. You can test by going to the device's page, make sure the dimmer is off, and then put a level number in and click Set Level. It should turn the dimmer straight to that value.

This is just the Zwave dimmer and mesh being unable to process the commands that fast. Waits between each action should help. As long as the light bulb flips modes with the 1 second waits between each command, you'll be able do all of this.

And how is this different than Dim?

They are the same thing. A Dim action in Rule Machine is sending a setLevel command to the dimmer. See if the following works to switch the bulbs.


Make sure that your bulb is on and at 100% before testing these actions. We can worry about logic later along with tracking state. The key is trying to get the actions correctly. These actions should dim the bulb to 5, turn off the dimmer, turn on the dimmer, and then set the dimmer back up to 100 with a one second wait between each command. For the on and off commands, use the actions under controlling switches rather than setting the dimmer the zero.

Thanks for your help. I've got something that works 95% of the time. I'll keep tweaking it. For some reason, the initial 25% dim works more reliably than a 5% dim. The last three actions look like they could be combined into one, but for some strange reason, the bulbs fail to switch modes if I do that.

How is the reliability when the bulbs are at 100%?