From ff814e10b5823cb93a5d9811c63822090f8379d5 Mon Sep 17 00:00:00 2001 From: io-debug Date: Thu, 21 Sep 2023 20:02:38 +0200 Subject: [PATCH 1/2] Set "_QUERY_SPARE_CAPACITY_TS=0", if res.status ==200 --- custom_components/senec/pysenec_ha/__init__.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/custom_components/senec/pysenec_ha/__init__.py b/custom_components/senec/pysenec_ha/__init__.py index 6127b7b..c33b0fd 100644 --- a/custom_components/senec/pysenec_ha/__init__.py +++ b/custom_components/senec/pysenec_ha/__init__.py @@ -1532,17 +1532,15 @@ async def update_spare_capacity(self): """This function will set the spare capacity over the web api""" async def set_spare_capacity(self, new_spare_capacity: int): _LOGGER.debug("***** set_spare_capacity(self) ********") - self._QUERY_SPARE_CAPACITY_TS = 0 a_url = f"{self._SENEC_API_SPARE_CAPACITY_BASE_URL}{self._master_plant_number}{self._SENEC_API_SET_SPARE_CAPACITY}{new_spare_capacity}" - # payload = f"reserve-in-percent={new_spare_capacity}" + async with self.websession.post(a_url, ssl=False) as res: try: res.raise_for_status() if res.status == 200: _LOGGER.debug("***** Set Spare Capacity successfully ********") - # res_body = await res.text() - # if res_body == "true": - # await self.update() + # Reset the timer in order that the Spare Capacity is updated immediately after the change + self._QUERY_SPARE_CAPACITY_TS = 0 else: self._isAuthenticated = False await self.authenticate(doUpdate=False, throw401=False) From 250afe5bd0c475c6fbed71b6d702799c7b9f6723 Mon Sep 17 00:00:00 2001 From: io-debug <139538558+io-debug@users.noreply.github.com> Date: Fri, 22 Sep 2023 07:42:04 +0200 Subject: [PATCH 2/2] Update const.py Changes the max. of Spare Capacity from 100 to 50 --- custom_components/senec/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/senec/const.py b/custom_components/senec/const.py index ecc6287..4c72ace 100644 --- a/custom_components/senec/const.py +++ b/custom_components/senec/const.py @@ -88,7 +88,7 @@ class ExtBinarySensorEntityDescription(BinarySensorEntityDescription): name="Spare Capacity", device_class = NumberDeviceClass.BATTERY, mode = NumberMode.SLIDER, - native_max_value = 100, + native_max_value = 50, native_min_value = 0, native_step = 1, native_unit_of_measurement = PERCENTAGE,