Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set custom sunset_time #7

Closed
dsenapati opened this issue Oct 11, 2020 · 4 comments
Closed

Unable to set custom sunset_time #7

dsenapati opened this issue Oct 11, 2020 · 4 comments
Labels

Comments

@dsenapati
Copy link

dsenapati commented Oct 11, 2020

Hi there -- thank you so much for your amazing work on this!

I've been slowly transitioning from CL to your component, but am having tremendous difficulty in setting a custom sunset time (working from home these days, and want to have my lights follow work schedule rather than sun's schedule). As context, I have established two switches (one with a custom sunrise_time and one with a custom sunset_time). I am having no issues with the switch with custom sunrise_time, but anytime I set a sunset time (e.g., 18:00:00 as my custom sunset_time, where my astronomical sunset today is 18:35:00), I get an error and my switch entity becomes disabled.

"The sun events ('sunset', 'solar_noon', 'sunrise', 'solar_midnight') are not in the expected order. The Adaptive Lighting integration will not work! This might happen if your sunrise/sunset offset is too large or your manually set sunrise/sunset time is past/before noon/midnight."

I noticed this behavior in the latest builds, but did not have this behavior in your the first few builds you released.

Logs here:

Error while setting up adaptive_lighting platform for switch Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 201, in _async_setup_platform await asyncio.gather(*pending) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 310, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 481, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 521, in add_to_platform_finish await self.async_added_to_hass() File "/config/custom_components/adaptive_lighting/switch.py", line 457, in async_added_to_hass await self.async_turn_on(adapt_lights=not self._only_once) File "/config/custom_components/adaptive_lighting/switch.py", line 544, in async_turn_on await self._update_attrs_and_maybe_adapt_lights( File "/config/custom_components/adaptive_lighting/switch.py", line 650, in _update_attrs_and_maybe_adapt_lights self._settings = self._sun_light_settings.get_settings( File "/config/custom_components/adaptive_lighting/switch.py", line 927, in get_settings percent = self.calc_percent() File "/config/custom_components/adaptive_lighting/switch.py", line 890, in calc_percent today = self.relevant_events(now) File "/config/custom_components/adaptive_lighting/switch.py", line 878, in relevant_events events = [ File "/config/custom_components/adaptive_lighting/switch.py", line 879, in <listcomp> self.get_sun_events(now + timedelta(days=days)) for days in [-1, 0, 1] File "/config/custom_components/adaptive_lighting/switch.py", line 872, in get_sun_events raise ValueError(msg) ValueError: Loft: The sun events ('sunset', 'solar_noon', 'sunrise', 'solar_midnight') are not in the expected order. The Adaptive Lighting integration will not work! This might happen if your sunrise/sunset offset is too large or your manually set sunrise/sunset time is past/before noon/midnight.

@basnijholt
Copy link
Owner

Did you only set the sunset?

The integration seems to think that this is the order of events: ('sunset', 'solar_noon', 'sunrise', 'solar_midnight'), which is in the wrong order. Did you set a offset?

@basnijholt
Copy link
Owner

@dsenapati and @ctrl50, I found a bug in the time zones while writing tests for Home Assistant 7ce7f4e.

I think if you update this component you should no longer experience the issue.

@dsenapati
Copy link
Author

@basnijholt – just wanted to confirm that updating to the latest component fixed my issue – thank you so much for your diligence on this, and looking forward to Adaptive Lighting getting merged into HA proper!

@basnijholt
Copy link
Owner

Great to hear, happy to know it's appreciated! I'll close this issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants