I replaced a couple smart plugs with smart bulbs in a couple of my lamps, but I still wanted to be able to dim my lamps.
This first piston will control a dimmable smart bulb and progress through three different definable steps with every push of a button: low, medium, high, and off
Then I expanded on this idea to to progress from low to high, then back down to low and then off.
Replace the “lamp” variable your bulb of choice and the “button” variable with your control button. You may have to edit the code to turn off the bulb after the 0% set level, but setting the level to 0% works for me and eliminates a flash when the bulb turns back on. If you get a flash, leave the set level 0% and add a turn off command after it.
Both pistons should work even if you turn on one of these using another method (app, Google Home, Alexa, etc) or set the dimmer level to something other than what’s defined at the top.
I’m sure I’m not the only one that has done something like this, but I don’t often see ‘simple’ examples like this, so I thought I’d share.