rename to adapt_brightness, adapt_color_temp, and adapt_rgb_color

This commit is contained in:
Bas Nijholt 2020-09-29 23:08:09 +02:00
commit 53bf68748a
4 changed files with 21 additions and 34 deletions

View file

@ -12,18 +12,9 @@ SUN_EVENT_MIDNIGHT = "solar_midnight"
CONF_NAME, DEFAULT_NAME = "name", "default"
CONF_LIGHTS, DEFAULT_LIGHTS = "lights", []
CONF_DISABLE_BRIGHTNESS_ADJUST, DEFAULT_DISABLE_BRIGHTNESS_ADJUST = (
"disable_brightness_adjust",
False,
)
CONF_DISABLE_COLOR_TEMP_ADJUST, DEFAULT_DISABLE_COLOR_TEMP_ADJUST = (
"disable_color_temp_adjust",
False,
)
CONF_DISABLE_RGB_COLOR_ADJUST, DEFAULT_DISABLE_RGB_COLOR_ADJUST = (
"disable_rgb_color_adjust",
False,
)
CONF_ADJUST_BRIGHTNESS, DEFAULT_ADJUST_BRIGHTNESS = "adjust_brightness", True
CONF_ADJUST_COLOR_TEMP, DEFAULT_ADJUST_COLOR_TEMP = "adjust_color_temp", True
CONF_ADJUST_RGB_COLOR, DEFAULT_ADJUST_RGB_COLOR = "adjust_rgb_color", True
CONF_DISABLE_ENTITY = "disable_entity"
CONF_DISABLE_STATE = "disable_state"
CONF_INITIAL_TRANSITION, DEFAULT_INITIAL_TRANSITION = "initial_transition", 1
@ -62,10 +53,10 @@ def int_between(min_int, max_int):
VALIDATION_TUPLES = [
(CONF_LIGHTS, DEFAULT_LIGHTS, cv.entity_ids),
(CONF_DISABLE_BRIGHTNESS_ADJUST, DEFAULT_DISABLE_BRIGHTNESS_ADJUST, bool),
(CONF_DISABLE_COLOR_TEMP_ADJUST, DEFAULT_DISABLE_COLOR_TEMP_ADJUST, bool),
(CONF_ADJUST_BRIGHTNESS, DEFAULT_ADJUST_BRIGHTNESS, bool),
(CONF_ADJUST_COLOR_TEMP, DEFAULT_ADJUST_COLOR_TEMP, bool),
(CONF_ADJUST_RGB_COLOR, DEFAULT_ADJUST_RGB_COLOR, bool),
(CONF_DISABLE_ENTITY, NONE_STR, cv.entity_id),
(CONF_DISABLE_RGB_COLOR_ADJUST, DEFAULT_DISABLE_RGB_COLOR_ADJUST, bool),
(CONF_DISABLE_STATE, NONE_STR, str),
(CONF_INITIAL_TRANSITION, DEFAULT_INITIAL_TRANSITION, VALID_TRANSITION),
(CONF_INTERVAL, DEFAULT_INTERVAL, cv.positive_int),

View file

@ -21,10 +21,10 @@
"description": "All settings for a Adaptive Lighting component. The option names correspond with the YAML settings. No options are shown if you have this entry defined in YAML.",
"data": {
"lights": "lights",
"disable_brightness_adjust": "disable_brightness_adjust",
"disable_color_temp_adjust": "disable_color_temp_adjust",
"adjust_brightness": "adjust_brightness",
"adjust_color_temp": "adjust_color_temp",
"adjust_rgb_color": "adjust_rgb_color",
"disable_entity": "disable_entity",
"disable_rgb_color_adjust": "disable_rgb_color_adjust",
"disable_state": "disable_state",
"initial_transition": "initial_transition, the transition of the lights when turning them on or when 'disable_state' or 'sleep_state' change",
"interval": "interval",

View file

@ -59,11 +59,11 @@ import homeassistant.util.dt as dt_util
from .const import (
ATTR_TURN_ON_OFF_LISTENER,
CONF_ADJUST_BRIGHTNESS,
CONF_ADJUST_COLOR_TEMP,
CONF_ADJUST_RGB_COLOR,
CONF_COLORS_ONLY,
CONF_DISABLE_BRIGHTNESS_ADJUST,
CONF_DISABLE_COLOR_TEMP_ADJUST,
CONF_DISABLE_ENTITY,
CONF_DISABLE_RGB_COLOR_ADJUST,
CONF_DISABLE_STATE,
CONF_INITIAL_TRANSITION,
CONF_INTERVAL,
@ -182,10 +182,10 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
data = validate(config_entry)
self._name = data[CONF_NAME]
self._lights = data[CONF_LIGHTS]
self._disable_brightness_adjust = data[CONF_DISABLE_BRIGHTNESS_ADJUST]
self._disable_color_temp_adjust = data[CONF_DISABLE_COLOR_TEMP_ADJUST]
self._adjust_brightness = data[CONF_ADJUST_BRIGHTNESS]
self._adjust_color_temp = data[CONF_ADJUST_COLOR_TEMP]
self._adjust_rgb_color = data[CONF_ADJUST_RGB_COLOR]
self._disable_entity = data[CONF_DISABLE_ENTITY]
self._disable_rgb_color_adjust = data[CONF_DISABLE_RGB_COLOR_ADJUST]
self._disable_state = data[CONF_DISABLE_STATE]
self._initial_transition = data[CONF_INITIAL_TRANSITION]
self._interval = data[CONF_INTERVAL]
@ -491,23 +491,19 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity):
transition = self._transition
service_data[ATTR_TRANSITION] = transition
if (
"brightness" in features
and not self._disable_brightness_adjust
and not colors_only
):
if "brightness" in features and self._adjust_brightness and not colors_only:
service_data[ATTR_BRIGHTNESS_PCT] = self._brightness
if (
"color_temp" in features
and not self._disable_color_temp_adjust
and self._adjust_color_temp
and not (self._prefer_rgb_color and "color" in features)
):
attributes = self.hass.states.get(light).attributes
min_mireds, max_mireds = attributes["min_mireds"], attributes["max_mireds"]
color_temp_mired = max(min(self._color_temp_mired, max_mireds), min_mireds)
service_data[ATTR_COLOR_TEMP] = color_temp_mired
elif "color" in features and not self._disable_rgb_color_adjust:
elif "color" in features and self._adjust_rgb_color:
service_data[ATTR_RGB_COLOR] = self._rgb_color
_LOGGER.debug(

View file

@ -21,10 +21,10 @@
"description": "All settings for a Adaptive Lighting component. The option names correspond with the YAML settings. No options are shown if you have this entry defined in YAML.",
"data": {
"lights": "lights",
"disable_brightness_adjust": "disable_brightness_adjust",
"disable_color_temp_adjust": "disable_color_temp_adjust",
"adjust_brightness": "adjust_brightness",
"adjust_color_temp": "adjust_color_temp",
"adjust_rgb_color": "adjust_rgb_color",
"disable_entity": "disable_entity",
"disable_rgb_color_adjust": "disable_rgb_color_adjust",
"disable_state": "disable_state",
"initial_transition": "initial_transition, the transition of the lights when turning them on or when 'disable_state' or 'sleep_state' change",
"interval": "interval",