Could use some direction on time-based dimmer

I’ve pursued exactly this course with my lighting, where the dimmer level is set according to the mode (Day, Evening, Night), and sometimes with specific time constraints on when they fire. You are correct that there is no straight forward method to just set the dimmer level without the lights coming on. What I’ve found is that by using motion to turn on lights, and by having my app handle the motion-on events, and by using device.setLevel(levelForThisMode) – so to speak – that when they do turn on they will be at the correct level. For lights that are not turned on by motion it’s trickier. What my app does is to check each light at mode change: if it’s on, great, simply adjust the level. If it’s off in a room without motion detection, I set the level and then immediately turn it back off. This results in a brief flicker of the light. But when next you turn it on, it will be at the proper level. I found this some rather tricky code that I’ve struggled with. Once in a while a light that is adjusted this way stays on when it should turn right back off. I think I found that bug yesterday, but I won’t know for sure for a bit.

The way my app works now, after about a dozen iterations of it, is that it knows about the modes (rather than asking for which modes – it’s hardwired, not good coding practice generally, but easier on me as the admin), and I enter a number at installation that specifies the three levels, eg. 903010, for 90% during Day, 30% Evening, 10% Night. It also allows the usual conditions to apply for motion activation, namely time of day, days of week, and modes.

PM me if you want further assistance…

1 Like