Skip to content

Commit

Permalink
sets hvac_power_level to when off and ensures the values are rounded
Browse files Browse the repository at this point in the history
Fixes #276
  • Loading branch information
= authored and swingerman committed Aug 29, 2024
1 parent ab98aaf commit dfc38a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions custom_components/dual_smart_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,16 @@ def extra_state_attributes(self) -> dict:
_LOGGER.debug(
"Setting HVAC Power Level: %s", self.power_manager.hvac_power_level
)
attributes[ATTR_HVAC_POWER_LEVEL] = self.power_manager.hvac_power_level
attributes[ATTR_HVAC_POWER_PERCENT] = self.power_manager.hvac_power_percent
attributes[ATTR_HVAC_POWER_LEVEL] = (
self.power_manager.hvac_power_level
if self.hvac_device.hvac_mode != HVACMode.OFF
else 0
)
attributes[ATTR_HVAC_POWER_PERCENT] = (
self.power_manager.hvac_power_percent
if self.hvac_device.hvac_mode != HVACMode.OFF
else 0
)

_LOGGER.debug("Extra state attributes: %s", attributes)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _calculate_power_level(self, step_value: float, env_difference: float) -> in
# should increase or decrease the power level based on the difference between the current and target temperature
_LOGGER.debug("Calculating hvac power level")

calculated_power_level = round(env_difference / step_value, 0)
calculated_power_level = round(env_difference / step_value)

return max(
self._hvac_power_min, min(calculated_power_level, self._hvac_power_max)
Expand All @@ -171,7 +171,7 @@ def _calculate_power_percent(
# should increase or decrease the power level based on the difference between the current and target temperature
_LOGGER.debug("Calculating hvac power percent")

calculated_power_percent = round(env_difference / power_tolerance * 100, 0)
calculated_power_percent = round(env_difference / power_tolerance * 100)

return max(
self._hvac_power_min_percent,
Expand Down

0 comments on commit dfc38a7

Please sign in to comment.