Circadian Lighting [Custom Component]

@claytonjn Thanks! I can confirm that fixes it here too.
I replaced the file before upgrading to 0.84.0 and wound up having to delete the custom_components\switch\__pycache__ directory and restart Home Assistant again before the switch returned.

I couldn’t believe it when I got back home from the store and you had already created a fix. Thank you again! This component is amazing!

FYI the command I used to upgrade/roll-back versions is from the Hassio CLI and can be used in an SSH/IDE terminal.

hassio ha update --options version=0.84.0

Interesting…I’m familiar with that command but I didn’t realize it would let you force an update before it shows up in the Hass.io panel in the UI.

Yup, you can run that to upgrade any time, so long as the content is available. I’ve also used it to downgrade back to the previous version. :smile: Thank you again!

Not sure if it’s important as the component seems to be functioning correctly but I noticed this message pops up in the logs on every reboot of Home Assistant:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 349, in _async_add_entity
    await entity.async_added_to_hass()
  File "/config/custom_components/switch/circadian_lighting.py", line 173, in async_added_to_hass
    state = await self.sync_get_last_state()
AttributeError: 'CircadianSwitch' object has no attribute 'sync_get_last_state'

Yup, missed a character. Updated config/custom_components/switch/circadian_lighting.py should fix that. Thanks for letting me know!

:tada: That took care of it. No more errors in the log file. Thanks! :smile:

I updated to 0.84, but now I get error (I downloaded the newest versions of the circadian_lighting.py):

2018-12-12 23:47:24 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.circadian_lighting. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/loader.py", line 92, in get_component
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/custom_components/circadian_lighting.py", line 9, in <module>
    from custom_components.circadian_lighting import DOMAIN, CIRCADIAN_LIGHTING_UPDATE_TOPIC, DATA_CIRCADIAN_LIGHTING
ImportError: cannot import name 'DOMAIN'
2018-12-12 23:47:24 ERROR (MainThread) [homeassistant.loader] Unable to find component circadian_lighting
2018-12-12 23:47:24 ERROR (MainThread) [homeassistant.setup] Setup failed for circadian_lighting: Component not found.

Since you already have the new file in place try stopping home assistant then deleting all of the __pycache__ directories from the custom_components folder and restart Home Assistant again.

Yeah, I tried that, but it doesn’t helped. There is another problem, because of “ImportError: cannot import name ‘DOMAIN’”.

The only thing I can guess is that you’re missing files or they’re not in the right spot. That error shows that it can’t find DOMAIN in custom_components/circadian_lighting.py but line 54 should be

DOMAIN = 'circadian_lighting'

My bad, I had /switch/circadian_lighting.py in /circadian_lighting.py.


I can confirm finally it’s working in 0.84 with Yeelights. Even Flux works. I think the misterious " “Improved service calling” in changelog did the job.

Just one more question:

 - platform: circadian_lighting
    lights_ct:
      - light.yeelight_ceiling_7c49ebb38056    

But If I define whole group of lights: group.yeelight_group, If I turn on one light, all lights are turning on, instead of that one.

If I define lights individually, everything is good.


Some of my lights doesn’t seem to be support mireds color changing, like Xiaomi gateway:

light.gateway_light_34ce00fb6ad7
brightness: 255
hs_color: 27.581,48.627
rgb_color: 255,188,131
xy_color: 0.466,0.378


light.yeelight_rgb_34ce00910f3f
min_mireds: 153
max_mireds: 588
brightness: 255
color_temp: 194
hs_color: 27.192,17.191
rgb_color: 255,231,211
xy_color: 0.366,0.348

I have configured it under lights_ct (mired) and works well. I don’t know the reason why, but it is cool that I don’t need to config it under _xy, _rgb.

Fast forward to afternoon (4:30PM):

2018-12-13 16:42:10 ERROR (SyncWorker_7) [homeassistant.components.light.yeelight] Error when calling &lt;function YeelightLight.set_colortemp at 0x7f0ad73a1378&gt;: {'code': -5000, 'message': 'general error'}

Maybe we are trying to set a value out of the range?

Yeelight:

min_mireds: 153
max_mireds: 370
brightness: 204
color_temp: 170
friendly_name: Yeelight 3
supported_features: 3

Manually setting to 370 works, above I get the error.

{
  "entity_id": "light.yeelight_ceiling_7c49ebb38056",
  "color_temp": 370,
  "brightness": 50,
  "transition": 900
}

Current circedian sensor values:

Yes, my experience is that it’s typically best to set up lights in CL as they are controlled - so if you control lights individually, they should be individually defined in CL; if you always control as a group then the group should be defined in CL.

Yes, I believe that’s what’s happening. Your configuration shows min_mireds: 153 which is equivalent to ~6,500 Kelvin and max_mireds: 370 which is equivalent to ~2,700 Kelvin. In CL you should define min_colortemp: 2700. If you want you could increase max_colortemp to 6500 to utilize the full range of the lights, but that’s past what occurs naturally so I personally wouldn’t change the max.

1 Like

Perfect. Thank you for the help.

Hi,

Sorry, I took some time before experimenting again…

The config with the input_number does change sleep state correctly.

Old config
- platform: circadian_lighting
    lights_ct:
      - light.lampe_etabli_entree # Lampe établi entrée
      - light.lampe_mur_entree # Lampe mur entrée
      - light.lampe_escalier_entree # Lampe escalier entrée
    min_brightness: 50
    sleep_entity: 'input_number.nb_lampes_entree'
    sleep_state: 1.0
    sleep_brightness: 1
    name: Luminothérapie Entrée

Played with CL switch config

New config
  - platform: circadian_lighting
    lights_ct:
      - light.lampe_etabli_entree # Lampe établi entrée
      - light.lampe_mur_entree # Lampe mur entrée
      - light.lampe_escalier_entree # Lampe escalier entrée
    min_brightness: 50
    sleep_entity: 'binary_sensor.mode_nuit'
    sleep_state: 'on'
    sleep_brightness: 2
    name: Luminothérapie Entrée

With old and new config,

CL switch seems to go into sleep mode correctly from log
2018-12-16 10:05:23 DEBUG (SyncWorker_35) [custom_components.switch.circadian_lighting] Luminothérapie Entrée Switch Updated
2018-12-16 10:05:23 DEBUG (SyncWorker_35) [custom_components.switch.circadian_lighting] light.lampe_etabli_entree CT Adjusted - color_temp: 191, brightness: 255.0, transition: 1
2018-12-16 10:05:30 DEBUG (SyncWorker_20) [custom_components.switch.circadian_lighting] Luminothérapie Entrée in Sleep mode

But

brightness is not updated

Sleep state is on,
Sleep brigthness shall be 2
Switch brightness is 100 as it should in my set circadian rythm.

The problem is then it won’t update the brightness.

Hi,

Very interesting addon you made!

Update: never mind, I updated to 0.84.2 and the error is gone :slight_smile:

Are the IKEA Tradfi lamps supported?
Not the color lamps, but the lamps of which only the color temperature and the brightness can be adjusted?

I tried some variations but nothing seems to work?

Yes I am using them.

Which type shall I use for them?
lights_ct** , lights_rgb** or lights_xy**?
How do you have this configured?