From 9abcd98f52fe5b13a8f3e8485903b81e6de7f1af Mon Sep 17 00:00:00 2001 From: adi90x Date: Fri, 3 Nov 2023 23:31:41 +0100 Subject: [PATCH] Mean power Update (#150) * Mean power should not multiply power setup + Documentation * Update test to use device_power --- README-fr.md | 1 + README.md | 2 +- custom_components/versatile_thermostat/base_thermostat.py | 3 +-- tests/test_power.py | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README-fr.md b/README-fr.md index eb1265e..873cf4e 100644 --- a/README-fr.md +++ b/README-fr.md @@ -344,6 +344,7 @@ Cela vous permet de modifier la puissance maximale au fil du temps à l'aide d'u > 2. Je l'utilise pour éviter de dépasser la limite de mon contrat d'électricité lorsqu'un véhicule électrique est en charge. Cela crée une sorte d'autorégulation. > 3. Gardez toujours une marge, car la puissance max peut être brièvement dépassée en attendant le calcul du prochain cycle typiquement ou par des équipements non régulés. > 4. Si vous ne souhaitez pas utiliser cette fonctionnalité, laissez simplement l'identifiant des entités vide +> 5. Si vous controlez plusieurs radiateurs, la **consommation électrique de votre chauffage** renseigné doit correspondre à la somme des puissances. ## Configurer la présence ou l'occupation Si sélectionnée en première page, cette fonction vous permet de modifier dynamiquement la température de tous les préréglages du thermostat configurés lorsque personne n'est à la maison ou lorsque quelqu'un rentre à la maison. Pour cela, vous devez configurer la température qui sera utilisée pour chaque préréglage lorsque la présence est désactivée. Lorsque le capteur de présence s'éteint, ces températures seront utilisées. Lorsqu'il se rallume, la température "normale" configurée pour le préréglage est utilisée. Voir [gestion des préréglages](#configure-the-preset-temperature). diff --git a/README.md b/README.md index 759b0e6..cf431f4 100644 --- a/README.md +++ b/README.md @@ -331,8 +331,8 @@ This allows you to change the max power along time using a Scheduler or whatever > 2. I use this to avoid exceeded the limit of my electrical power contract when an electrical vehicle is charging. This makes a kind of auto-regulation. > 3. Always keep a margin, because max power can be briefly exceeded while waiting for the next cycle calculation typically or by not regulated equipement. > 4. If you don't want to use this feature, just leave the entities id empty +> 5. If you control several heaters, the **power consumption of your heater** setup should be the sum of the power. -## Configure the presence or occupancy If you choose the ```Presence management``` feature, this feature allows you to dynamically changes the temperature of all configured Versatile thermostat's presets when nobody is at home or when someone comes back home. For this, you have to configure the temperature that will be used for each preset when presence is off. When the occupancy sensor turns to off, those tempoeratures will be used. When it turns on again the "normal" temperature configured for the preset is used. See [preset management](#configure-the-preset-temperature). To configure presence fills this form: diff --git a/custom_components/versatile_thermostat/base_thermostat.py b/custom_components/versatile_thermostat/base_thermostat.py index 8fde216..65bda14 100644 --- a/custom_components/versatile_thermostat/base_thermostat.py +++ b/custom_components/versatile_thermostat/base_thermostat.py @@ -934,8 +934,7 @@ class BaseThermostat(ClimateEntity, RestoreEntity): return None return float( - self.nb_underlying_entities - * self._device_power + self._device_power * self._prop_algorithm.on_percent ) diff --git a/tests/test_power.py b/tests/test_power.py index a4a8f2d..ae68b43 100644 --- a/tests/test_power.py +++ b/tests/test_power.py @@ -256,6 +256,7 @@ async def test_power_management_energy_over_switch( CONF_USE_POWER_FEATURE: True, CONF_USE_PRESENCE_FEATURE: False, CONF_HEATER: "switch.mock_switch", + CONF_HEATER_2: "switch.mock_switch2", CONF_PROP_FUNCTION: PROPORTIONAL_FUNCTION_TPI, CONF_TPI_COEF_INT: 0.3, CONF_TPI_COEF_EXT: 0.01, @@ -278,6 +279,7 @@ async def test_power_management_energy_over_switch( assert tpi_algo assert entity.total_energy == 0 + assert entity.nb_underlying_entities == 2 # set temperature to 15 so that on_percent will be set with patch( @@ -297,7 +299,7 @@ async def test_power_management_energy_over_switch( assert entity.current_temperature == 15 assert tpi_algo.on_percent == 1 - assert entity.mean_cycle_power == 100.0 + assert entity.device_power == 100.0 assert mock_send_event.call_count == 2 assert mock_heater_on.call_count == 1