Code Monkey home page Code Monkey logo

kelvin's People

Contributors

chrisdrake3 avatar flmessier avatar grussr avatar gunnarmorling avatar npwalker avatar prfalken avatar raphaelmarinier avatar sarangak avatar sirwolfgang avatar stefanwichmann avatar xpi-d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kelvin's Issues

Kelvin disables lights in its scenes improperly

I've currently got a switch with three scenes, activated in this order:

  1. kelvin default
  2. Bright
  3. Energize

The idea is that Kelvin is the default, but if I need really bright lights for whatever reason, I can do that.

However, I'm having issues: Kelvin seems to update the scene to have the lights turned off at some point after I configure it. So this is what happens:

press # expected actual
1 on (kelvin) off
2 on (bright) on (bright)
3 on (energize) on (energize)
4 on (kelvin) on (kelvin)
5 on (bright) on (bright)
6 on (energize) on (energize)

this is because Kelvin somehow reconfigures the scene to stop turning on the light itself, so the first press doesn't turn the lights on. I can confirm this by editing the scene in the Hue app; it shows that the light being on is no longer part of the scene. If I loop around back to Kelvin all's well since other scenes have turned it on.

Respect range of "Color Temperature Lights"

All devices of the "Color Temperature Light" series (Device ID 0x0220) only support a reduced range of 2200-6500K. Kelvin should respect this range properly. Currently 2000K is assumed as the lowest color temperature for all lights.

Docker container doesn't create config.json in mounted folder

Hi,

Since the last Docker version, where the config.json moved to /opt/kelvin/config.json, the config.json isn't created in my mounted folder on the Synology NAS.
Kelvin is running and adjusts the lights according to the standard values, but I can't find and edit the JSON file. This was no issue with the previous release.

Thanks for the great app!

Add systemd instructions?

I know it's trivial but it would be useful to mention how to create a systemd service for this program.

# /etc/systemd/system/kelvin.service

[Unit]
Description=Kelvin
After=network.target

[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/Kelvin
ExecStart=/home/pi/Kelvin/kelvin
Restart=on-abort

[Install]
WantedBy=multi-user.target
$ sudo systemctl enable kelvin
$ sudo systemctl start kelvin

Error Parsing Time

I have, today, installed Kelvin in a Docker container. Everything seems to be working fine, but I will be monitoring to check that transitions configure in the Schedule are working as expected.

I do notice in the logs that there is a message every minute related to parsing the time:

time="2018/21/11 16:53:15" level=info msg="parsing time \"\" as \"15:04\": cannot parse \"\" as \"15\""
time="2018/21/11 16:54:15" level=info msg="parsing time \"\" as \"15:04\": cannot parse \"\" as \"15\""
time="2018/21/11 16:55:15" level=info msg="parsing time \"\" as \"15:04\": cannot parse \"\" as \"15\""
time="2018/21/11 16:56:15" level=info msg="parsing time \"\" as \"15:04\": cannot parse \"\" as \"15\""
time="2018/21/11 16:57:15" level=info msg="parsing time \"\" as \"15:04\": cannot parse \"\" as \"15\""
time="2018/21/11 16:58:15" level=info msg="parsing time \"\" as \"15:04\": cannot parse \"\" as \"15\""
time="2018/21/11 16:59:15" level=info msg="parsing time \"\" as \"15:04\": cannot parse \"\" as \"15\""

Will this cause any problems? Is there a solution?
Thanks.

Kelvin only changes colour temperature once when lights turn on.

Installed Kelvin on a fresh Raspberry Pi Zero W. Haven't gotten it to work properly though. There are two issues and I suspect they are related.

Firstly Kelvin doesn't manage to control all lights when they get turnt on. Most of the time all the lamps appear in the logs, then all lamps get the "initializing state to ..." However here only sometimes does all lamps actually get to the correct colour temperature (have set brightness at -1 in the config, but tried having it at 100 with no change). The "detected matchingt target state " message only appears sporadically. So to summarize: The lamps are found in kelvin, but kelvin doesn't get proper control of them.

Secondly even when kelvin have managed to get control of all the lights the main functionality doesn't work for me. There is no transition after sunset, i have to manually restart the lamps (many times for kelvin to get proper control) to achieve a change in colour temp.

Don't know how to troubleshoot this, I have checked all the connections to the router and they seem fine. The app always gets local network-control of the bridge. I have moved the bridge further away from the router to check for interference with no improvement. How should I proceed??

PS! Also noticed Kelvin loads the CPU to +80%, often times bottlenecking it. I gather from an earlier issue here that around 20% could be expected but not as high as 80% all the time.

IKEA Tradfri bulbs "pulse" when turned on

I noticed that some of my Tradfri bulbs will pulse when turned on since I enabled Kelvin.

What could it be?

For pulse I mean, they "blink" slowly from say, 40% brightness to 100% brightness, it takes 5 or 6 seconds for the "pulse" to finish.

Crash shortly after startup - index out of range in lightstate.go

Windows 64 bit. Extracted release v0.0.8 and ran the .exe file. Registration to hub went well, lamps were found. Color temperature was set correctly, then the program crashes with the following error:

2017/03/29 22:39:14 Kelvin v0.0.8 starting up... πŸš€
2017/03/29 22:39:14 Looking for updates...
2017/03/29 22:39:14 βš™ Default configuration generated
2017/03/29 22:39:14 ⌘ No bridge configuration found. Starting local discovery...
2017/03/29 22:39:18 ⌘ Found bridge. Starting user registration.
PLEASE PUSH THE BLUE BUTTON ON YOUR HUE BRIDGE.... Success!
2017/03/29 22:39:33 πŸ’‘ Devices found on current bridge:
2017/03/29 22:39:33 | Name                 |  ID | Reachable | On    | Dimmable | Temperature | Color | Cur. Temp | Cur. Bri |
2017/03/29 22:39:33 | Hue ambiance lamp 1  |   1 | true      | true  | true     | true        | false |     2202K |       79 |
2017/03/29 22:39:33 | Hue ambiance lamp 2  |   2 | true      | true  | true     | true        | false |     2202K |       79 |
2017/03/29 22:39:33 🌍 Location not configured. Detecting by IP
2017/03/29 22:39:33 🌍 Detected location: Copenhagen, Denmark (55.6759, 12.5655).
2017/03/29 22:39:33 Configuring intervals for Wednesday March 29 2017
2017/03/29 22:39:33 πŸ’‘ Starting cyclic update for Hue ambiance lamp 2
2017/03/29 22:39:33 πŸ’‘ Starting cyclic update for Hue ambiance lamp 1
2017/03/29 22:39:33 Managing lights for interval 22:00 to 23:59
2017/03/29 22:39:35 πŸ’‘ Light Hue ambiance lamp 2 just appeared. Initializing state to 2000K at 60%
2017/03/29 22:39:35 πŸ’‘ Light Hue ambiance lamp 1 just appeared. Initializing state to 2000K at 60%
panic: runtime error: index out of range

goroutine 82 [running]:
panic(0x69eb00, 0xc04200c080)
        /home/travis/.gimme/versions/go1.7.4.linux.amd64/src/runtime/panic.go:500 +0x1af
main.(*LightState).equals(0xc0422f8368, 0x89a, 0x849d00, 0x0, 0x0, 0x3b, 0x89a)
        /home/travis/gopath/src/github.com/stefanwichmann/kelvin/lightstate.go:36 +0x1c4
main.(*Light).update(0xc0422f8300, 0xc0422c3f48, 0xc0422c3ecf)
        /home/travis/gopath/src/github.com/stefanwichmann/kelvin/light.go:150 +0x4fb
main.(*Light).updateCyclic(0xc0422f8300, 0xc04218b860)
        /home/travis/gopath/src/github.com/stefanwichmann/kelvin/light.go:71 +0x2f4
created by main.main
        /home/travis/gopath/src/github.com/stefanwichmann/kelvin/kelvin.go:86 +0x599

Quick look at the source reveals that the offending line in lightstate.go reads:

if (lightstate.color[0] != 0 && lightstate.color[1] != 0) || (state.color[0] != 0 && state.color[1] != 0)

I don't have time to properly dig into this right now, but will probably have a look tomorrow if nobody's fixed it by then - or if it turns out that it's only reproducible on my setup :)

Docker Timezone

It seems like the docker version doesn’t support the TZ variable, and defaults to UTC. As a result, all of the scheduling is thrown off.

Allow Schedule Sets Between beforeSunrise and afterSunset

I believe this isn't currently supported, but I may be wrong. Feel free to correct me.

It would be great if Kelvin supported schedules between beforeSunrise and afterSunset. A "daytime" schedule set would allow control of lights throughout the day. This would allow users to create more gradual transitions between warm lights in mornings and evenings and the default color/brightness that currently is set throughout the day. It could also allow users, to adjust specific rooms during the day... for those, with small children that nap midday for example, and could benefit for warmer dimmer light in the middle of the day in a part of the house.

Thanks! Great bot!

arm version segfaulting

Running Kelvin on arm board, it segfaults. No difference if config.json generated on PC is present or not.

Output below:

$ ./kelvin
Segmentation fault
$ uname -a
Linux armboard 2.6.32.65-bcm5892-secure #2 PREEMPT Thu Mar 24 16:15:42 CST 2016 armv6l GNU/Linux

Light switches for this system

Do you know of any powerless & wireless wall light switches by any chance. I want to still be able to activate the lights using wall switches as well as from an app

Taking minutes for lights to appear in kelvin/ not appearing ever?

First off, thanks so much for writing this library! It's exactly what I'm looking for. I'm hoping you can help me troubleshoot. I've got kelvin running, but some of my lights seem to never be detected or effected by Kelvin. I don't have any issue with my hue switches seeming to control my bulbs instantly, but there is sometimes a few minutes delay for the Kelvin logs report detecting a light. Is this a Kelvin problem, or a hue bridge/zigbee problem? Would love to get your thoughts on where to start troubleshooting- I want this to work so bad!

Feature request - Kelvin wins

I'd like an option where Kelvin is the master control by default. I.e. it doesn’t need to be 'enabled' by something else. I want to only use Kelvin as the control for my Hue lights. I never (or very rarely) use any manual on/off control, I use schedules all the time for my office and other rooms in the house.

It would work like this:

  • Kelvin has control by default.

  • If a light is manually turned on or off via another App. then that remains in effect only until the next Kelvin time cue hits. For example, sunrise, sunset, or any manual times set in schedules.

What I'm doing now is starting a Kelvin cue at 1:00am in all my zones, but that will fail if another trigger comes during the day.

I'd like to completely remove any reliance on the Hue app and give all scheduling to Kelvin!

Panic on startup

Seems that light.TargetLightState is not being initialized with any color values prior to calling light.setLightState(light.TargetLightState). Tried to understand what is the intention, but couldn't quite see it with minimal effort.

Could I suggest adding some unit tests, and running a linter (https://github.com/dominikh/go-tools/tree/master/cmd/megacheck or golint).

INFO[2017/03/08 21:11:32] πŸ’‘ Light Hue color spot Hallway 2 spot 3 is not associated to any schedule. Ignoring...
INFO[2017/03/08 21:11:32] πŸ’‘ Light Hue beyond down 8 is not associated to any schedule. Ignoring...
INFO[2017/03/08 21:11:32] πŸ’‘ Light Hue color Hallway 1 spot 3 is not associated to any schedule. Ignoring...
INFO[2017/03/08 21:11:32] πŸ’‘ Light Hue color spot Hallway 2 spot 2 is not associated to any schedule. Ignoring...
INFO[2017/03/08 21:11:32] πŸ’‘ Light Hue color spot Kid's Bath 3 is not associated to any schedule. Ignoring...
INFO[2017/03/08 21:11:32] πŸ’‘ Light Hue beyond up 4 is not associated to any schedule. Ignoring...
INFO[2017/03/08 21:11:32] πŸ’‘ Light Hue beyond down 1 just appeared. Initializing state to 0K at 0% brightness.
INFO[2017/03/08 21:11:32] πŸ’‘ Light Hue color spot Hallway 2 spot 2 is not associated to any schedule. Ignoring...
INFO[2017/03/08 21:11:32] πŸ’‘ Light Hue color spot Kid's Bath 2 is not associated to any schedule. Ignoring...
panic: runtime error: index out of range

goroutine 390 [running]:
main.(*Light).setLightState(0xc42061a000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/meling/Dropbox/work/go/src/github.com/stefanwichmann/kelvin/light.go:209 +0x9e0
main.(*Light).update(0xc42061a000, 0x2, 0x0)
	/Users/meling/Dropbox/work/go/src/github.com/stefanwichmann/kelvin/light.go:149 +0x1de
main.(*Light).updateCyclic(0xc42061a000, 0xc42013a8c0)
	/Users/meling/Dropbox/work/go/src/github.com/stefanwichmann/kelvin/light.go:88 +0x2b8
created by main.main
	/Users/meling/Dropbox/work/go/src/github.com/stefanwichmann/kelvin/kelvin.go:82 +0x590

Lights switching straight back off after turning on

Got home from holiday to find I couldn't turn any lights on!

I didn't have time to sort it yesterday but I've figured it out today. Kelvin auto updated whilst we were away (yesterday afternoon) and the latest update includes a significant change.

I have Kelvin just controlling colour temperature, so my brightness values were all set to 0 to ignore. This will now turn the light off and a new value of -1 should be used.

I suggest the updater could migrate these settings? I suppose I have now learned to turn auto update off.

Rethinking the core functionalities of Kelvin

In the light of the recent discussions in #23, #24 and #25 I would like to start a conversation about the core functionalities of Kelvin.

My goal for Kelvin is to enhance your life at home by seamlessly controlling your lights based on natural and artificial schedules. It should be able to combine dynamic sunrise and sunset times with a fixed daily schedule of early hour work or "Netflix and chill" at night.

While working on Kelvin for close to a year now I realized that this combination doesn't always work as expected and confuses users. So I think it's time to rethink the core mechanics of Kelvin to make them more precise, easier to understand and yet simpler to configure.

Examples:

Following are examples of things people expect Kelvin to do well without big hassles:

  1. I use early mornings to get personal things done and to start the day productive. For this I want to have an artificial daylight at 07:00. In the summertime this might be after sunrise (04:55), during the winter before sunrise (08:36).
  2. In the evening around 22:00 I want to have warmer light at lower brightness to prepare for bedtime. I summer this may lay before sunset, during the winter it lays definitely after sunset times.
  3. My kids take a nap every day between 12:30 and 14:00 and I want to turn down the brightness in their bedroom during their sleep.

Current state:

Let's have a look at the current mechanics in Kelvin to see how it tries to match these example demands.

Kelvin separates the 24h of a day into three intervals: before sunrise, daytime and after sunset. "Before sunrise" begins at 00:00 and "after sunset" ends on 23:59. The other interval borders are dependent on the current and local sunrise and sunset times.

Custom settings are configured as timestamps and Kelvin will slowly transition to these settings in time. For an explicit time range (with start and end) you have to create two configuration entries.

Custom settings during daytime (between sunrise and sunset) are completely ignored. The assumption being that the daylight does not interfere with your schedule anyway. So example 3 isn't supported at all.

Furthermore if a custom setting falls into the daytime interval (see example 1 and 2) it will be ignored as well. If in doubt, the sunrise and sunset configuration wins.

This leaves us with the intervals before sunrise and after sunset for which a custom settings is fully supported right now.

Problems:

There are several problems with the current implementation that make Kelvin difficult to understand:

  • Not all valid use cases are supported.
  • Kelvin might ignore a custom settings based on sunrise/sunset times.
  • Kelvin is in constant transition which makes the current state less predictable.

Proposal:

  • We allow the user to express his custom settings as intervals with a start and end times for the whole day (00:00 - 23:59).
  • The user can specify any number of intervals as long as they don't overlap per schedule.
  • These custom intervals will always be respected and prioritized over any other setting (like sunrise and sunset). If the user wants to have a bright working light during the morning hours it should not matter if the sun is up or not. Same goes for the nap example.
  • We introduce three default intervals:
    • 00:00 - dawn
    • sunrise - sunset
    • sunset - 23:59
  • During intervals the light state remains stable (as in the current daylight interval).
  • The custom intervals punch holes into the default intervals (or replace them if they are long).
  • Kelvin will insert transitions between all intervals.

With these mechanism we could combine sane defaults with the flexibility of fixed schedules:

  • If the user doesn't change the configuration at all the lights will follow the natural light outside with local sunrise and sunset times.
  • If the user needs a custom schedule Kelvin will respect these times and transition around it.
  • We keep the required configuration to a minimum.

For additional clarification and explanation I made some graphs how Kelvin would react in the example scenarios. They show the kelvin value for every hour of the day.

Natural schedule

natural summer
natural winter

Early Work (Example 1)

earlywork summer
earlywork winter

Nap (Example 3)

nap summer
nap winter

Thoughts? Any feedback is appreciated!

Some bulbs get turned off at midnight

Some of my bulbs get automatically turned off by Kelvin after midnight, even though brightness is set to -1 (unmanaged). Tried using 100 to see if -1 could be the cause, but the issue still persists.

Once that happens, Kelvin doesn’t respect manual changesβ€”the selected lights get turned off again immediately.

Lights "manually changed"?

So, getting this up and running has been fantastically easy (even for a non-techie)
However I noticed that it was stopping updating..

While sat in the living room, and watching the commands, it seems that Kelvin thinks the lights are being manually adjusted, though I've not touched them (unless they ARE, and the hub is running some sort of automated command somewhere?)

Not sure how to diagnose this further.. any suggestions?

p.s. just noticed I'm using v1.0.1, so I guess I need to get that updated somehow!

pi@pizero-hue:~/kelvin-linux-arm-v1.0.1 $ ./kelvin
INFO[2017/18/05 21:28:41] Kelvin v1.0.1 starting up... πŸš€
INFO[2017/18/05 21:28:41] βš™ Configuration config.json loaded
INFO[2017/18/05 21:28:41] ⌘ Initializing bridge from configuration
INFO[2017/18/05 21:28:41] Looking for updates...
INFO[2017/18/05 21:28:41] ⌘ Connection to bridge established
INFO[2017/18/05 21:28:41] πŸ’‘ Devices found on current bridge:
INFO[2017/18/05 21:28:41] | Name | ID | Reachable | On | Dimmable | Temperature | Color | Cur. Temp | Cur. Bri |
INFO[2017/18/05 21:28:41] | Jamie's Lamp | 3 | false | true | true | true | true | 0K | 100 |
INFO[2017/18/05 21:28:41] | Guest Lamp | 4 | false | false | true | true | true | 2012K | 0 |
INFO[2017/18/05 21:28:41] | TV Lamp | 6 | true | true | true | true | true | 2336K | 77 |
INFO[2017/18/05 21:28:41] | Couch Lamp | 7 | true | true | true | true | true | 2336K | 77 |
INFO[2017/18/05 21:28:41] 🌍 Working with location 51.5378, 0.7143 from configuration
INFO[2017/18/05 21:28:41] πŸ’‘ Light Couch Lamp: Activating schedule for May 18 2017 (sunrise: 5:00AM, sunset: 8:47PM)
INFO[2017/18/05 21:28:41] πŸ’‘ Light Couch Lamp: Activating interval 8:47PM - 10:00PM
INFO[2017/18/05 21:28:41] πŸ’‘ Light Guest Lamp: Activating schedule for May 18 2017 (sunrise: 5:00AM, sunset: 8:47PM)
INFO[2017/18/05 21:28:41] πŸ’‘ Light Guest Lamp: Activating interval 8:47PM - 10:00PM
INFO[2017/18/05 21:28:41] πŸ’‘ Light TV Lamp: Activating schedule for May 18 2017 (sunrise: 5:00AM, sunset: 8:47PM)
INFO[2017/18/05 21:28:41] πŸ’‘ Light TV Lamp: Activating interval 8:47PM - 10:00PM
INFO[2017/18/05 21:28:41] πŸ’‘ Light Jamie's Lamp: Activating schedule for May 18 2017 (sunrise: 5:00AM, sunset: 8:47PM)
INFO[2017/18/05 21:28:41] πŸ’‘ Light Jamie's Lamp: Activating interval 8:47PM - 10:00PM
INFO[2017/18/05 21:28:42] πŸ’‘ Light Couch Lamp just appeared. Initializing state to 2324K at 78%
INFO[2017/18/05 21:28:42] πŸ’‘ Light TV Lamp just appeared. Initializing state to 2324K at 78%
INFO[2017/18/05 21:29:47] πŸ’‘ Light TV Lamp was manually changed. Disabling updates..
INFO[2017/18/05 21:29:49] πŸ’‘ Light Couch Lamp was manually changed. Disabling updates..
INFO[2017/18/05 21:36:03] πŸ’‘ Light Couch Lamp is no longer reachable or turned on. Clearing state.
INFO[2017/18/05 21:36:03] πŸ’‘ Light TV Lamp is no longer reachable or turned on. Clearing state.
INFO[2017/18/05 21:36:09] πŸ’‘ Light Couch Lamp just appeared. Initializing state to 2251K at 74%
INFO[2017/18/05 21:36:09] πŸ’‘ Light TV Lamp just appeared. Initializing state to 2251K at 74%
INFO[2017/18/05 21:37:41] πŸ’‘ Light TV Lamp was manually changed. Disabling updates..
INFO[2017/18/05 21:37:41] πŸ’‘ Light Couch Lamp was manually changed. Disabling updates..

Docker - store config.json outside docker

Hi,

I'd like to run Kelvin in a Docker under Unraid, however it looks like the config.json file is stored inside the docker, which means it will get overwritten whenever the docker file is updated?

If I'm right in this conclusion, please look at mapping a path for storing the config.json application data outside of the container itself on the host machine. Typically this would be at the /config location

Thanks!

Allow Relative Offset Times in Schedules

Since sunrise and sunset times change throughout the year, it would be great to be able to set relative offset times in schedules for beforeSunrise and afterSunset.

As an example, an afterSunset schedule could include "timeOffset" : "+2:00". If sunset was 6:58, the color and brightness settings would be triggered at 8:58. Later in the year, if sunset was 5:04, it would be triggered at 7:04. beforeSunrise schedules would likely include negative values, though I would find value in negative and positive values for both beforeSunrise and afterSunset. We try to use Kelvin in our home to mimic the circadian rhythm of outdoor light throughout the year.

Thanks! Great bot!

Warmer in the evening?

Hi - I'd like to make the bulbs warmer in the evening, but wasn't 100% sure how to go about this..
I can see from the config file there is a setting for AfterSunset, though I don't know what the time value is for.

Can I just choose a brightness and colour temp for AfterSunset, without setting a time, and have Kelvin automatically gradually shift to that temperature in the evening?

By the same token, perhaps something more 'energising' in the morning?

Distribute Kelvin as a docker container

Another request on Reddit:

https://de.reddit.com/r/Hue/comments/625of1/meet_kelvin_a_little_bot_i_wrote_to_automate_your/dfk4cun/

A distribution of Kelvin as a docker container would certainly make it much easier to give it a try and to get it running in existing docker environments. On the other hand I'm suspecting Kelvin's primary use will happen in home environments and not many people have a docker farm at home (yet).

Any thoughts?

Modification of polling interval & some questions

Hey there!

This is an awesome project. Thank you for putting it together! The fact that you created a docker container allows me to migrate off of f.lux (and running a windows PC) to a synology NAS-based solution (which I am cool with running 24/7).

I haven't dug into the code yet, but was hoping to understand a bit more on a few things, with one request.

I noticed that when I enable Kelvin and turn a light on/off again that it mostly updates the light state as I expect. However, it's a little unclear to me how you implemented state detection in terms of how you choose to check if a light state should be "overridden" by Kelvin. For example, here are some of the observations I've made:

  • Enable Kelvin -> Turn on a light that was off before Kelvin was enabled -> State changes as expected.

  • Enable Kelvin -> Turn off a light that was on before Kelvin was enabled -> Turn it back on again -> Expectation is that Kelvin would "take over" and update all the new lights with the expected "correct" state. Is this the correct expectation to have? Sometimes this doesn't seem to happen.

  • Enable Kelvin -> Assume lights reach "correct" state per Kelvin -> Use another app (or a switch) to set a different scene -> Scene runs as expected -> Turn off all lights -> Turn back on again -> Expectation is that Kelvin would "take over" and update all the new lights with the expected "correct" state. Is this the correct expectation to have? Sometimes this doesn't seem to happen. Also, is there a way to quickly get back to "Kelvin" state without turning the lights off and on again (e.g. having a Kelvin Scene) as was suggested in another issue?

  • Enable Kelvin -> Turn off lights using dimmer switch -> Turn on lights to "previous state" using dimmer switch -> Expectation is that Kelvin would "take over" and update all the new lights with the expected "correct" state. Is this the correct expectation to have? Sometimes this doesn't seem to happen.

  • Enable Kelvin -> Dim lights using dimmer switch -> Expectation is that Kelvin won't take over again until the lights are turned off and on again. Is this the correct expectation to have?

I was thinking that perhaps, with the modification of the polling logic / interval, some of these issues may be able to be solved (or it could just be general Hue Flakiness that is impossible to work around perfectly, I'm not sure). FWIW, I have 40 bulbs connected to a single bridge, so this is a semi-large use-case :). What is the current polling logic / interval today? That might help me to understand, too.

Thanks again for all your hard work here!

Unknown color mode in HasChanged method

I'm seeing the following appear in my log every second:

level=warning msg="πŸ’‘ HueLight Side Door - Unknown color mode in HasChanged method! Current light state: &{Name:Side Door HueLight:{Id:4 Name:Side Door bridge:0xxxxxx} SetColorTemperature:2000 SetBrightness:-1 TargetColorTemperature:500 TargetColor:[0.527 0.404] TargetBrightness:-1 CurrentColorTemperature:0 CurrentColor:[] CurrentBrightness:254 CurrentColorMode: SupportsColorTemperature:false SupportsXYColor:false Dimmable:true On:true}"

It only applies to a single bulb, which is on a timer to come on at night and off in the day. Not causing a problem other than filling up the log.

Failed to start because of opened port 1900

First time starting Kelvin, it failed to start. Log and some more info below.

$ ./kelvin 
2017/03/31 18:46:42 Kelvin v0.0.11 starting up... πŸš€
2017/03/31 18:46:42 Validating local system time...
2017/03/31 18:46:42 Looking for updates...
2017/03/31 18:46:42 Local system time seems to be valid.
2017/03/31 18:46:42 βš™ Configuration config.json loaded
2017/03/31 18:46:42 ⌘ No bridge configuration found. Starting local discovery...
2017/03/31 18:46:42 listen udp :1900: bind: address already in use
$ netstat -l|grep 1900
udp        0      0 239.255.255.250:1900    0.0.0.0:*                          
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.10
Release:	16.10
Codename:	yakkety

Constantly high CPU usage of kelvin on Raspberry Pi Zero

I just installed Kelvin on a fresh install of Rasbian on a Raspberry Pi Zero W.

When I look at top I see that Kelvin is consistently consuming 20% of my CPU all the time. This is much more than expected. I was expecting it to wake up maybe once per minute to adjust lights based on the schedule and go to sleep.

Is this normal? Is there anything I can do to reduce CPU usage? I was looking for a low power solution.

Log: "Disabling Kelvin" "Activating Kelvin" loop, and overriding custom scenes

I'm unable to select custom scenes or change anything during the daytime without Kelvin throwing a log loop and overriding what I'm trying to do. I reset the hub (clean up in Hue app) with no change. Kelvin is running as a service on Ubuntu. I would like it to automatically enable when the lights are on after sunset but be able to control the lights myself through the day. Thanks for your help!

Log:

Jun 15 07:56:21 kelvin kelvin[2072]: time="2018/15/06 07:56:21" level=info msg="πŸ’‘ Light Skull - Light state has been changed manually. Disabling Kelvin..."
Jun 15 07:56:24 kelvin kelvin[2072]: time="2018/15/06 07:56:24" level=info msg="πŸ’‘ Light Side - Detected matching target state. Activating Kelvin..."

Debug:

DEBU[2018/15/06 07:52:36] πŸ’‘ Light Side - Initialization complete. Identified as Color temperature light (ModelID: LTW004, Version: 5.105.0.21536)
INFO[2018/15/06 07:52:36] πŸ’‘ Light Side - Activating schedule for Jun 15 2018 (Sunrise: 05:27, Sunset: 20:32)
INFO[2018/15/06 07:52:36] πŸ’‘ Light Side - Activating interval 05:27 - 20:32
DEBU[2018/15/06 07:52:36] πŸ’‘ Light Side - The calculated lightstate for the interval 05:27 - 20:32 is {ColorTemperature:-1 Brightness:-1}
DEBU[2018/15/06 07:52:36] πŸ’‘ Light Side - Initialized target light state to {ColorTemperature:-1 Brightness:-1}
DEBU[2018/15/06 07:52:36] πŸ’‘ Light Side - Starting cyclic update...
INFO[2018/15/06 07:52:37] πŸ’‘ Light Side - Light just appeared.
INFO[2018/15/06 07:52:37] πŸ’‘ Light Side - Initializing state to -1K at -1% brightness.
DEBU[2018/15/06 07:52:37] πŸ’‘ Light Side - Adjusted color temperature to light capability of 2000K
DEBU[2018/15/06 07:52:37] πŸ’‘ HueLight Side - Setting light state to 2000K and -1% brightness.
DEBU[2018/15/06 07:52:38] πŸ’‘ HueLight Side - Color temperature has changed! Current light state: &{Name:Side HueLight:{Id:5 Name:Side bridge:0xb26b80} SetColorTemperature:2000 SetBrightness:-1 TargetColorTemperature:500 TargetColor:[0.527 0.404] TargetBrightness:-1 CurrentColorTemperature:454 CurrentColor:[] CurrentBrightness:254 CurrentColorMode:ct SupportsColorTemperature:true SupportsXYColor:false Dimmable:true Reachable:true On:true MinimumColorTemperature:2000}
WARN[2018/15/06 07:52:38] πŸ’‘ HueLight Side - Failed to update light state: &{Name:Side HueLight:{Id:5 Name:Side bridge:0xb26b80} SetColorTemperature:2000 SetBrightness:-1 TargetColorTemperature:500 TargetColor:[0.527 0.404] TargetBrightness:-1 CurrentColorTemperature:454 CurrentColor:[] CurrentBrightness:254 CurrentColorMode:ct SupportsColorTemperature:true SupportsXYColor:false Dimmable:true Reachable:true On:true MinimumColorTemperature:2000}
DEBU[2018/15/06 07:52:38] πŸ’‘ Light Side - Adjusted color temperature to light capability of 2000K

Config:

{
  "version": 1,
  "bridge": {
    "ip": "192.168.1.52",
    "username": ""
  },
  "location": {
    "latitude": ,
    "longitude": 
  },
  "webinterface": {
    "enabled": false,
    "port": 8080
  },
  "schedules": [
    {
      "name": "default",
      "associatedDeviceIDs": [
        2,
        3,
        5,
        6
      ],
      "enableWhenLightsAppear": true,
      "defaultColorTemperature": -1,
      "defaultBrightness": -1,
      "beforeSunrise": [
        {
          "time": "4:00",
          "colorTemperature": 2200,
          "brightness": 1
        }
      ],
      "afterSunset": [
        {
          "time": "20:00",
          "colorTemperature": 3400,
          "brightness": 50
        },
        {
          "time": "22:00",
          "colorTemperature": 2200,
          "brightness": 1
        }
      ]
    }
  ]
}

Kelvin failing to run on boot

I followed the instructions to use systemd to run kelvin on bootup on a Rasperry Pi. However, Kelvin fails to run on bootup. The Kelvin Logs look like this:

-- Logs begin at Sat 2018-06-16 20:03:03 CDT. --
Jun 16 20:03:07 raspberrypi systemd[1]: Started Kelvin.
Jun 16 20:03:08 raspberrypi kelvin[413]: time="2018/16/06 20:03:08" level=info msg="Kelvin v1.1.6 starting up... πŸš€"
Jun 16 20:03:08 raspberrypi kelvin[413]: time="2018/16/06 20:03:08" level=info msg="βš™ Configuration config.json loaded"
Jun 16 20:03:08 raspberrypi systemd[1]: kelvin.service: Main process exited, code=exited, status=1/FAILURE
Jun 16 20:03:08 raspberrypi systemd[1]: kelvin.service: Unit entered failed state.
Jun 16 20:03:08 raspberrypi systemd[1]: kelvin.service: Failed with result 'exit-code'.

Any ideas as to what the problem might be?

Add the ability to include/exclude certain lights

A user an reddit suggested to allow the explicit inclusion or exclusion of certain lights in Kelvin:

https://de.reddit.com/r/Hue/comments/625of1/meet_kelvin_a_little_bot_i_wrote_to_automate_your/dfjyiyk/

I think this a a good idea. Right now all capable lights will be managed by Kelvin.

In my opinion it should by sufficient to focus on the exclusion in a first step. In my assumption the average user has 3 - 10 lights in his/her house. In this case it seems reasonable to add the exclusion once and keep the configuration file simple.

Any thoughts?

Does Kelvin reverts Hue πŸ’‘its last settings after hardware light switch is toggled πŸ”²

Hallo Stefan,

First, thank you very much for open sourcing this project. It looks very impressive and well documented:) You should add a button for donations and find a way to monetize long term πŸ˜‰.

I am also of father of toddlers and I bought "White ambiance" Hue for having warmer temperatures in the evening. I did lots of reading before falling to me geeky instincts but so far I am not πŸ’― % happy with them. My main concern is that as soon as me or my kids use the old school light switch to power off the lights, the smart bulbs forget about their last settings and default light is very bright & cold. Are you supposed to buy motion sensors and Dimmer switches for each room?
image

Being a ruby developer, I did some digging and came across your post in Reddit. Would kelvin sort that problem? It looks like it would, even if polling / randomness would add some waiting time & unstability.

I am not sure what to do and I am very tempted to ask for a refund ... There is also some announcement by Phillips that they will fix the startup color.

In https://ioshacker.com/accessories-i/philips-hue-soon-let-set-default-startup-color

For example, it is unclear if this new option would allow the bulb to revert to its last setting or only one fixed setting set by the user

Add the ability to configure different rooms/groups

Currently Kelvin doesn't know anything about rooms or groups of lights. Adding this capability would add a lot of complexity to the inner structure of Kelvin (it would have to manage multiple active intervals for different devices for example) and especially to the user facing configuration. Would you have to create rooms/groups? Is there a standard room/group? Will there be a fallback to a standard room if no other room is associated?

I think there is a lot to discuss and foresee in this. Let me know what you think!

Add the ability to activate Kelvin through a Hue scene

(based on https://de.reddit.com/r/Hue/comments/658mq2/i_havent_checked_out_any_new_hue_apps_since_i_got/dgdor5k/)

Currently Kelvin will take control of your lights once you turn them on. This works fine as long as you want it to be your default setting. If you have a Hue Tap or Hue Dimmer with multiple configured scenes this might not be the case.

It would be nice to activate Kelvin based on a specific scene. As soon as this scene gets active (via tap, dimmer or app) Kelvin will adjust your lights. In addition to this it might be a good idea to re-enable Kelvin after a manual light change.

Kelvin thinks light is constantly being turned off and on again

Hi again,

I discovered that some of my lights sometimes are in a constant loop state of being turned on and off according to Kelvin, even though the lights them selves are on all the time.

time="2018/01/04 10:40:15" level=info msg="πŸ’‘ Light EntrΓ© - Light just appeared."
time="2018/01/04 10:40:15" level=info msg="πŸ’‘ Light EntrΓ© - Initializing state to 2750K at 100% brightness."
time="2018/01/04 11:55:04" level=info msg="πŸ’‘ Light EntrΓ© - Light was turned off. Clearing state..."
time="2018/01/04 11:55:33" level=info msg="πŸ’‘ Light EntrΓ© - Light just appeared."
time="2018/01/04 11:55:33" level=info msg="πŸ’‘ Light EntrΓ© - Initializing state to 2750K at 100% brightness."
time="2018/01/04 12:18:11" level=info msg="πŸ’‘ Light EntrΓ© - Light was turned off. Clearing state..."
time="2018/01/04 12:18:25" level=info msg="πŸ’‘ Light EntrΓ© - Light just appeared."
time="2018/01/04 12:18:25" level=info msg="πŸ’‘ Light EntrΓ© - Initializing state to 2750K at 100% brightness."
time="2018/01/04 12:23:10" level=info msg="πŸ’‘ Light EntrΓ© - Light was turned off. Clearing state..."
time="2018/01/04 12:23:16" level=info msg="πŸ’‘ Light EntrΓ© - Light just appeared."
time="2018/01/04 12:23:16" level=info msg="πŸ’‘ Light EntrΓ© - Initializing state to 2750K at 100% brightness."
time="2018/01/04 12:24:59" level=info msg="πŸ’‘ Light EntrΓ© - Light was turned off. Clearing state..."
time="2018/01/04 12:25:31" level=info msg="πŸ’‘ Light EntrΓ© - Light just appeared."
time="2018/01/04 12:25:31" level=info msg="πŸ’‘ Light EntrΓ© - Initializing state to 2750K at 100% brightness."
time="2018/01/04 12:38:18" level=info msg="Looking for updates..."
time="2018/01/04 12:38:19" level=warning msg="Error looking for update: Invalid Semantic Version"

Same thing happened to two other lights yesterday evening. I made it stop by turning off the light and on again using another scene. Don't know if the scene change was necessary.

Also as you can see at the end, the update feature isn't working in the Docker container.

Kelvin thinks that I’m changing the lights manually and it loops

I’m not sure if this might be related to issue #20, but Kelvin seems to think that I’m changing the lights manually even when I’m not, which results in Kelvin activating and disabling itself continuously. (I have the Hue scene set to β€œReading (default Kelvin)” so that Kelvin will activate with the default schedule automatically.)

Here’s the output when I run Kelvin normally:

$ ./kelvin
INFO[2018/21/06 13:05:24] Kelvin v1.1.6 starting up... πŸš€               
INFO[2018/21/06 13:05:24] Looking for updates...                       
INFO[2018/21/06 13:05:24] βš™ Configuration config.json loaded           
INFO[2018/21/06 13:05:24] ⌘ Connection to bridge established           
INFO[2018/21/06 13:05:24] ⌘ Devices found on current bridge:           
INFO[2018/21/06 13:05:24] | Name                 |  ID | On    | Dimmable | Temperature | Color | 
INFO[2018/21/06 13:05:24] | Small desk lamp      |   1 | true  | true     | true        | true  | 
INFO[2018/21/06 13:05:24] | Large desk lamp      |   2 | true  | true     | true        | true  | 
INFO[2018/21/06 13:05:24] | Patio lamp           |   3 | true  | true     | true        | true  | 
INFO[2018/21/06 13:05:24] | Bedside lamp         |   5 | true  | true     | true        | true  | 
INFO[2018/21/06 13:05:24] 🌍 Working with location 32.9143, -96.7366 from configuration 
INFO[2018/21/06 13:05:25] πŸ’‘ Light Large desk lamp - Activating schedule for Jun 21 2018 (Sunrise: 06:18, Sunset: 20:38) 
INFO[2018/21/06 13:05:25] πŸ’‘ Light Bedside lamp - Activating schedule for Jun 21 2018 (Sunrise: 06:18, Sunset: 20:38) 
INFO[2018/21/06 13:05:25] πŸ’‘ Light Bedside lamp - Activating interval 06:18 - 20:38 
INFO[2018/21/06 13:05:25] πŸ’‘ Light Patio lamp - Activating schedule for Jun 21 2018 (Sunrise: 06:18, Sunset: 20:38) 
INFO[2018/21/06 13:05:25] πŸ’‘ Light Patio lamp - Activating interval 06:18 - 20:38 
INFO[2018/21/06 13:05:25] πŸ’‘ Light Large desk lamp - Activating interval 06:18 - 20:38 
INFO[2018/21/06 13:05:25] πŸ’‘ Light Small desk lamp - Activating schedule for Jun 21 2018 (Sunrise: 06:18, Sunset: 20:38) 
INFO[2018/21/06 13:05:25] πŸ’‘ Light Small desk lamp - Activating interval 06:18 - 20:38 
INFO[2018/21/06 13:05:26] πŸ’‘ Light Patio lamp - Light just appeared.    
INFO[2018/21/06 13:05:26] πŸ’‘ Light Patio lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:26] πŸ’‘ Light Small desk lamp - Light just appeared. 
INFO[2018/21/06 13:05:26] πŸ’‘ Light Small desk lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:26] πŸ’‘ Light Large desk lamp - Light just appeared. 
INFO[2018/21/06 13:05:26] πŸ’‘ Light Large desk lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:26] πŸ’‘ Light Bedside lamp - Light just appeared.  
INFO[2018/21/06 13:05:26] πŸ’‘ Light Bedside lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:27] πŸ’‘ Light Bedside lamp - Light state has been changed manually. Disabling Kelvin... 
INFO[2018/21/06 13:05:27] πŸ’‘ Light Large desk lamp - Light state has been changed manually. Disabling Kelvin... 
INFO[2018/21/06 13:05:27] πŸ’‘ Light Small desk lamp - Light state has been changed manually. Disabling Kelvin... 
INFO[2018/21/06 13:05:27] πŸ’‘ Light Patio lamp - Light state has been changed manually. Disabling Kelvin... 
INFO[2018/21/06 13:05:28] πŸ’‘ Light Large desk lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:28] πŸ’‘ Light Small desk lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:28] πŸ’‘ Light Bedside lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:28] πŸ’‘ Light Patio lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:29] πŸ’‘ Light Bedside lamp - Light state has been changed manually. Disabling Kelvin... 
INFO[2018/21/06 13:05:29] πŸ’‘ Light Large desk lamp - Light state has been changed manually. Disabling Kelvin... 
INFO[2018/21/06 13:05:29] πŸ’‘ Light Patio lamp - Light state has been changed manually. Disabling Kelvin... 
INFO[2018/21/06 13:05:29] πŸ’‘ Light Small desk lamp - Light state has been changed manually. Disabling Kelvin... 
INFO[2018/21/06 13:05:30] πŸ’‘ Light Patio lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:30] πŸ’‘ Light Large desk lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:30] πŸ’‘ Light Small desk lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:30] πŸ’‘ Light Bedside lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:31] πŸ’‘ Light Large desk lamp - Light state has been changed manually. Disabling Kelvin... 
INFO[2018/21/06 13:05:31] πŸ’‘ Light Small desk lamp - Light state has been changed manually. Disabling Kelvin... 
INFO[2018/21/06 13:05:31] πŸ’‘ Light Patio lamp - Light state has been changed manually. Disabling Kelvin... 
INFO[2018/21/06 13:05:31] πŸ’‘ Light Bedside lamp - Light state has been changed manually. Disabling Kelvin... 
INFO[2018/21/06 13:05:32] πŸ’‘ Light Patio lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:32] πŸ’‘ Light Small desk lamp - Detected matching target state. Activating Kelvin... 
INFO[2018/21/06 13:05:32] πŸ’‘ Light Bedside lamp - Detected matching target state. Activating Kelvin... 

And if it may help, here’s the output from Kelvin when I run it with ./kelvin --debug:
Kelvin - debug log.txt

P.S. I’m using a combination of 2nd generation Hue White and Color Ambiance bulbs and 3rd generation Hue White and Color Ambiance bulbs. And I’ve also double-checked that they have the latest firmware.

Provide a graphical interface for Kelvin

Currently the user of Kelvin has to manually edit the config.json file to interact with the application. This is not only error prone but also a big hurdle for inexperienced or non-technical users. In order to be usable by a broader user base, Kelvin should provide a graphical interface for setup and configuration.

As most installations of Kelvin are probably headless (on a raspberry pi) a web interface seems to be a reasonable choice. It allows access from all kinds of devices (desktop to smartphone) and should suitable for the relatively simple tasks:

  • Initial setup and authorization on the bridge
  • Editing of the schedules (create, update, delete)
  • Overview of the current status

Over the last weeks I implemented an initial version of this interface and you can use it right now if you clone and run the master branch. Just change the webinterface.enabled setting to true and point a browser to the computer running Kelvin on port 8080. You should see something like seen on the following screenshots:

kelvin-dashboard
kelvin-schedules
kelvin-configuration

Tell me what you think?

(Note: The next release of Kelvin will contain this changes being disabled by default)

Installing Kelvin on headless raspberry pi

I just recently bought my first raspberry pi. Put I'm having trouble figuring out how to install it on a headless version of jessie. I've read through your guides but can't seem to wrap my head around it.

And thank you for providing this neat application!

Request: Let user define sunrise/sunset offset

I really enjoy using Kelvin, but at sunset time it is already quite dark and the 4000K at 100%, that I've defined as daytime setting, is too hard on the eyes.
Would it be possible to let the user define a sunset and sunrise offset, so that the adjustments would begin earlier and the lights thereby would have reached a more comfortable setting at the real sunset..?

Thanks in advance!

Typo in web config

The Configuration page has a typo under the first box

"Hue Brigde" should be "Hue Bridge"

kelvin typo

official docker image: possible memory leak?

Hey Stefan,

first I would like to thank you for this amazing software πŸ‘

Second, I grabbed kelvin:latest from the docker registry and run it on my Synology NAS. This works well, at startup the container consumes about 6MB RAM but after ~8 hours this has increased to nearly 200MB and looks to be increasing still. I'm wondering if there is some kind of memory leak or whether this is known behavior and will top out eventually. My NAS is limited on RAM so I'm a bit worried.

cheers
AZ

Spurious "manual change"

I have a setup with a hue bridge, 3 hue lights (colour + temperature capable) and 2 ambience lights (temperature capable). I've been spuriously getting problems where some lights seemingly randomly "desync" from their expected state. In the logs I find the "changed manually" message which I have not done.

After running with debug enabled I have been able to gather some data:

 $ journalctl --no-tail -u kelvin | grep -i changed
Nov 25 14:04:38 raspberrypi kelvin[14308]: time="2018/25/11 14:04:38" level=debug msg="βš™ Configuration hasn't changed. Omitting write."
Nov 25 14:04:41 raspberrypi kelvin[14308]: time="2018/25/11 14:04:41" level=debug msg="βš™ Configuration hasn't changed. Omitting write."
Nov 25 17:22:45 raspberrypi kelvin[14308]: time="2018/25/11 17:22:45" level=debug msg="πŸ’‘ HueLight Hue color lamp 1 - Brightness has changed! Current light state: &{Name:Hue color lamp 1 HueLight:{Id:1 Name:Hue color lamp 1 Attributes:{State:{Hue:41460 On:true Effect:none Alert:none Bri:241 Sat:77 Ct:153 Xy:[0.3129 0.3289] Reachable:true ColorMode:xy} Type:Extended color light Name:Hue color lamp 1 ModelId:LCT015 UniqueId:00:17:88:01:03:7a:c0:ef-0b ManufacturerName:Philips ProductName:Hue color lamp SoftwareVersion:1.29.0_r21169} bridge:0x7440a8} SetColorTemperature:6500 SetBrightness:94 TargetColorTemperature:153 TargetColor:[0.313 0.329] TargetBrightness:238 CurrentColorTemperature:153 CurrentColor:[0.313 0.329] CurrentBrightness:241 CurrentColorMode:xy SupportsColorTemperature:true SupportsXYColor:true Dimmable:true Reachable:true On:true MinimumColorTemperature:2000}"
Nov 25 17:22:45 raspberrypi kelvin[14308]: time="2018/25/11 17:22:45" level=debug msg="πŸ’‘ HueLight Hue color lamp 1 - Brightness has changed! Current light state: &{Name:Hue color lamp 1 HueLight:{Id:1 Name:Hue color lamp 1 Attributes:{State:{Hue:41460 On:true Effect:none Alert:none Bri:241 Sat:77 Ct:153 Xy:[0.3129 0.3289] Reachable:true ColorMode:xy} Type:Extended color light Name:Hue color lamp 1 ModelId:LCT015 UniqueId:00:17:88:01:03:7a:c0:ef-0b ManufacturerName:Philips ProductName:Hue color lamp SoftwareVersion:1.29.0_r21169} bridge:0x7440a8} SetColorTemperature:6500 SetBrightness:94 TargetColorTemperature:153 TargetColor:[0.313 0.329] TargetBrightness:238 CurrentColorTemperature:153 CurrentColor:[0.313 0.329] CurrentBrightness:241 CurrentColorMode:xy SupportsColorTemperature:true SupportsXYColor:true Dimmable:true Reachable:true On:true MinimumColorTemperature:2000}"
Nov 25 17:22:45 raspberrypi kelvin[14308]: time="2018/25/11 17:22:45" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Light state has been changed manually: {Name:Hue color lamp 1 HueLight:{Id:1 Name:Hue color lamp 1 Attributes:{State:{Hue:41460 On:true Effect:none Alert:none Bri:241 Sat:77 Ct:153 Xy:[0.3129 0.3289] Reachable:true ColorMode:xy} Type:Extended color light Name:Hue color lamp 1 ModelId:LCT015 UniqueId:00:17:88:01:03:7a:c0:ef-0b ManufacturerName:Philips ProductName:Hue color lamp SoftwareVersion:1.29.0_r21169} bridge:0x7440a8} SetColorTemperature:6500 SetBrightness:94 TargetColorTemperature:153 TargetColor:[0.313 0.329] TargetBrightness:238 CurrentColorTemperature:153 CurrentColor:[0.313 0.329] CurrentBrightness:241 CurrentColorMode:xy SupportsColorTemperature:true SupportsXYColor:true Dimmable:true Reachable:true On:true MinimumColorTemperature:2000}"
...

Logs for color lamp 1 around and before the time of the first event:

time="2018/25/11 17:03:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:03:43" level=debug msg="πŸ’‘ HueLight Hue color lamp 1 - Setting light state to 6500K and 96% brightness."
time="2018/25/11 17:03:45" level=debug msg="πŸ’‘ HueLight Hue color lamp 1 - Light was successfully updated."
time="2018/25/11 17:03:45" level=info msg="πŸ’‘ Light Hue color lamp 1 - Updated light state to 6500K at 96% brightness"
time="2018/25/11 17:04:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:04:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:05:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:05:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:06:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:06:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:07:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:07:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:08:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:08:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:09:43" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:09:43" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:10:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:10:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:11:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:11:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:12:43" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:12:43" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:96}"
time="2018/25/11 17:13:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:13:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:14:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:14:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:15:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:15:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:16:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:16:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:17:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:17:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:18:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:18:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:19:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:19:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:20:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:20:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:21:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:21:43" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:95}"
time="2018/25/11 17:22:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - The calculated lightstate for the interval 16:26 - 18:00 is {ColorTemperature:6500 Brightness:94}"
time="2018/25/11 17:22:42" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Updated target state to {ColorTemperature:6500 Brightness:94}"
time="2018/25/11 17:22:43" level=debug msg="πŸ’‘ HueLight Hue color lamp 1 - Setting light state to 6500K and 94% brightness."
time="2018/25/11 17:22:45" level=debug msg="πŸ’‘ HueLight Hue color lamp 1 - Brightness has changed! Current light state: &{Name:Hue color lamp 1 HueLight:{Id:1 Name:Hue color lamp 1 Attributes:{State:{Hue:41460 On:true Effect:none Alert:none Bri:241 Sat:77 Ct:153 Xy:[0.3129 0.3289] Reachable:true ColorMode:xy} Type:Extended color light Name:Hue color lamp 1 ModelId:LCT015 UniqueId:00:17:88:01:03:7a:c0:ef-0b ManufacturerName:Philips ProductName:Hue color lamp SoftwareVersion:1.29.0_r21169} bridge:0x7440a8} SetColorTemperature:6500 SetBrightness:94 TargetColorTemperature:153 TargetColor:[0.313 0.329] TargetBrightness:238 CurrentColorTemperature:153 CurrentColor:[0.313 0.329] CurrentBrightness:241 CurrentColorMode:xy SupportsColorTemperature:true SupportsXYColor:true Dimmable:true Reachable:true On:true MinimumColorTemperature:2000}"
time="2018/25/11 17:22:45" level=warning msg="πŸ’‘ HueLight Hue color lamp 1 - Failed to update light state: &{Name:Hue color lamp 1 HueLight:{Id:1 Name:Hue color lamp 1 Attributes:{State:{Hue:41460 On:true Effect:none Alert:none Bri:241 Sat:77 Ct:153 Xy:[0.3129 0.3289] Reachable:true ColorMode:xy} Type:Extended color light Name:Hue color lamp 1 ModelId:LCT015 UniqueId:00:17:88:01:03:7a:c0:ef-0b ManufacturerName:Philips ProductName:Hue color lamp SoftwareVersion:1.29.0_r21169} bridge:0x7440a8} SetColorTemperature:6500 SetBrightness:94 TargetColorTemperature:153 TargetColor:[0.313 0.329] TargetBrightness:238 CurrentColorTemperature:153 CurrentColor:[0.313 0.329] CurrentBrightness:241 CurrentColorMode:xy SupportsColorTemperature:true SupportsXYColor:true Dimmable:true Reachable:true On:true MinimumColorTemperature:2000}"
time="2018/25/11 17:22:45" level=info msg="πŸ’‘ Light Hue color lamp 1 - Updated light state to 6500K at 94% brightness"
time="2018/25/11 17:22:45" level=debug msg="πŸ’‘ HueLight Hue color lamp 1 - Brightness has changed! Current light state: &{Name:Hue color lamp 1 HueLight:{Id:1 Name:Hue color lamp 1 Attributes:{State:{Hue:41460 On:true Effect:none Alert:none Bri:241 Sat:77 Ct:153 Xy:[0.3129 0.3289] Reachable:true ColorMode:xy} Type:Extended color light Name:Hue color lamp 1 ModelId:LCT015 UniqueId:00:17:88:01:03:7a:c0:ef-0b ManufacturerName:Philips ProductName:Hue color lamp SoftwareVersion:1.29.0_r21169} bridge:0x7440a8} SetColorTemperature:6500 SetBrightness:94 TargetColorTemperature:153 TargetColor:[0.313 0.329] TargetBrightness:238 CurrentColorTemperature:153 CurrentColor:[0.313 0.329] CurrentBrightness:241 CurrentColorMode:xy SupportsColorTemperature:true SupportsXYColor:true Dimmable:true Reachable:true On:true MinimumColorTemperature:2000}"
time="2018/25/11 17:22:45" level=debug msg="πŸ’‘ Light Hue color lamp 1 - Light state has been changed manually: {Name:Hue color lamp 1 HueLight:{Id:1 Name:Hue color lamp 1 Attributes:{State:{Hue:41460 On:true Effect:none Alert:none Bri:241 Sat:77 Ct:153 Xy:[0.3129 0.3289] Reachable:true ColorMode:xy} Type:Extended color light Name:Hue color lamp 1 ModelId:LCT015 UniqueId:00:17:88:01:03:7a:c0:ef-0b ManufacturerName:Philips ProductName:Hue color lamp SoftwareVersion:1.29.0_r21169} bridge:0x7440a8} SetColorTemperature:6500 SetBrightness:94 TargetColorTemperature:153 TargetColor:[0.313 0.329] TargetBrightness:238 CurrentColorTemperature:153 CurrentColor:[0.313 0.329] CurrentBrightness:241 CurrentColorMode:xy SupportsColorTemperature:true SupportsXYColor:true Dimmable:true Reachable:true On:true MinimumColorTemperature:2000}"
time="2018/25/11 17:22:53" level=info msg="πŸ’‘ Light Hue color lamp 1 - Detected matching target state. Activating Kelvin..."
time="2018/25/11 17:22:53" level=debug msg="πŸ’‘ HueLight Hue color lamp 1 - Setting light state to 6500K and 94% brightness."
time="2018/25/11 17:22:55" level=debug msg="πŸ’‘ HueLight Hue color lamp 1 - Light was successfully updated."

It looks like the last successful update was:

time="2018/25/11 17:03:43" - Setting light state to 6500K and 96% brightness."
time="2018/25/11 17:03:45" - Light was successfully updated."

The light brightness was then updated to 95 and 94 before the next set was attempted 19 minutes later:

time="2018/25/11 17:22:43" - Setting light state to 6500K and 94% brightness."

Formatting the interesting bits of the changed message for readability:

SetColorTemperature:6500
SetBrightness:94
TargetColorTemperature:153
TargetColor:[0.313 0.329]
TargetBrightness:238                          --- (Brightness 94%)
CurrentColorTemperature:153
CurrentColor:[0.313 0.329]
CurrentBrightness:241                        --- (Brightness 95%)
CurrentColorMode:xy

The value diff is 3 but the threshold for equality here:

if light.Dimmable && light.TargetBrightness != -1 && !equalsInt(light.TargetBrightness, light.CurrentBrightness, 2) {

is 2. I think a value of 3 would have prevented it in this case but I'm not sure if this is the actual fix or if the problem was the light not being updated for 19 minutes?

Bug in computation of colour temperature?

On the line here:

return int((float64(1) / float64(colorTemperature)) * float64(1000000))

If you pass 6500K the result of the computation will be 153.846153846 which will truncate to 153 due to use of int(). According to here the range is 500-154. So 6500K mapping to 153 would be out of range
.

Failing to start on boot due to network issue udp4: missing address

New install of a Raspberry PI following the "Systemd setup on a RaspberryPi" instructions. I received the following error message after reboot:

pi@eqraspberry:~ $ journalctl -fu kelvin
-- Logs begin at Tue 2018-07-17 19:04:48 CDT. --
Jul 17 19:04:51 eqraspberry systemd[1]: Started Kelvin.
Jul 17 19:04:52 eqraspberry kelvin[312]: time="2018/17/07 19:04:52" level=info msg="Kelvin v1.1.8 starting up... πŸš€"
Jul 17 19:04:52 eqraspberry kelvin[312]: time="2018/17/07 19:04:52" level=info msg="βš™ Configuration /home/pi/kelvin/config.json loaded"
Jul 17 19:04:52 eqraspberry kelvin[312]: time="2018/17/07 19:04:52" level=info msg="Looking for updates..."
Jul 17 19:04:52 eqraspberry kelvin[312]: time="2018/17/07 19:04:52" level=fatal msg="dial udp4: missing address"
Jul 17 19:04:52 eqraspberry systemd[1]: kelvin.service: Main process exited, code=exited, status=1/FAILURE
Jul 17 19:04:52 eqraspberry systemd[1]: kelvin.service: Unit entered failed state.
Jul 17 19:04:52 eqraspberry systemd[1]: kelvin.service: Failed with result 'exit-code'.

I noticed the udp4: missing address error and guessed it was network related, so in the Raspberry PI configuration settings I checked the Network at Boot -> Wait for network option. After a reboot the application loaded fine:

pi@eqraspberry:~ $ journalctl -u kelvin
-- Logs begin at Tue 2018-07-17 19:07:47 CDT, end at Tue 2018-07-17 19:09:46 CDT. --
Jul 17 19:08:12 eqraspberry systemd[1]: Started Kelvin.
Jul 17 19:08:13 eqraspberry kelvin[403]: time="2018/17/07 19:08:13" level=info msg="Kelvin v1.1.8 starting up... πŸš€"
Jul 17 19:08:13 eqraspberry kelvin[403]: time="2018/17/07 19:08:13" level=info msg="Looking for updates..."
Jul 17 19:08:13 eqraspberry kelvin[403]: time="2018/17/07 19:08:13" level=info msg="βš™ Configuration /home/pi/kelvin/config.json loaded"
Jul 17 19:08:13 eqraspberry kelvin[403]: time="2018/17/07 19:08:13" level=info msg="Webinterface started on port 8080"
Jul 17 19:08:13 eqraspberry kelvin[403]: time="2018/17/07 19:08:13" level=info msg="⌘ Connection to bridge established"
...

I recommend updating the README to include checking that option as part of either the systemd setup instructions or troubleshooting section. Or update the application so that if the network isn't ready then wait 5 seconds and try again before aborting with a failure code.

redshift integration?

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.

Changing schedule on Kelvin web interface causes "enableWhenLightsAppear" boolean to be reset to false

I know the web interface is in beta, but wanted to give feedback.

Version:
Kelvin v1.1.6 running on a Raspberry Pi 3

Prerequisites:

  1. Web interface in Kelvin should be enabled
  2. "enableWhenLightsAppear" attribute in config.json should be set to true

To recreate:

  1. Open web interface of Kelvin and head to schedules tab
  2. Change/add something (example: add entry for the morning at 2AM with 2400 temperature and 60% brightness).
  3. Hit "Save Schedules" at the bottom
  4. Head to "/home/pi/kelvin" and open config.json
  5. Notice the "enableWhenLightsAppear" has been reset to false even though it was true originally

Please let me know if I am doing something wrong or more info is needed :).

Installing kelvin as a service (the correct way)

I went through and installed kelvin as a service the "correct" way: service specific user (that cannot login), located in the recommended location for unmanaged software not built by the admin and auto started on boot. I found the systemd file under /etc after I wrote this (οΎ‰β‰§βˆ‡β‰¦)οΎ‰ ミ ┸━┸.

Feel free to do as you please with. I'm posting it here as I already went through the motions.

# Fetch release
wget https://github.com/stefanwichmann/kelvin/releases/download/v1.1.9/kelvin-linux-arm-v1.1.9.tar.gz -O /tmp/kelvin-arm.tar.gz

# Create user to run as
sudo adduser --system --group --shell /bin/nologin --no-create-home --home /opt/kelvin kelvin

# Install
sudo mkdir -p /opt/kelvin
cd /opt/kelvin
sudo tar -xvzf /tmp/kelvin-arm.tar.gz
sudo mv kelvin-linux-arm*/* .
sudo rmdir kelvin-linux-arm*
sudo chown -R kelvin:kelvin /opt/kelvin

# Create service file for systemd 
sudo -e /etc/systemd/system/kelvin.service

/etc/systemd/system/kelvin.service:

[Unit]
Description=Kelvin
ConditionPathExists=/opt/kelvin/kelvin
After=network.target

[Service]
Type=simple
User=kelvin
Group=kelvin

Restart=always
RestartSec=10
StartLimitInterval=60s

WorkingDirectory=/opt/kelvin
ExecStart=/opt/kelvin/kelvin

[Install]
WantedBy=multi-user.target

# Start, then press hue button. Restart if necessary
sudo systemctl start kelvin

# Start on boot
sudo systemctl enable kelvin

# Confirm status
sudo systemctl status kelvin

# Clean up
rm /tmp/kelvin-arm.tar.gz

# Edit config to taste
sudo -u kelvin -e /opt/kelvin/config.json
sudo systemctl restart kelvin

# Read Logs
journalctl -fu kelvin.service

Light state has been changed manually.

I keep getting this messsage:

Light state has been changed manually. Disabling Kelvin...

As far as I can tell I have nothing that is manually changing these light settings.

My setup is just a Phillips hue hub. I have turned off the device with the hue app, and still get these errors. No schedules, timers, or motion sensors are configured.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.