Circadian Lighting [Custom Component]

Yeah i got the same problem. The brightness wont update.

You should use lights_ct

Hey Nesty,

Can you perhaps share your config?
I’m also having Ikea lights and I can’t seem to get it running :frowning:

Hello,

I’ve updated HA to 0.84.5 and now the component is broken


Edit, nevermind, shall be solved by this commit: https://github.com/claytonjn/home-assistant/commit/19902f6ff12888bb8b5aea77e23876a1319c8aa1

The update procedure which worked from me:

  • from HA < 0.84, reinstall CL with the link in first post
  • reboot HA, CL composant failed to load
  • upgrade to HA 0.84.5 (:latest)
  • working.

This may not be the best way, but that worked. I don’t know if it’s relevant, but I’ve also cleaned history database

Old message

Log Details (ERROR)

Fri Dec 21 2018 13:03:14 GMT+0100 (heure normale d’Europe centrale)

Error loading custom_components.switch.circadian_lighting. Make sure all dependencies are installed

Traceback (most recent call last): 
  File "/usr/src/app/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 "&lt;frozen importlib._bootstrap&gt;", line 994, in _gcd_import File "&lt;frozen importlib._bootstrap&gt;", line 971, in _find_and_load 
  File "&lt;frozen importlib._bootstrap&gt;", line 955, in _find_and_load_unlocked File "&lt;frozen importlib._bootstrap&gt;", line 665, in _load_unlocked 
  File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module 
  File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed 
  File "/config/custom_components/switch/circadian_lighting.py", line 16, in &lt;module&gt; from homeassistant.helpers.restore_state import async_get_last_state 
ImportError: cannot import name 'async_get_last_state'

If it can help, here is a PR to another custom_component that seems to solve the issue:
https://github.com/rogro82/hass-variables/commit/6221f722ce3145ead976e3bdf171d302794ae8ff#diff-1431dc6830fb1bde90297d3b041aadc3

Thanks!

Yes, I see that this works for the E27 980lm bulb.

But it does not work for the E14 400lm candle bulb.This one is fixed-color but the brightness can be varied.
I put these under “light_brightness” but nothing happens.

Another question: would it be possible to use different brightness settings for different groups of lights?
Each group contain the same type/brand of lights, but between groups the brand can differ (yeelight, ikea).

It seems that some people are having issues with brightness adjustment but I haven’t been able to pinpoint what the problem is. It works perfectly with my (primarily) Hue lights, but it seems that it doesn’t work with some others. I think the best place to start would be to set transition to something really small or NULL.

Yes, you can set min_brightness and/or max_brightness at the switch level so that you can have different settings for different groups of lights.

Thank you for your pointers.

Update: never mind, I found an example in the thread, post 74.
About your second remark, as I read the first post, I can set the min and max_brightness for the _ct, _rgb and _xy group. If this is not correct, can you show me how to do this via an example?

I have one dimmer switch that I want to use with this awesome project but have no experience of *.py files or where/how to add them to may HA.

My switch is defined as below:

  - platform: mqtt
# 10.0.1.132
    name: "Koi Quarantine Dimmer"
    state_topic: "stat/koi_dimmer_1/POWER"
    command_topic: "cmnd/koi_dimmer_1/POWER"
    availability_topic: "tele/koi_dimmer_1/LWT"
    brightness_state_topic: "stat/koi_dimmer_1/RESULT"
    brightness_command_topic: "cmnd/koi_dimmer_1/Dimmer"
    brightness_scale: 100
    brightness_value_template: >
      {% if value_json.Dimmer is defined %}
        {{ value_json.Dimmer }}
      {% else %}
        {% if state_attr('light.koi_dimmer_1','brightness') == none %}
          0
        {% else %}
          {{ state_attr('light.koi_dimmer_1','brightness') / 255 * 100 }}
        {% endif %}
      {% endif %}
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

What do I need to do to get this working with Circadian lighting?

Well, I tried what is shown in post 74. Unfortunately nothing works anymore, the lights no longer change.
I went back to a simple config with 1 switch, I noticed the following: when not using “name: xyz” everything works. When I add “name: xyz” below the platform definition, the lights no longer change.
I force a visible change by setting the max-brightness to a high value and a low value. And I restart HA in between.

Some more background on what I reported yesterday:

When I have this in configuration.yaml:

switch:
  - platform: circadian_lighting
    lights_ct:
      - light.yeelight_color2_abc123
      - light.yeelight_color2_abc123
    max_brightness: 20

Everything works fine. In the log (set to debug) I can find these messages:

2018-12-23 10:29:02 DEBUG (SyncWorker_0) [custom_components.switch.circadian_lighting] light.yeelight_color2_abc123 CT Adjusted - color_temp: 217, brightness: 51.0, transition: 900.0

When I update configuration.yaml to this:

switch:
  - platform: circadian_lighting
    name: Yeelight
    lights_ct:
      - light.yeelight_color2_abc123
      - light.yeelight_color2_abc123
    max_brightness: 20

It no longer works. In the log I find this:

2018-12-23 10:41:38 DEBUG (SyncWorker_4) [custom_components.switch.circadian_lighting] Yeelight off - not adjusting

And the light is definitely on.

Am I doing something wrong? Or have I found a bug?

When the log says Yeelight off it’s referring to the Circadian Lighting switch that you named Yeelight not the actual lights. When you saw that log entry was the Yeelight Circadian Lighting switch turned on?

Yes, the switch, either named named switch.yeelight_circadian_lighting or switch.circadian_lighting_circadian_lighting, is on both times.
But in the first case the lights are not adjusting.

Maybe try flipping it off and back on? I really have no idea, according to the log the python code thinks the switch is off. I have all my CL switches named so that shouldn’t be an issue so the only thing I can think of is that changing the name changes the entity_id which is making the system think the CL switch is off.

Sorry, I didn’t look properly, the switch was off :frowning:

Sorry about that, too much assuming from my part instead of checking.

After turning the switch to on, the lights adjust.

And, after another restart of HA, the switch stays on!
A little peculiar, but knowing this now, I can live with it :slight_smile:
May I suggest that you add some info about this to the first post?

Hello all,

Does anybody have Yeelight disconnection problem using this component?

I have issues with lights disconnecting (becoming unavailable in both Yeelight/Mihome and Home Assistant) when they are ON and CL switch is ON. I can reproduce easily.
No problem when CL is disabled.

I’ve tried several interval/transition, it may help a little but does not solve.

Wife Acceptance Factor is decreasing, please help ;), she wants to use wall switch now :woozy_face:

I have no experience with Yeelights but is it possible that they’re actually becoming unavailable regardless of CL but that they don’t show that they’re unavailable because they aren’t being regularly adjusted without CL?

For example, by default CL makes adjustments to the lights every 15 minutes. Perhaps the lights are unavailable but don’t indicate as such until CL tries to adjust the lights and can’t. The service calls CL uses are the exact same as adjusting the lights in the Home Assistant front end, or what any other component would use so the only thing different is the interval at which they are adjusted. It seems odd to me that the lights would become unavailable in the native apps as well, unless before CL they were unavailable just as frequently but they didn’t indicate that because nothing tried and failed to adjust them.

1 Like

Thank you Clayton for your answer

I absolutely follow you and I’ve already tried something

With this config I have disconnection:

CL config
circadian_lighting:
  min_colortemp: 2700 #2700K=370 mired
  max_colortemp: 6500 #6500K=153 mired
  sunrise_time: '08:00'
  sunset_time: '18:00'
  interval: 300
  transition: 2
CL Switch config
  - platform: circadian_lighting
    lights_ct:
      - light.yeelight_ct2_7c49ebb78f5d # Lampe établi entrée
      - light.yeelight_ct2_7c49ebb7d4ce # Lampe mur entrée
      - light.yeelight_ct2_7c49ebb78ca6 # Lampe escalier entrée
    min_brightness: 50
    sleep_entity: 'binary_sensor.mode_nuit'
    sleep_state: 'on'
    sleep_brightness: 1
    name: Luminothérapie Entrée

  - platform: circadian_lighting
    lights_ct:
      - light.yeelight_ct2_7c49ebb7d72d # Lampe meuble téléphone salon
      - light.yeelight_ct2_7c49ebb7d182 # Lampe mur salon
      - light.yeelight_ct2_7c49ebb79243 # Lampe escalier salon
      - light.yeelight_ct2_7c49ebb7ceb7 # Lampe mezzanine
    sleep_entity: 'binary_sensor.mode_nuit'
    sleep_state: 'on'
    sleep_brightness: 1
    name: Luminothérapie Séjour

If I do this automation with the above config I have few to none.

Switch automation
- id: '1545850535761'
  alias: Circadian timer
  trigger:
  - platform: time
    minutes: /5
    seconds: 0
  condition:
  - condition: state
    entity_id: input_boolean.luminotherapie
    state: 'on'
  action:
  - data:
      entity_id:
      - switch.circadian_lighting_luminotherapie_entree
      - switch.circadian_lighting_luminotherapie_sejour
    service: switch.turn_on
  - delay: '00:00:20'
  - data:
      entity_id:
      - switch.circadian_lighting_luminotherapie_entree
      - switch.circadian_lighting_luminotherapie_sejour
    service: switch.turn_off
1 Like

Yeelight lamps use wifi for the connection. Make sure that the wifi-signal at the lamp-positions is strong enough.
Also, check the firmware of the lamps, if it is up to date (which server are you on?)
Another thing that can cause problems: assign a unique IP-address to each lamp. I had a problem with one lamp due to this, I had assigned the same IP to the lamp and the TV.

I have no problems with Circadian Lighting and my 2 Yeelight Color2 Bulbs.

1 Like

Thank for your tips

Even the lamp on the same furniture as the router can disconnect. Wifi signal is strong and the farest lamp is 6 meter in line of sight of the router
Firmware is the latest. I’m on German server (living in France, it’s the recommended one). Tried mainland China and Singapour also.
Tried Lede 17.1 and OpenWRT 18.6 (not sure about minors) on my TPLink also.
DHCP is set to give a fixed IP, leasetime is infinite. tried to reduce it at 15 min, 1 hour, 5 hours, 1 day. no success

May you share your CL and switch config please?
With interval at 300 and transition at 2 it seems my problem is solved. (was 60/59 before because I read Yeeligt don’t support long transition time)
I still have no brightness control in sleep mode, but now, CL switches go off.