Skip to content

Commit

Permalink
feat: add different brightness ramping mechanisms
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Aug 4, 2023
1 parent 1ef7ed5 commit fb36952
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions custom_components/adaptive_lighting/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,30 @@
" for later real sunsets. 🌇"
)

CONF_BRIGHTNESS_MODE, DEFAULT_BRIGHTNESS_MODE = "brightness_mode", "default"
DOCS[CONF_BRIGHTNESS_MODE] = (
"Brightness mode to use. Possible values are `default`, `linear`, and `tanh` "
"(uses `brightness_ramp_time_before` and `brightness_ramp_time_after`). 📈"
)
CONF_BRIGHTNESS_RAMP_TIME_BEFORE, DEFAULT_BRIGHTNESS_RAMP_TIME_BEFORE = (
"brightness_ramp_time_before",
3600,
)
DOCS[CONF_BRIGHTNESS_RAMP_TIME_BEFORE] = (
"(Ignored if `brightness_mode='default'`) The duration (in seconds) to ramp up/down "
"the brightness before sunrise/sunset. The brightness starts changing at this many seconds "
"before the sunset/sunrise 📈📉"
)
CONF_BRIGHTNESS_RAMP_TIME_AFTER, DEFAULT_BRIGHTNESS_RAMP_TIME_AFTER = (
"brightness_ramp_time_after",
3600,
)
DOCS[CONF_BRIGHTNESS_RAMP_TIME_AFTER] = (
"(Ignored if `brightness_mode='default'`) The duration (in seconds) to ramp up/down "
"the brightness after sunrise/sunset. The brightness starts changing at this many seconds "
"after the sunset/sunrise 📈📉."
)

CONF_TAKE_OVER_CONTROL, DEFAULT_TAKE_OVER_CONTROL = "take_over_control", True
DOCS[CONF_TAKE_OVER_CONTROL] = (
"Disable Adaptive Lighting if another source calls `light.turn_on` while lights "
Expand Down Expand Up @@ -284,6 +308,27 @@ def int_between(min_int, max_int):
(CONF_SUNSET_TIME, NONE_STR, str),
(CONF_MIN_SUNSET_TIME, NONE_STR, str),
(CONF_SUNSET_OFFSET, DEFAULT_SUNSET_OFFSET, int),
(
CONF_BRIGHTNESS_MODE,
DEFAULT_BRIGHTNESS_MODE,
selector.SelectSelector(
selector.SelectSelectorConfig(
options=["default", "linear", "tanh"],
multiple=False,
mode=selector.SelectSelectorMode.DROPDOWN,
),
),
),
(
CONF_BRIGHTNESS_RAMP_TIME_BEFORE,
DEFAULT_BRIGHTNESS_RAMP_TIME_BEFORE,
cv.positive_int,
),
(
CONF_BRIGHTNESS_RAMP_TIME_AFTER,
DEFAULT_BRIGHTNESS_RAMP_TIME_AFTER,
cv.positive_int,
),
(CONF_ONLY_ONCE, DEFAULT_ONLY_ONCE, bool),
(CONF_TAKE_OVER_CONTROL, DEFAULT_TAKE_OVER_CONTROL, bool),
(CONF_DETECT_NON_HA_CHANGES, DEFAULT_DETECT_NON_HA_CHANGES, bool),
Expand Down Expand Up @@ -322,6 +367,8 @@ def timedelta_as_int(value):
CONF_SUNSET_OFFSET: (cv.time_period, timedelta_as_int),
CONF_SUNSET_TIME: (cv.time, str),
CONF_MIN_SUNSET_TIME: (cv.time, str),
CONF_BRIGHTNESS_RAMP_TIME_AFTER: (cv.time_period, timedelta_as_int),
CONF_BRIGHTNESS_RAMP_TIME_BEFORE: (cv.time_period, timedelta_as_int),
}


Expand Down

0 comments on commit fb36952

Please sign in to comment.