Circadian Lighting [Custom Component]

Nothing noted in Configuration validation?

Iā€™m not at all familiar with on_level, I assume this is ISY specific?

Iā€™m not sure why two lights would get different brightness values, Iā€™d have to see the log for that. You probably shouldnā€™t have light.piano_room_table_lamp listed under both lights_xy and lights_rgb though.

In terms of the table lamp, at the time of the log it looks like CL calculated that the sun is still up - from sunrise to sunset brightness stays at 100%. Line 1 shows that it was 8:19pm, line 3 shows sunset as being 8:30pm. That all looks proper to me.

Iā€™d have to see the log for the bathroom light to troubleshoot that as well.

I thought I had pulled piano_room_table_lamp from rgb, thatā€™s from back when I was first testing it trying to figure how to best control that lamp. Itā€™s one of the Inovelli RGB bulbs, so is a bit funky. Oddly enough, it seems to work correctly.

Iā€™ll double check the great room table lamp tomorrow night. I would check it tonight, but I donā€™t think my other half would appreciate it since he fell asleep on the couch watching tv right next to that lamp. :slight_smile: I may need to play with the sunset/sunrise offsets a bit. Iā€™m in a valley so having mountains on both sides makes it get darker before the official sunset time.

As for the bathroom light, let me see if I can reproduce that in the morning. I did just try the master bathroom light and it seems to be doing the correct thing now. Itā€™s being set at 76%, although it took nearly a minute to go from the initial level up to that. However, in looking at the logs that looks like it may be an issue in what it is reporting, as it shows transitioning from off to off in the logs - which seems bizarre. You can see that it was pulling 3W (itā€™s a set of 5 LED bulbs) at 21:08:20, yet it reported that the state was off. It doesnā€™t show the state transition to on until 21:09:01, and your code changes it 7 seconds later. The next time I turned it on, via. the HA web interface, it reported correctly. And when I just went in and turned it on at the switch again, it did the right thing at 21:26.

2020-06-18 21:07:31 DEBUG (SyncWorker_12) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from None to <state light.master_bathroom_light=unavailable; restored=True, supported_features=33, friendly_name=Master Bathroom Light @ 2020-06-18T21:07:31.264344-07:00>
2020-06-18 21:07:36 DEBUG (SyncWorker_0) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=unavailable; restored=True, supported_features=33, friendly_name=Master Bathroom Light @ 2020-06-18T21:07:31.264344-07:00> to <state light.master_bathroom_light=off; node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:07:36.062804-07:00>
2020-06-18 21:08:20 DEBUG (SyncWorker_5) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=off; node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:07:36.062804-07:00> to <state light.master_bathroom_light=off; node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=3.1, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:07:36.062804-07:00>
2020-06-18 21:09:01 DEBUG (SyncWorker_6) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=off; node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=3.1, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:07:36.062804-07:00> to <state light.master_bathroom_light=on; brightness=75, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=3.1, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:09:01.113891-07:00>
2020-06-18 21:09:01 DEBUG (SyncWorker_6) [custom_components.circadian_lighting.switch] light.master_bathroom_light Brightness Adjusted - brightness: 200, transition: 1.0
2020-06-18 21:09:08 DEBUG (SyncWorker_12) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=on; brightness=75, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=3.1, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:09:01.113891-07:00> to <state light.master_bathroom_light=on; brightness=201, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=3.1, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:09:01.113891-07:00>
2020-06-18 21:09:51 DEBUG (SyncWorker_16) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=on; brightness=201, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=3.1, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:09:01.113891-07:00> to <state light.master_bathroom_light=off; node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=3.1, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:09:51.929241-07:00>
2020-06-18 21:09:55 DEBUG (SyncWorker_0) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=off; node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=3.1, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:09:51.929241-07:00> to <state light.master_bathroom_light=off; node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:09:51.929241-07:00>
2020-06-18 21:15:00 DEBUG (SyncWorker_6) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=off; node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:09:51.929241-07:00> to <state light.master_bathroom_light=on; brightness=201, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:15:00.958183-07:00>
2020-06-18 21:15:01 DEBUG (SyncWorker_6) [custom_components.circadian_lighting.switch] light.master_bathroom_light Brightness Adjusted - brightness: 195, transition: 1.0
2020-06-18 21:15:02 DEBUG (SyncWorker_14) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=on; brightness=201, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:15:00.958183-07:00> to <state light.master_bathroom_light=on; brightness=196, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:15:00.958183-07:00>
2020-06-18 21:15:07 DEBUG (SyncWorker_15) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=on; brightness=196, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:15:00.958183-07:00> to <state light.master_bathroom_light=on; brightness=196, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=2.4, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:15:00.958183-07:00>
2020-06-18 21:26:46 DEBUG (SyncWorker_5) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=off; node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:25:16.987147-07:00> to <state light.master_bathroom_light=on; brightness=75, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:26:46.313833-07:00>
2020-06-18 21:26:46 DEBUG (SyncWorker_5) [custom_components.circadian_lighting.switch] light.master_bathroom_light Brightness Adjusted - brightness: 184, transition: 1.0
2020-06-18 21:26:47 DEBUG (SyncWorker_9) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=on; brightness=75, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:26:46.313833-07:00> to <state light.master_bathroom_light=on; brightness=108, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:26:46.313833-07:00>
2020-06-18 21:26:48 DEBUG (SyncWorker_5) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=on; brightness=108, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:26:46.313833-07:00> to <state light.master_bathroom_light=on; brightness=183, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:26:46.313833-07:00>
2020-06-18 21:26:53 DEBUG (SyncWorker_13) [custom_components.circadian_lighting.switch] light.master_bathroom_light change from <state light.master_bathroom_light=on; brightness=183, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=0.0, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:26:46.313833-07:00> to <state light.master_bathroom_light=on; brightness=183, node_id=53, value_index=0, value_instance=1, value_id=72057594931937281, power_consumption=2.4, friendly_name=Master Bathroom Light, supported_features=33 @ 2020-06-18T21:26:46.313833-07:00>

In looking at the logs, I guess it only exists for Insteon devices. I didnā€™t realize that it wasnā€™t a standard HA light feature, since the Z-Wave switches and lights all support an initial on value by a parameter setting. I thought that HA would have abstracted that in their API.

OK so I checked older version against HA 0.111.4 andā€¦ it works no issues with 1.0.11 and as soon as Iā€™ll update to 1.0.13 HA canā€™t start properly - process of statring and loading all components never ends.

Okay so it looks like youā€™re physically cutting power to the light at the switch? Thatā€™s why it goes from state none to unavailable to off to on when you flip the physical switch on. So line 4 in the log is when HA knows that the switch is on and line 5 is CL sending the adjustment - those timestamps are the same. The line thatā€™s 7 seconds later (line 6) is when HA updates to reflect the changeā€¦Iā€™m not sure why thatā€™s so delayed but CL tries to adjust immediately when the state shows on. The state going from off to off is expected, the state object updates when any attributes update - in the first example (line 3) power consumption updated from 0 to 3.1. This is why when you write an automation if you have a state trigger with to: it will only trigger the first time the entity goes into that state but if you omit to: from the trigger and include the state you want as a condition it can trigger for multiple concurrent instances of the same state.

The problem is there are so many different types of lights, and those that do support this type of feature likely implement it differently. I have one LIFX light that Iā€™m pretty sure supports a similar feature, but with Hue API if you send any settings it turns the lights on - thereā€™s no way to change settings and keep light(s) off. Thereā€™s Z-Wave, Zigbee, WiFi, Bluetooth, and probably other types of lights that will all behave differently. Plus, for Z-Wave alone you could have the direct Z-Wave integration, the new OpenZWave beta, Zwave2MQTT, Z-Wave through ISY, etc.

Sounds like thereā€™s a problem installing the required timezonefinder package. Iā€™ve gone back and forth with that - I really donā€™t want to include it but I havenā€™t been able to find a way to normalize timezones between the HA instance and between Astral (how CL gets sunrise, sunset, etc) without it. Maybe someone smarter than me will be able to point me in the right directionā€¦

So itā€™s a kind of a bug in HA - I mean they change this too often or what? Anyway Iā€™ll stay on 1.0.11 for now

Yeah, Iā€™m thinking I may just implement this myself. Iā€™ve made a start with the bathroom light:

This seems to be doing the right thing so far. Next, the hall, great room, and eventually the kitchen.

Unfortunately, most of my overhead lights are Insteon FanLincs with LED bulbs that donā€™t work well with dimming. They flicker whenever there are Insteon commands on the wire and SmartHome engineering canā€™t (or wonā€™t) find a fix.

That is still a bit odd, as the switch is the z-wave device. I will ping the folks at Inovelli and see if they know why it is reporting this way. The good news is that the automation I wrote to set the inital on-level to whatever the current Circadian brightness is, should address this.

It looks the same for kelvin and color temp
I have to check about flux logs, most likely there is something.

I figured out what is going on. The two switches are part of an Insteon scene as they were three-way switches before I put in the Insteon. I have a motion sensor that triggers the scene, and that was changing them to a different value and wasnā€™t showing up as a brightness change to HA. I fixed it with the node red code that I am using to set the on_level and a program on the ISY that sets the scene on_levels if the on_level of the main controlling switch changes. Itā€™s a bit of a pita, but it seems to solve all of my issues. I no longer have brightness changes when I turn lights on after dark, I have a way to override the dimming (if I double-click the switch on, it turns of the Circadian switch, double-click off re-enables it), and with the scene on_levels updating I donā€™t get brightness changes if the motion sensor triggers.

I just need to figure out what to do with my LED lights that can support a low dim level, but have to come on to a brighter level first in order to come on at all. I may just add a ā€œfloorā€ value to my automations that set the on level. That would let them come on, and Circadian would dim them down to the appropriate level.

All in all, great job on this module!

Iā€™m glad I stumbled across this component which is very new to me; Iā€™ve only had 24 nice hours to play with it. I know it is much more configurable than flux which is what I came from, but can it also do what flux can?

Specifically,
#1 is there a way to set what the precise color temperature will be at sunset, and then also a configurable end time with another configurable color temperature?

#2 I also noticed that the brightness got way too dim way too early for me - is there a way to configure it such that it stays at X brightness until a certain time, and then and only then does it proceed to lower in brightness?

#3 Can sleep mode be configured with something other than a 1000-10000K color temperature? My normal middle-of-the-night sleep settings have the lights that lead to the bathroom turn on with 5% brightness and the color red so as to not ruin my sleepy night vision. Unless Iā€™m missing something, pure red canā€™t be expressed in kelvins. If it makes any difference, almost all of the bulbs being controlled are Hue color ambiance with a couple Hue white ambiance and other brands sprinkled in.

#4 Finally, are the component variables (e.g., min/max color temperature & brightness) exclusive to the component configuration settings, and thus must be applied to all CL switches? Or can I set different color temperature/brightness settings for individual CL switches?

Iā€™m sure I can achieve all of the above by having several CL switches operating during limited times, and then switching them off and having additional automatons and scripts take over without the use of this component, but Iā€™d much prefer to keep it all within the CL component if I can. Thank you in advance for your help!

No, the min_colortemp is the temperature at sunset and after sunset lights remain that temperature until sunrise.

Lights will be max_brightness from sunrise-sunset, and will dim to min_brightness half way between sunset and sunrise, then will brighten back up to max_brightness at sunrise. The only way to keep brightness higher until a specific time is to adjust sunset time.

Right now sleep mode only takes a temperature. I do almost the exact same thing with our bathroom lights, they come on at 1% red at night. For that set of lights I have the automation that handles motion activation turn off the CL switch for those lights and set the 1%/red when weā€™re sleeping. For all other lights in the house I use the sleep temperature option. Iā€™m hoping to make this more flexible when I finally have the time to move CL to use the UI config rather than YAML.

Color temperature is at the component level, brightness is at the switch level. The primary goal of this component is to keep things rhythmic and consistent, so it really goes against the core mission to allow different temperature settings for different lights. The only real argument for allowing this is to ā€œnormalizeā€ different types of lights that display differently, but Iā€™ve always thought that should be handled at the device integration level rather than this component. If CL asks for 3500k it should assume that the lights are 3500k and users shouldnā€™t have to put in 3200k when they really want 3500k.

Appreciate the quick reply! Explanations to #1-2 are especially useful as that wasnā€™t immediately obvious to me that min_colortemp and max_brightness both occurred simultaneously at sunset. #3 will be simple enough to implement just as you do in your house.

Thanks again!

Any news on the 0.111.4 upgrade issue? Iā€™ve been holding off doing the update. I hear that the 0.112 beta just landed yesterday as well, and Iā€™m hoping it wonā€™t have the same issueā€¦

No issues on 0.111.4 for me. Are you referring to the issues @cpu was (is?) having - if so thatā€™s a result of the CL version including a required package that isnā€™t installing properly, not anything to do with the HA version.

@claytonjn For the issue @cpu reported, is downgrading CL version the recommended quick fix?

I seem to be hitting the same problem. After upgrading HA and then CL, I see the below on startup and CL doesnā€™t load

2020-06-28 02:06:21 ERROR (MainThread) [homeassistant.setup] Error during setup of component circadian_lighting
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/srv/homeassistant/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/srv/homeassistant/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/setup.py", line 190, in _async_setup_component
    result = await asyncio.wait_for(task, SLOW_SETUP_MAX_WAIT)
  File "/usr/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/custom_components/circadian_lighting/__init__.py", line 112, in setup
    interval, transition)
  File "/home/homeassistant/.homeassistant/custom_components/circadian_lighting/__init__.py", line 138, in __init__
    self.data['timezone'] = self.get_timezone()
  File "/home/homeassistant/.homeassistant/custom_components/circadian_lighting/__init__.py", line 157, in get_timezone
    from timezonefinder import TimezoneFinder
  File "/srv/homeassistant/lib/python3.7/site-packages/timezonefinder/__init__.py", line 2, in <module>
    from .timezonefinder import TimezoneFinder
  File "/srv/homeassistant/lib/python3.7/site-packages/timezonefinder/timezonefinder.py", line 8, in <module>
    import numpy as np
  File "/srv/homeassistant/lib/python3.7/site-packages/numpy/__init__.py", line 140, in <module>
    from . import core
  File "/srv/homeassistant/lib/python3.7/site-packages/numpy/core/__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "/srv/homeassistant/bin/python3"
  * The NumPy version is: "1.19.0"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory