claytonjn / hass-circadian_lighting

Circadian Lighting custom component for Home Assistant
Apache License 2.0
776 stars 87 forks source link

2021.5.0 #149

Open matteos1 opened 3 years ago

matteos1 commented 3 years ago

not work with new version 2021.5.0

cdemi commented 3 years ago

Same as #148

filmgarage commented 3 years ago

I love this integration, I can't live without it! :-) Wat can I do to help? Also not working in 2021.5:

Error during setup of component circadian_lighting:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 248, in _async_setup_component
    result = await task
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/circadian_lighting/__init__.py", line 109, in setup
    cl = CircadianLighting(hass, min_colortemp, max_colortemp,
  File "/config/custom_components/circadian_lighting/__init__.py", line 139, in __init__
    self.data['percent'] = self.calc_percent()
  File "/config/custom_components/circadian_lighting/__init__.py", line 210, in calc_percent
    today_sun_times = self.get_sunrise_sunset(now)
  File "/config/custom_components/circadian_lighting/__init__.py", line 174, in get_sunrise_sunset
    location = astral.Location()
AttributeError: module 'astral' has no attribute 'Location'

Traceback (most recent call last):

File "/usr/src/homeassistant/homeassistant/setup.py", line 248, in _async_setup_component
result = await task
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/circadian_lighting/__init__.py", line 109, in setup
cl = CircadianLighting(hass, min_colortemp, max_colortemp,
File "/config/custom_components/circadian_lighting/__init__.py", line 139, in __init__
self.data['percent'] = self.calc_percent()
File "/config/custom_components/circadian_lighting/__init__.py", line 210, in calc_percent
today_sun_times = self.get_sunrise_sunset(now)
File "/config/custom_components/circadian_lighting/__init__.py", line 174, in get_sunrise_sunset
location = astral.Location()
AttributeError: module 'astral' has no attribute 'Location'

And concerning the version number: (that's easy to fix) ;-)

2021-05-05 23:56:20 ERROR (MainThread) [homeassistant.loader] No 'version' key in the manifest file for custom integration 'circadian_lighting'. As of Home Assistant 2021.6, this integration will no longer be loaded. Please report this to the maintainer of 'circadian_lighting'
aksyonov commented 3 years ago

I found a temporary solution until the issue with astral is fixed. Just need to add the next lines into circadian_lighting config:

  sunrise_time: '06:00:00'
  sunset_time: '20:00:00'

(change the time to average sunrise and sunset time in your area)

filmgarage commented 3 years ago

Thanks @aksyonov that works for now!

dartfrogdk commented 3 years ago

not a solution for countries in the north regions, light changes so fast most of the time, light extending 15-30 minutes pr day now

sevorl commented 3 years ago

I tried this, but unfortunately it seems configuration.yaml does not support variables here:

sunrise_time: '{{ as_timestamp(strptime(state_attr("sun.sun", "next_dawn"), "")) | timestamp_custom("%H:%M:%S")}}' sunset_time: '{{ as_timestamp(strptime(state_attr("sun.sun", "next_dusk"), "")) | timestamp_custom("%H:%M:%S")}}'

dartfrogdk commented 3 years ago

Best addon and not working 😢

cybershadow1 commented 3 years ago

I tried this, but unfortunately it seems configuration.yaml does not support variables here:

sunrise_time: '{{ as_timestamp(strptime(state_attr("sun.sun", "next_dawn"), "")) | timestamp_custom("%H:%M:%S")}}' sunset_time: '{{ as_timestamp(strptime(state_attr("sun.sun", "next_dusk"), "")) | timestamp_custom("%H:%M:%S")}}'

Yup, got an error as well. I hope we can work this out soon. This integration is a life saver!

basnijholt commented 3 years ago

For the time being you might try out the adaptive-lighting integration (see this PR in core.)

The code also lives here https://github.com/basnijholt/adaptive-lighting (add as custom repo to HACS).

This code is based on this integration and has some extra features.

Kirbo commented 3 years ago

For the time being you might try out the adaptive-lighting integration (see this PR in core.)

The code also lives here https://github.com/basnijholt/adaptive-lighting (add as custom repo to HACS).

This code is based on this integration and has some extra features.

@basnijholt How easy is it to migrate from hass-circadian_lighting into adaptive-lighting, or does it mean I have to configure everything from the scratch?

flecmart commented 3 years ago

@kirbo

Depends on how heavily your configuration relies on certain concepts that differ between the two implementations. I read the documentation of adaptive-lighting and some concepts are different from circadian lighting - e.g. the "talking back control" thingy.

I implemented different automations/scenes/events to implement this feature with circadian lighting in my home assistant config, because this project just offers you the one switch to disable the automation. I think https://github.com/basnijholt/adaptive-lighting has put more effort in those use cases and you can control it better and more differentiated. I guess as adaptive-lighting will probably make it to core is one more reason to switch.

And finally this project seems to be unmaintained at the moment, because the issue is not really addressed. No front to @claytonjn though - we all know real life and work can make maintaining open source projects hard from time to time - so thank you very much for the idea & base implementation ❤️

austwhite commented 3 years ago

I don't think this project has been updated in a very long time. I made the switch to Adaptive lighting, but I only was in trialing stage. The ability for Adaptive Lighting to disable itself based on manual control is helpful. Even if you use a voice assistant to change a light, there is a setting to stop Adaptive Lighting taking over again.

sevorl commented 3 years ago

I will definitely give adaptive-lighting a try. Does anyone have experience using this with Ikea Tradfri bulbs? These have a known issue, that color temp and brightness can not be set in the same call.

sevorl commented 3 years ago

I will definitely give adaptive-lighting a try. Does anyone have experience using this with Ikea Tradfri bulbs? These have a known issue, that color temp and brightness can not be set in the same call.

I figured it out myself: There is an option to control temp and brightness in two steps. Awesome!

masterfish1 commented 3 years ago

I don't think this project has been updated in a very long time.

The dev has a Twitter account (https://twitter.com/claytonjn) which also shows a Facebook account (https://www.facebook.com/claytonjn). I don't have either but perhaps it's worth someone contacting him there directly.

dartfrogdk commented 3 years ago

Just use adaptive - lightning it is working perfectly

RobertDWhite commented 3 years ago

Replace init.py with this fix https://github.com/robertomano24/circadian_lighting/blob/master/custom_components/circadian_lighting/__init__.py until a new version is released.

Xitro01 commented 3 years ago

Replace init.py with this fix https://github.com/robertomano24/circadian_lighting/blob/master/custom_components/circadian_lighting/__init__.py until a new version is released.

Thanks, but how to fix this issue: ModuleNotFoundError: No module named 'timezonefinder'

elahd commented 3 years ago

@robertomano24's solution works for me. Thanks!

@Xitro01: This should have been installed by HACS with the Circadian Lighting add-in. timezonefinder is listed as a dependency in manifest.json. Try this: remove the add-in (through HACS and config.yaml), restart Home Assistant, re-install the add-in (via HACS and config.yaml), replace __init__.py with robertomano24's version, then restart hass again.

cwildfoerster commented 3 years ago

Replace init.py with this fix https://github.com/robertomano24/circadian_lighting/blob/master/custom_components/circadian_lighting/__init__.py until a new version is released.

Thanks, but how to fix this issue: ModuleNotFoundError: No module named 'timezonefinder'

Yes, unfortunaly not working with docker out of the box.

Xitro01 commented 3 years ago

@robertomano24's solution works for me. Thanks!

@Xitro01: This should have been installed by HACS with the Circadian Lighting add-in. timezonefinder is listed as a dependency in manifest.json. Try this: remove the add-in (through HACS and config.yaml), restart Home Assistant, re-install the add-in (via HACS and config.yaml), replace init.py with robertomano24's version, then restart hass again.

Replacing the manifest and restarting hass was enough, thanks!

JaimeZX commented 3 years ago

I found a temporary solution until the issue with astral is fixed. Just need to add the next lines into circadian_lighting config:

  sunrise_time: '06:00:00'
  sunset_time: '20:00:00'

(change the time to average sunrise and sunset time in your area)

Worked for me! Would be great if we can get it working without the hack.

dartfrogdk commented 3 years ago

just use adaptive lightning, much better solution

MTrab commented 3 years ago

Unfortunately, this repo looks like it's dead and abandoned

RobertDWhite commented 3 years ago

Here is a fork that works: https://github.com/robertomano24/circadian_lighting I will do my best to keep this fork updated to work with HA. It should be working now. You will need to add the files to your custom_components folder manually.

If you use Hue and want the Hue scenes you make to update with CL values for a seamless integration, check out my repo here: https://github.com/robertomano24/circadian_lighting-hue

claytonjn commented 3 years ago

Sorry for my absence, I have a new puppy and job that have been keeping me busy!

This has been implemented in version 2.0.4-beta, which also changes the component to be async along with a couple other changes. Please test and let me know if everything is working properly - if so I will push to a general release. Thanks!

techguydave commented 3 years ago

2.0.4-beta worked for me. As soon as HA finished restarting it picked up the lights again. Thanks for your work and congrats on the new puppy and job!

JaimeZX commented 3 years ago

I'm out of town right now but I'll try it when I get home. Thanks!

Jim

Sent from my stupid work iPhone

On May 29, 2021, at 5:19 AM, David Thomas @.***> wrote:

 2.0.4-beta worked for me. As soon as HA finished restarting it picked up the lights again. Thanks for your work and congrats on the new puppy and job!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

davidclemens commented 3 years ago

2.0.4 fixed it for me.

claytonjn commented 3 years ago

Got a handful of people confirming that 2.0.4 is working properly and no complaints about compatibility with HA Core 2015.5.x so I'm going to close this issue. Thanks everyone!

JaimeZX commented 3 years ago

Well... two things:

  1. I'm an idjit and rather than commenting out the configuration.yaml -> circadian_lighting -> sunrisetime (and sunset) lines, I just changed them to a set time per aksyonov's suggestion. Reinstalling circadian_lighting didn't rewrite those lines... not sure what they're supposed to be.
  2. Was I transported into a new time zone? I reinstalled the plugin at about 19:30 and suddenly I have noonish circadian values (97.7% and climbing) and very white bulbs. I've looked all over for a lat/long setting and can't find one... What am I missing?
    Edit: I see in init.py there are references to "hass.config.latitude" (and .longitude, and .elevation) but I don't know where those are defined. My rPi has it's location set correctly in Configuration. Further, my time zone is correct. In configuration.yaml I have
    min_colortemp: 2000  
    max_colortemp: 6000
    sunrise_offset: -05:00:00
    sunset_offset: -00:00:00
    sunrise_time: '05:14:00'
    sunset_time: '19:47:00'

    but you can see in this screenshot that it's clearly not reflecting the correct values. (See the jump at the recent update.) https://i.postimg.cc/0yVKvG8W/2021-06-03-circadian-values.png

claytonjn commented 3 years ago

CL v2 removed the dependency on timezonefinder which depended on numpy and caused a lot of installation issues for people running Home Assistant Core installations. I believe that has caused the sunrise_time and sunset_time to be in UTC now which probably addresses your second comment. As for the first comment; it really depends on what behavior you want - if you want CL to follow the actual sunrise and sunset in your area just remove the sunrise_time and sunset_time lines completely.

JaimeZX commented 3 years ago

Well I was with you all the way until I checked my graph. LOOOL not sure how to account for this! https://i.postimg.cc/FKzrzGdq/2021-06-04-circadian.png

But since it's 9:20PM in London right now, the current value seems accurate. I'll comment out those two lines and we'll see what happens. Thanks!

Edit: commenting out the _time lines, as you suggested, brought it back to a "morning" value for me, see: https://i.postimg.cc/m24Hdc5D/2021-06-04-circadian2.png.

Can't wait to see what the graph looks like when I get home from work later. Thanks!! :)

JaimeZX commented 3 years ago

My numbers were still looking goofy (see graph) so I also commented out the sunrise_offset line and rebooted. We'll see if it returns to normal-ish; the values at least dropped a bit. Has there been a change to the _offset processing as well?

JaimeZX commented 3 years ago

Update. Everything looks good at this point. I tried un-commenting the sunrise_offset: -05:00:00 line in /config/configuration.yaml and the script doesn't load properly anymore. So I guess that's out. Any way to offset the sunrise time earlier then?

michalk-k commented 3 years ago

I'm encountering this issue right now. HAOS 2021.9.7, Circadian Lighting 2.0.4 Restarted the server about 21:30 CET getting the error:

2021-10-13 21:31:48 ERROR (MainThread) [homeassistant.setup] Error during setup of component circadian_lighting
Traceback (most recent call last):
  File "/config/custom_components/circadian_lighting/__init__.py", line 204, in _get_sun_events
    location = astral.location.Location()
AttributeError: module 'astral' has no attribute 'location'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 255, in _async_setup_component
    result = await task
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/circadian_lighting/__init__.py", line 108, in setup
    hass.data[DOMAIN] = CircadianLighting(
  File "/config/custom_components/circadian_lighting/__init__.py", line 157, in __init__
    self._percent = self.calc_percent()
  File "/config/custom_components/circadian_lighting/__init__.py", line 260, in calc_percent
    today = self._relevant_events(now)
  File "/config/custom_components/circadian_lighting/__init__.py", line 251, in _relevant_events
    sun_events = self._get_sun_events(now + timedelta(days=days))
  File "/config/custom_components/circadian_lighting/__init__.py", line 206, in _get_sun_events
    location = astral.Location()
AttributeError: module 'astral' has no attribute 'Location'

But, yesterday, when I was restarting at about 1 at night, it did finish without this error.