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

Add ability to configure scenes for lights #1357

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions custom_components/localtuya/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
CONF_COLOR_TEMP_MAX_KELVIN = "color_temp_max_kelvin"
CONF_COLOR_TEMP_REVERSE = "color_temp_reverse"
CONF_MUSIC_MODE = "music_mode"
CONF_SCENE_VALUES = "scene_values"
CONF_SCENE_VALUES_FRIENDLY = "scene_values_friendly"

# switch
CONF_CURRENT = "current"
Expand Down
15 changes: 13 additions & 2 deletions custom_components/localtuya/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
CONF_COLOR_TEMP_MAX_KELVIN,
CONF_COLOR_TEMP_MIN_KELVIN,
CONF_COLOR_TEMP_REVERSE,
CONF_SCENE_VALUES,
CONF_SCENE_VALUES_FRIENDLY,
CONF_MUSIC_MODE,
)

Expand Down Expand Up @@ -125,6 +127,8 @@ def flow_schema(dps):
description={"suggested_value": DEFAULT_COLOR_TEMP_REVERSE},
): bool,
vol.Optional(CONF_SCENE): vol.In(dps),
vol.Optional(CONF_SCENE_VALUES): str,
vol.Optional(CONF_SCENE_VALUES_FRIENDLY): str,
vol.Optional(
CONF_MUSIC_MODE, default=False, description={"suggested_value": False}
): bool,
Expand Down Expand Up @@ -167,7 +171,12 @@ def __init__(
self._effect_list = []
self._scenes = None
if self.has_config(CONF_SCENE):
if self._config.get(CONF_SCENE) < 20:
if (self.has_config(CONF_SCENE_VALUES) and
self.has_config(CONF_SCENE_VALUES_FRIENDLY)):
values_list = [value.strip() for value in self._config.get(CONF_SCENE_VALUES).split(";")]
friendly_values_list = [value.strip() for value in self._config.get(CONF_SCENE_VALUES_FRIENDLY).split(";")]
self._scenes = dict(zip(friendly_values_list, values_list))
elif self._config.get(CONF_SCENE) < 20:
self._scenes = SCENE_LIST_RGBW_255
elif self._config.get(CONF_BRIGHTNESS) is None:
self._scenes = SCENE_LIST_RGB_1000
Expand Down Expand Up @@ -241,7 +250,9 @@ def effect(self):
@property
def effect_list(self):
"""Return the list of supported effects for this light."""
return self._effect_list
if len(self._effect_list) > 0:
return self._effect_list
return None

@property
def supported_features(self):
Expand Down
2 changes: 2 additions & 0 deletions custom_components/localtuya/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
"color_temp_max_kelvin": "Maximum Color Temperature in K",
"music_mode": "Music mode available",
"scene": "Scene",
"scene_values": "Scene values, separate entries by a ;",
"scene_values_friendly": "User friendly scene values, separate entries by a ;",
"fan_speed_control": "Fan Speed Control dps",
"fan_oscillating_control": "Fan Oscillating Control dps",
"fan_speed_min": "minimum fan speed integer",
Expand Down
2 changes: 2 additions & 0 deletions custom_components/localtuya/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@
"color_temp_max_kelvin": "Maximum Color Temperature in K",
"music_mode": "Music mode available",
"scene": "Scene",
"scene_values": "Scene values, separate entries by a ;",
"scene_values_friendly": "User friendly scene values, separate entries by a ;",
"select_options": "Valid entries, separate entries by a ;",
"select_options_friendly": "User Friendly options, separate entries by a ;",
"fan_speed_control": "Fan Speed Control dps",
Expand Down
2 changes: 2 additions & 0 deletions custom_components/localtuya/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@
"color_temp_max_kelvin": "Massima temperatura di colore in k",
"music_mode": "Modalità musicale disponibile",
"scene": "Scena",
"scene_values": "Valori di scena, voci separate da una vigola (;)",
"scene_values_friendly": "Valori di scena intuitivi, voci separate da una vigola (;)",
"select_options": "Opzioni valide, voci separate da una vigola (;)",
"select_options_friendly": "Opzioni intuitive, voci separate da una virgola",
"fan_speed_control": "DP di controllo di velocità del ventilatore",
Expand Down
2 changes: 2 additions & 0 deletions custom_components/localtuya/translations/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@
"color_temp_max_kelvin": "Temperatura máxima de cor em K",
"music_mode": "Modo de música disponível",
"scene": "Cena",
"scene_values": "Valores de cena, entradas separadas por um ;",
"scene_values_friendly": "Valores de cena amigáveis ao usuário, entradas separadas por um ;",
"select_options": "Entradas válidas, entradas separadas por um ;",
"select_options_friendly": "Opções fantasia ​​ao usuário, entradas separadas por um ;",
"fan_speed_control": "Dps de controle de velocidade do ventilador",
Expand Down