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

Refactor: entities initialization msg and remove dp_value_conf #49

Merged
merged 4 commits into from
Oct 27, 2023
Merged
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
1 change: 0 additions & 1 deletion custom_components/localtuya/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def __init__(
"""Initialize the Tuya button."""
super().__init__(device, config_entry, buttonid, _LOGGER, **kwargs)
self._state = None
_LOGGER.debug("Initialized button [%s]", self.name)

async def async_press(self):
"""Press the button."""
Expand Down
17 changes: 8 additions & 9 deletions custom_components/localtuya/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ def __init__(
self._has_presets = self.has_config(CONF_ECO_DP) or self.has_config(
CONF_PRESET_DP
)
_LOGGER.debug("Initialized climate [%s]", self.name)

@property
def supported_features(self):
Expand Down Expand Up @@ -375,7 +374,7 @@ async def async_set_preset_mode(self, preset_mode):
def min_temp(self):
"""Return the minimum temperature."""
if _min_temp := self._config.get(CONF_MIN_TEMP_DP):
return self.dp_value_conf(CONF_MIN_TEMP_DP)
return self.dp_value(CONF_MIN_TEMP_DP)
# DEFAULT_MIN_TEMP is in C
if self.temperature_unit == TEMP_FAHRENHEIT:
return DEFAULT_MIN_TEMP * 1.8 + 32
Expand All @@ -386,7 +385,7 @@ def min_temp(self):
def max_temp(self):
"""Return the maximum temperature."""
if self.has_config(CONF_MAX_TEMP_DP):
return self.dp_value_conf(CONF_MAX_TEMP_DP)
return self.dp_value(CONF_MAX_TEMP_DP)
# DEFAULT_MAX_TEMP is in C
if self.temperature_unit == TEMP_FAHRENHEIT:
return DEFAULT_MAX_TEMP * 1.8 + 32
Expand All @@ -399,23 +398,23 @@ def status_updated(self):

if self.has_config(CONF_TARGET_TEMPERATURE_DP):
self._target_temperature = (
self.dp_value_conf(CONF_TARGET_TEMPERATURE_DP) * self._target_precision
self.dp_value(CONF_TARGET_TEMPERATURE_DP) * self._target_precision
)

if self.has_config(CONF_CURRENT_TEMPERATURE_DP):
self._current_temperature = (
self.dp_value_conf(CONF_CURRENT_TEMPERATURE_DP) * self._precision
self.dp_value(CONF_CURRENT_TEMPERATURE_DP) * self._precision
)

if self._has_presets:
if (
self.has_config(CONF_ECO_DP)
and self.dp_value_conf(CONF_ECO_DP) == self._conf_eco_value
and self.dp_value(CONF_ECO_DP) == self._conf_eco_value
):
self._preset_mode = PRESET_ECO
else:
for preset, value in self._conf_preset_set.items(): # todo remove
if self.dp_value_conf(CONF_PRESET_DP) == value:
if self.dp_value(CONF_PRESET_DP) == value:
self._preset_mode = preset
break
else:
Expand All @@ -427,7 +426,7 @@ def status_updated(self):
self._hvac_mode = HVACMode.OFF
else:
for mode, value in self._conf_hvac_mode_set.items():
if self.dp_value_conf(CONF_HVAC_MODE_DP) == value:
if self.dp_value(CONF_HVAC_MODE_DP) == value:
self._hvac_mode = mode
break
else:
Expand All @@ -436,7 +435,7 @@ def status_updated(self):

# Update the current action
for action, value in self._conf_hvac_action_set.items():
if self.dp_value_conf(CONF_HVAC_ACTION_DP) == value:
if self.dp_value(CONF_HVAC_ACTION_DP) == value:
self._hvac_action = action


Expand Down
Loading