Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redshift integration? #23

Closed
FezVrasta opened this issue Jan 26, 2018 · 16 comments
Closed

redshift integration? #23

FezVrasta opened this issue Jan 26, 2018 · 16 comments
Labels

Comments

@FezVrasta
Copy link

I think it would make a lot of sense to integrate Redshift into this project to automatically adjust the temperature according to the location without any additional configuration from the user.

The software is written mostly in C so I think it should be quite trivial to integrate into Go.

@stefanwichmann
Copy link
Owner

Thanks for the idea of integration Redshift into Kelvin. I think there are some thinks to take into consideration here. Both tools are similar in certain aspects but fairly different in others. Let's have a look.

Similarities:

  • Both tools use your location to determine the local sunrise and sunset times.
  • Based on this timestamps or user-configured intervals they interpolate a target color temperature in kelvin.
  • You can adjust the range of this target color in the configuration.

Differences:

  • Kelvin manages your lights, Redshift manages your computer screen.
  • Kelvin is designed for headless usage, Redshift is intended for desktop usage.
  • Kelvin provides an api (currently in beta) to enable integration, Redshift is designed to be a self-contained desktop application.

I think it would be really cool to sync the color of your computer screen with your lights. And in fact that's exactly what I do in my office with flux and Kelvin. So how can we bring these two together?

Currently I think keeping these two separated and sync the light state via configuration is good enough and the best thing to do. Let me give you some examples:

  • What happens when to computers (both running Redshift) want to control your lights?
  • What happens when your laptop leaves the house? Which system will manage your lights?
  • What happens if two rooms have different schedules and you move your laptop from one room to the other? How will the lights match?

As I stated above a manual integration works really well and gives us much more flexibility. So i don't think it's a good idea to integrate Redshift into kelvin.

Sidenotes:

  • As Kelvin provides an API it could be easily integrated into Redshift or a wrapper around it.
  • Does Redshift support ARM-Systems (like the Raspberry Pi), macOS and FreeBSD?
  • Currently the projects have incompatible licenses.

Let me know what you think!

@tremby
Copy link

tremby commented Jan 27, 2018

Redshift manages your computer screen.

It doesn't have to; it can just print what temperature it would use at this moment, via the -p switch.

Redshift is intended for desktop usage.

Not exactly. The redshift binary doesn't have a GUI (redshift-gtk is the GUI).

Kelvin provides an api (currently in beta) to enable integration, Redshift is designed to be a self-contained desktop application.

Not exactly (see above). I run it on a headless system with its -p flag to decide what temperature my lights at home should be at that moment. It controls no screen on that system. I think it could also control a remote screen it has access to via X forwarding etc, though I'm not certain about that.

Does Redshift support ARM-Systems (like the Raspberry Pi), macOS and FreeBSD?

To find out, I just successfully compiled and ran redshift on my Raspberry Pi, so yes.

As I stated above a manual integration works really well and gives us much more flexibility. So i don't think it's a good idea to integrate Redshift into kelvin.

Despite my corrections above, I agree that there's not much value in an integration, from what I know of Kelvin.

For any who already use redshift and just want their Hue lights to be in sync, you can write a really short script to do that. Here's my one. (I previously posted this on Reddit.)

@FezVrasta
Copy link
Author

As noted, I'd just like to use the color temperature algorithm of redshift to avoid to manually set the colors for all the different times of the day, and to have it adjust automatically depending on the season possibly.

Right now I have to keep several configurations for 6am-8am 8am-10am 10am-12pm etc, multiplied for the seasons... That's a bit of a pain.

@stefanwichmann
Copy link
Owner

I like the idea of adjusting automatically to the seasons. You should not have to fiddle with multiple configurations! Please help me understand why you currently use multiple configurations.

To mimic Redshift's behavior you could use a simple config like:

04:00 AM - Night color
23:00 PM - Night color

This way Kelvin would always provide a slow fade between 4AM and sunrise and between sunset and 23PM. Redshift keeps this transitions closer around sunrise and sunset but aside from that it should produce similar results. At least that's my understanding of the code.

Would this solve your needs?

@FezVrasta
Copy link
Author

I will not be at home for the next two weeks, I'll follow up once I'm back home. Thanks!

@tremby
Copy link

tremby commented Jan 29, 2018

Gotta say, I'm pretty confused.

I like the idea of adjusting automatically to the seasons.

Does it not already?

The first feature listed in the readme is this:

  • Adjust the color temperature and brightness of your lights based on the local sunrise and sunset times

Sunrise and sunset change throughout the year -- this sounds to me like things would therefore adjust to the seasons.

@stefanwichmann
Copy link
Owner

Yes, Kelvin will automatically adjust to the changing sunrise ans sunset times throughout the year. But it also uses a time-based configuration to match your daily schedule. Depending on your preference (Do you prefer your daily schedule or the changing sunrise times?) you have to use different configurations.

I'm still trying to understand the needs of @FezVrasta and am also a little confused. So, let's wait till he returns and maybe we can come to an understanding.

Apart from the specific needs discussed here, I am always interested in ways to make Kelvin easier to use. That's what I wanted to say with my initial sentence...

@tremby
Copy link

tremby commented Jan 30, 2018

If you've got ways to specify things like

  • sunset + 5 minutes
  • sunrise + 0.1 * day_hours
  • sunset + 0.5 * night_hours

...then I think you'd be covering a lot of use cases.

@FezVrasta
Copy link
Author

FezVrasta commented Feb 25, 2018

Sorry for the delay, I just finished to replace all my IKEA bulbs because they suck and now I reconfigured Kelvin with the suggested configuration.

I don't think this will do what I wanted tho.

My idea is to NOT have to configure it at all, you will automatically receive the best temperature and brightness from redshift, the most I'd do is to set the sunrise/sunset offset.

Anyway, with the following configuration I should get the temperature from bright white to warm white while the time proceeds?
What I mean is, at 4AM I will have yellow-ish lights, at 10AM they will be less yellow-ish, at noon they will be white, at 6PM they will be yellow-ish but not too much, and at 11PM they will be full yellow-ish?

image

@stefanwichmann
Copy link
Owner

Hi Federico,

welcome back and thanks for catching up.

If you configure Kelvin like above and assuming your location is Budapest (as your profile states) you would get a color temperature curve like this one:

budapest

Kelvin will construct the following intervals:

  • From 00:00 to 04:00 it will keep the temperature at 3000K
  • From 04:00 to sunrise (currently 06:30) it will fade the temperature to 6000K
  • From sunrise to sunset (currently at 17:23) it will keep the 6000K
  • From sunset to 23:00 is will slowly fade to 3000K
  • From 23:00 to 23:59 is will keep the temperature at 3000K

If I get your request right you are expecting a constant change over the whole course of the day!?!

This isn't something Kelvin does because it assumes the color temperature during daylight stays constant. This strategy is broadly accepted (see https://www.timeanddate.com/sun/hungary/budapest or https://en.wikipedia.org/wiki/Color_temperature). In reality the color temperature will constantly shift during daylight but our eyes adjust to this and you won't notice a difference. In addition to this there may be shifts in color temperature caused by clouds for example which you can't predict.

Long story short: Kelvin will keep it's color temperature constant during daylight which itself is considered constant. And it will shift the color temperature while the natural light is shifting noticeably during sunrise and sunset.

Flux will operate in the same way as you can see in this picture:
flux
And because Redshift was developed as a clone of flux I am guessing it also works this way. This comment from the Redshift sample configuration suggests the same:

By default, Redshift will use the current elevation of the sun to determine
whether it is daytime, night or in transition (dawn/dusk). When the sun is
above the degrees specified with elevation-high it is considered daytime and
below elevation-low it is considered night.

So, in essence aside from the 10:00 less yellow-ish color temperature you should get results close to what you expect but for slightly different reasons.

Hope this helps!?!

@FezVrasta
Copy link
Author

Umh I see, thanks for the info. I guess the problem is that the hole where I live has a very bad lighting so the home starts getting dark very soon (way before the sunset). But I suppose I can adjust the sunset offset to accommodate this problem.

I'll do some more experiment in the next days, thanks again

@stefanwichmann
Copy link
Owner

Sure! Let me know how your experiments go.

Also maybe take a look at #27 where I think about the future directions of Kelvin. Some of the changes would allow you to adjust the color temperature during daylight.

@FezVrasta
Copy link
Author

FezVrasta commented Feb 27, 2018

Umh so... I'm really trying hard to make it work but it doesn't seem to want to cooperate.

We have this "sunrise - sunset" timeframe where I can set a given light, but how can I tell it to set a different color as soon the sun sets? It just asks me a time, I can't find a way to tell it "at sunset, set temperature to X" 🙁

Also, I thought there was an offset option for sunset and sunrise but I can't find it anymore.

@stefanwichmann
Copy link
Owner

As stated above and shown in the graph, there is no option to set a specific temperature at sunset. And there isn't an option for an offset either. All of this has been discussed in this issue.

If you use your configuration from above Kelvin will start at sunset (currently around 17:30 at your location) and fade the temperature to a warmer color (in your case 3000K). By the time the natural light is gone (currently around 19:09 at your location) you should see a noticeable change here.

If you don't see changing color temperatures at all, please make sure the given lights are part of your Kelvin schedule. And if you have manually changed the color yourself, please reactivate Kelvin by turning your light off and on again, by using a scene or through the web interface.

@FezVrasta
Copy link
Author

The thing is that the whole sunset sunrise thing is useless if I then have to manually set another time to when I want the lights to be at a warmer color... There should be a way to specify sunset + X

@stefanwichmann
Copy link
Owner

#27 describes why relative offsets also can't be the optimal solution for Kelvin...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants