claytonjn / hass-circadian_lighting

Circadian Lighting custom component for Home Assistant
Apache License 2.0
774 stars 89 forks source link

Brightness continues to drop long after it's dark #210

Open cssinate opened 1 year ago

cssinate commented 1 year ago

I've just got this up and running for the first time today. Based on my observations and the charts you show in the README, it seems like the Brightness value continues to go down while the sun gets further and further away, even though the apparent darkness of the sky doesn't change noticeably. Here in eastern Canada, it's completely black by 6:30pm. I'd prefer that the light be at its lowest level by the time it's completely dark out, and stay at the lowest until the sky starts to lighten again. Is that possible?

claytonjn commented 1 year ago

it seems like the Brightness value continues to go down while the sun gets further and further away, even though the apparent darkness of the sky doesn't change noticeably

Yes, that is correct

Here in eastern Canada, it's completely black by 6:30pm.

I'm in Michigan and it's completely dark by 5:30pm here 😂

I'd prefer that the light be at its lowest level by the time it's completely dark out, and stay at the lowest until the sky starts to lighten again. Is that possible?

There's currently no way to achieve this behavior with the current code. It is possible from a technical standpoint but my hesitation for adding features like this is that the component already has a lot of configuration options and can be overwhelming and confusing for users to understand, so I worry that adding more options will make it that much worse. It would require two additional configuration options, likely min_brightness_start_time and min_brightness_end_time but I assume you don't want to change those throughout the year which would also require additional settings such as min_brightness_start_sunset_offset and min_brightness_end_sunrise_offset, but even then because of the tilt of the Earth those offset likely wouldn't work throughout the year.

The best solution would be to correlate brightness with the actual solar elevation, but I'm not aware of an API which provides the maximum/minimum elevations and the time those occur on a given day and that information would be necessary for calculations because it changes throughout the year. (As an aside, the "holy grail" for accurate circadian color temperature would be an equation that correlates solar elevation with color temperature, but I have not found enough data to create or borrow one)

The only other solution I can think of would be to add an option like min_brightness_at_night which would change the behavior to dim between sunset and night (The time between astronomical dusk of one day and astronomical dawn of the next) and brighten between night and sunrise. Just doing a quick check, Astral lists night as starting at 5:32p for me tonight which seems accurate for when it starts being darkest, but it lists night as ending at 7:20am and I think 7:10am is likely more accurate - I'd have to do some more experimenting with dusk, blue hour, etc to see what is most accurate.


I'm going to mark this as an enhancement. Can you tell me, what would you like to see in terms of configuration? For your use-case, do you just want the brightness to more accurately follow the sun and change automatically throughout the year, or do you want to be able to set specific times or offsets?

cssinate commented 1 year ago

Thanks for looking into it. I appreciate the time and effort you put into it.

Dec. 10, 2022 10:12:22 a.m. Clayton Nummer @.***>:

it seems like the Brightness value continues to go down while the sun gets further and further away, even though the apparent darkness of the sky doesn't change noticeably

Yes, that is correct

Here in eastern Canada, it's completely black by 6:30pm.

I'm in Michigan and it's completely dark by 5:30pm here 😂

I'd prefer that the light be at its lowest level by the time it's completely dark out, and stay at the lowest until the sky starts to lighten again. Is that possible?

There's currently no way to achieve this behavior with the current code. It /is/ possible from a technical standpoint but my hesitation for adding features like this is that the component already has a lot of configuration options and can be overwhelming and confusing for users to understand, so I worry that adding more options will make it that much worse. It would require two additional configuration options, likely min_brightness_start_time and min_brightness_end_time but I assume you don't want to change those throughout the year which would also require additional settings such as min_brightness_start_sunset_offset and min_brightness_end_sunrise_offset, but even then because of the tilt of the Earth those offset likely wouldn't work throughout the year.

The best solution would be to correlate brightness with the actual solar elevation, but I'm not aware of an API which provides the maximum/minimum elevations and the time those occur on a given day and that information would be necessary for calculations because it changes throughout the year. (As an aside, the "holy grail" for accurate circadian color temperature would be an equation that correlates solar elevation with color temperature, but I have not found enough data to create or borrow one)

The only other solution I can think of would be to add an option like min_brightness_at_night which would change the behavior to dim between sunset and night (The time between astronomical dusk of one day and astronomical dawn of the next[https://astral.readthedocs.io/en/latest/]) and brighten between night and sunrise. Just doing a quick check, Astral lists night as starting at 5:32p for me tonight which seems accurate for when it starts being darkest, but it lists night as ending at 7:20am and I think 7:10am is likely more accurate - I'd have to do some more experimenting with dusk, blue hour, etc to see what is most accurate.


I'm going to mark this as an enhancement. Can you tell me, what would you like to see in terms of configuration? For your use-case, do you just want the brightness to more accurately follow the sun and change automatically throughout the year, or do you want to be able to set specific times or offsets?

— Reply to this email directly, view it on GitHub[https://github.com/claytonjn/hass-circadian_lighting/issues/210#issuecomment-1345284609], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AGAOZVF27X5OXIQ2KJPLERTWMSMVJANCNFSM6AAAAAASZ6N7FA]. You are receiving this because you authored the thread.[Tracking image][https://github.com/notifications/beacon/AGAOZVFGVNGOCKJWETFAR4DWMSMVJA5CNFSM6AAAAAASZ6N7FCWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTSQF5VAC.gif]

claytonjn commented 1 year ago

Here's a dump of all of the relevant times for today (putting this here for my future self when I get time to work on implementing this)

2022-12-10 11:00:49.450 WARNING (MainThread) [custom_components.circadian_lighting] dawn: 2022-12-09 07:19:18.276505-05:00
2022-12-10 11:00:49.452 WARNING (MainThread) [custom_components.circadian_lighting] sunrise: 2022-12-09 07:51:48.397107-05:00
2022-12-10 11:00:49.455 WARNING (MainThread) [custom_components.circadian_lighting] sunset: 2022-12-09 16:59:50.065172-05:00
2022-12-10 11:00:49.456 WARNING (MainThread) [custom_components.circadian_lighting] dusk: 2022-12-09 17:32:19.845430-05:00
2022-12-10 11:00:49.459 WARNING (MainThread) [custom_components.circadian_lighting] night: (datetime.datetime(2022, 12, 9, 17, 32, 19, 845430, tzinfo=<DstTzInfo 'America/Detroit' EST-1 day, 19:00:00 STD>), datetime.datetime(2022, 12, 10, 7, 20, 8, 412206, tzinfo=<DstTzInfo 'America/Detroit' EST-1 day, 19:00:00 STD>))
2022-12-10 11:00:49.460 WARNING (MainThread) [custom_components.circadian_lighting] twilight: (datetime.datetime(2022, 12, 9, 7, 19, 18, 276505, tzinfo=<DstTzInfo 'America/Detroit' EST-1 day, 19:00:00 STD>), datetime.datetime(2022, 12, 9, 7, 51, 48, 397107, tzinfo=<DstTzInfo 'America/Detroit' EST-1 day, 19:00:00 STD>))
2022-12-10 11:00:49.462 WARNING (MainThread) [custom_components.circadian_lighting] golden_hour: (datetime.datetime(2022, 12, 10, 8, 36, 45, 539185, tzinfo=<DstTzInfo 'America/Detroit' EST-1 day, 19:00:00 STD>), datetime.datetime(2022, 12, 10, 7, 32, 8, 335207, tzinfo=<DstTzInfo 'America/Detroit' EST-1 day, 19:00:00 STD>))
2022-12-10 11:00:49.463 WARNING (MainThread) [custom_components.circadian_lighting] blue_hour: (datetime.datetime(2022, 12, 10, 7, 32, 8, 335207, tzinfo=<DstTzInfo 'America/Detroit' EST-1 day, 19:00:00 STD>), datetime.datetime(2022, 12, 10, 7, 20, 8, 412206, tzinfo=<DstTzInfo 'America/Detroit' EST-1 day, 19:00:00 STD>))

Looking at some camera footage, I would say that at the time of this dump it starts getting dark at ~5:15p and is completely dark by ~5:40p, and that it starts getting light at ~6:55a and is completely light by ~7:22a.

I also have a min/max lux sensor which is an average of a bunch of outdoor hue sensors I have around the outside of my house. It looks like they get to the lowest around ~5:20p and remain there until ~7:25p

image

image

So it looks like to simulate actual brightness, the closest would be for lights to dim from sunset to the start of night, then remain at min_brightness until the end of night and then dim up until sunrise.