Dimming lights based on time of day

I’m currently using Homeseer to control lights in my house based on the time of day. It does 2 things: toggles lights when the switch is tapped and auto dims throughout the day.

The idea is that I want my lights to brighten/dim throughout the day. The lights are dim in the morning, brightest at solar noon and then slowly dim to a low level in the evening. Between midnight and sunrise they’re always at the low level. Each room has it’s own values because the rooms have different needs.

When a switch is tapped it checks the current light level. If off, it calculates the appropriate level based on the time of day. If it’s at that level, it toggles it to a higher level (approx 2x of the low level). If it’s at that high level it toggles it to the calculated lower level. The off switch just turns it all off.

It also supports auto dimming, so every 10 minutes an event is fired: if the light is I recalculate the light level based on the time of day. If it’s near the current level it adjusts it to the new level. This allows constant brighten/dim 1% at a time that nobody notices. It’s pretty legit.

My current set up:

  • I have all my Z-Wave switches connected to Homeseer.
  • I’ve downloaded all the sunrise/sunset/twilight events for the next 50 years.
  • I’ve got a webserver set up to calculate light levels based on the room/time of day with regards to sunrise/sunset for today. It returns an int that is the level to use. This server has the rules hardcoded for the different rooms.
  • Every 10 minutes Homeseer fires an event for each light switch. It hits the server mentioned above with the current light level and then adjusts it based on the value returned from the server.

I’m fairly new to Openhab so I’m unsure of the best way to do this, be it bindings or rules or what. I’ve got no problem writing code - I’m just not sure what direction to go in. Does anyone have any advice? I’ve got no problem writing code - I’m just not sure what’s what at this point. Anyone have any advice?


IMHO you’re way to go would be the Astro Binding:
combined with rules that fire at the different events like sunrise, sunset, dusk etc.
On the plus side, the events autocalculate so no need to download/update a list.
Also, the rules run inside OH so no need for a separate webserver.
This thread might give you further ideas: