Dusk-to-Dawn Light Control with Lux control and Motion Dimming - RC2

@tuffcalc Ha! Yea. Totally different use case. Super easy to code, though, I think . . .

  1. subscribe to motion events
  2. when you get a motion.active event, check the light sensor
    — if it’s dark, turn the light on, wait for end motion event, then set scheduled job to turn the light off
    — if it’s light, do nothing

The light can’t trick the lux sensor if you manage it so that you only check it when you know the light is off.

. … well, there might be a little more to it than that but still pretty straightforward.

UPDATE: I went ahead and coded this for @tuffcalc and PM’d it to him. If anyone else is interested, I can start another thread, however, I don’t want to let this one take on a life of it’s own like my porch light did ;-). If there is interest, maybe someone else can be the steward.

Today was the first time I set an offset for sunset, 30 before using -30. It’s currently 6:25 pm and sunset starts at 6:29 locally… The lights haven’t activated…

Sorry for the slow response, @DITPL. I just checked the app. . . it seems to work with the offsets according to the logs from the simulator and at my house. However, I am noticing very flaky behavior today . . not sure what’s going on. If you think this is still not working correctly, please re-start the app with live logging on and see what you get. Please also look at the SmartApp status page as well. Thanks!

Whilst looking into the issue @DITPL reported, I found a bug in the code that would result in the lights not turning off the very first morning if the app is installed after midnight and before sunrise. Day 2 and beyond would not be an issue. Also, since I now understand the the schedule() method ignores date information, I think I have some conditional branches in the code that are unnecessary. When I get a chance, I will correct the minor bug and, perhaps, eliminate the unnecessary conditional branches.

. … which raises a question, @Jim, what is the process for updating code that has been submitted for publication?

@DITPL, I’m prepared to write off your report as just some temporary ST weirdness. Have you been able to get the offsets to work since your initial report?

1 Like

@AaronZON @jim Resubmit the SmartApp and send me a note so I can expedite it.

1 Like

I just started using this and it’s been working great for me. I’m not using the offset but it’s turned on and off as it should.

I’m having some problems with my motion detector but I was trying to use my outside camera using a Synology smart app. I am going to give it a go tonight with a ST motion detector and see how it goes.

Thanks for doing this!

1 Like

I just made revisions to the code. Resolved the minor bug mentioned a couple of posts up . . .

. . . I also revise and tested the code without the conditional branches that are unnecessary. In the scheduleSunEvents() handler, I was getting today’s rise and set times, then, testing for if these were in the past or future. If they were in the past, I was indexing to the next day before using the schedule() method for the sunrise and sunset handlers. This was unnecessary since the schedule() method ignores date information and only cares about the time.

The updated code is behind the git link at the beginning of this thread. There is really no functional change in this revision and the bug only impacts crazy people who play with their SmartThings after midnight . . .and even then, the issue self-corrects the next day. So, I’ll let you decide whether or not it’s worth your trouble to update the code you are running.

I also resubmitted the app for publication.

I am getting phantom activations where the lights turn on even though there is no motion and no motion seen in the activity log. I’ll test the new code tonight!

Thanks @DITPL. Just to clarify, you are using a dim-state value of zero, right? And this weird behavior is occurring at night (during darkness), right?

It could be the start routine in the gotDark() handler. The app fires the lights at 30%, then schedules modeDim() for 3 seconds later which takes the dimmer to the dim level, which, I think, in your case is 0% or off. This should happen only once a day and for only 3 seconds unless modeDim() fails to fire.

If the dim setting is 0%, there’s no need to start the light at 30% and ramp down. A conditional statement could be added to skip that step if the dim level is set to 0%.

Let me know if you think this explains the issue. If so I can code a new gotDark() handler for you to try.

It happens more than once per evening, but I haven’t been around this weekend too much to test. I’ll update soon!

1 Like

Suggestion: it’d be nice to have an option to allow a button (likely virtual) to override the settings for a predefined amount of time and just have the lights stay on full brightness.

Let’s say I have someone coming over, or I ordered a pizza - I would want the lights to be on full brightness for a while so they can easily find the house. i know I can change the settings itself but I’d love something easy for my wife to push to just handle it for her.

Just a thought. Thanks! This is working perfectly for me.

1 Like

I think this is a great idea (and similar to another suggestion I have received). I think it would be nice to have this behavior linked to the physical dimmer (assuming there is one) - I think this would help with the WAF. For example, maybe there is an option in the set-up to assign a physical ON press to: set to x% for y minutes, then return to the program control. Maybe physical OFF press is assigned to : turn light off for z minutes then return to the program.

I’m not planning to try to do this anytime soon as I don’t have the time right now. However, my code is out there and I’m not asserting any rights to it so, if anyone wants to have a go at it, feel free!

. . . just checking in here. Life has re-arranged my priorities such that I haven’t been as active here as I was. This app is still in review for publication. I did receive notice from ST that they did some initial tests to verify that it works. I was also asked recently to verify that I still am interested in publishing my app and I indicated that I am.

This app has been solid at my house. Is anyone experiencing any issues?

Realistically, I don’t think I’m going to be able to respond to feature requests in the near future. If you do have feature ideas, please go ahead and post therm here in case someone else is ready and willing to pick it up and run with it. Anyone is welcome to start with my code and expand/improve it. The latest code is still posted behind the GitHub link in the first post of this thread.

1 Like

This is still one of my favorite SmartApps. It’s been very solid for me as well. Thank you for your time that you put into making this. Hopefully things will settle down for you soon and you can show us what else is up your sleeve!

1 Like

Hi Chris, not sure if you got the full brightness suggestion implemented but I use the little app created by @bravenel from this post and it does exactly what you described.

I agree with @DITPL . I have this Dusk to Dawn light control app for all my outside lights and it’s solid.

Thanks Ray for the link - I will take a look.

I have to say that out of everything I do ST related that this dusk to dawn module is one of the easiest, most reliable components. I’ve been running it for over a month now without any issues whatsoever. Thanks for the effort in creating this!

1 Like

ST staff has asked me to do some minor clean-up in the app and is looking into the problem I am solving with the gotDark() method - they would like this done another way. They’ve also asked me to come up with a shorter, snappier name for it. I’m thinking about going with “PorchLight Pro”. Other suggestions?

Porchlight pro sounds about right. Too bad you have to change the name. It would be pretty hard not to know what that app does with the name like “Dust To Dawn light control with lux control and motion Dimming”!

1 Like

They didn’t say I had to change it. . . just a suggestion. But I do agree that shorter, snappier name is better. I’m realizing that it would be really handy to have a ‘marketplace’ of some sort that could include a few paragraphs about the app, how to use it, reviews, etc. The problem with the way it is now is that the only place to explain the app at all is in the title and the various prompts for user settings.

We’re definitely in agreement here that a marketplace would be worthwhile!

2 Likes