Issue #174 - regression following PR#150

This commit is contained in:
Jean-Marc Collin
2023-11-06 16:13:35 +00:00
parent a6a47fde53
commit 95c4aa8ae9
4 changed files with 17 additions and 4 deletions

View File

@@ -42,7 +42,7 @@
// "terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/bin/python3",
"python.analysis.autoSearchPaths": true,
"pylint.lintOnChange": true,
"pylint.lintOnChange": false,
"python.formatting.provider": "black",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"editor.formatOnPaste": false,

View File

@@ -3,7 +3,7 @@
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
},
"pylint.lintOnChange": true,
"pylint.lintOnChange": false,
"files.associations": {
"*.yaml": "home-assistant"
},

View File

@@ -1827,7 +1827,15 @@ class BaseThermostat(ClimateEntity, RestoreEntity):
self._device_power,
)
ret = (self._current_power + self._device_power) >= self._current_power_max
if self.is_over_climate:
power_consumption_max = self._device_power
else:
power_consumption_max = max(
self._device_power / self.nb_underlying_entities,
self._device_power * self._prop_algorithm.on_percent,
)
ret = (self._current_power + power_consumption_max) >= self._current_power_max
if not self._overpowering_state and ret and self._hvac_mode != HVACMode.OFF:
_LOGGER.warning(
"%s - overpowering is detected. Heater preset will be set to 'power'",
@@ -1845,6 +1853,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity):
"current_power": self._current_power,
"device_power": self._device_power,
"current_power_max": self._current_power_max,
"current_power_consumption": power_consumption_max,
},
)

View File

@@ -4,8 +4,11 @@ from unittest.mock import patch, call
from datetime import datetime, timedelta
import logging
from custom_components.versatile_thermostat.thermostat_switch import ThermostatOverSwitch
from custom_components.versatile_thermostat.thermostat_switch import (
ThermostatOverSwitch,
)
from .commons import * # pylint: disable=wildcard-import, unused-wildcard-import
logging.getLogger().setLevel(logging.DEBUG)
@@ -185,6 +188,7 @@ async def test_power_management_hvac_on(hass: HomeAssistant, skip_hass_states_is
"current_power": 50,
"device_power": 100,
"current_power_max": 149,
"current_power_consumption": 100.0,
},
),
],