From 8ca22faa8c6421627e6888563e91299e0502efb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20Nyi=CC=81ri?= Date: Fri, 21 Oct 2022 11:56:16 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20#224:=20Error=20noiseSensorStarted=20?= =?UTF-8?q?=D0=B0fter=20updating=20to=20the=20version=204.1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/tapo_control/__init__.py | 2 ++ custom_components/tapo_control/binary_sensor.py | 2 -- custom_components/tapo_control/select.py | 17 +++++++++++++++++ custom_components/tapo_control/switch.py | 3 +++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/custom_components/tapo_control/__init__.py b/custom_components/tapo_control/__init__.py index 9cd91d86..909a4390 100644 --- a/custom_components/tapo_control/__init__.py +++ b/custom_components/tapo_control/__init__.py @@ -242,6 +242,7 @@ async def async_update_data(): LOGGER.error(e) hass.data[DOMAIN][entry.entry_id]["camData"] = camData + LOGGER.debug("Updating entities...") for entity in hass.data[DOMAIN][entry.entry_id]["entities"]: if entity._enabled: entity.updateTapo(camData) @@ -284,6 +285,7 @@ async def async_update_data(): "events": False, "eventsListener": False, "entities": [], + "noiseSensorStarted": False, "name": camData["basic_info"]["device_alias"], } diff --git a/custom_components/tapo_control/binary_sensor.py b/custom_components/tapo_control/binary_sensor.py index ccfcdf41..2e472b93 100644 --- a/custom_components/tapo_control/binary_sensor.py +++ b/custom_components/tapo_control/binary_sensor.py @@ -82,8 +82,6 @@ def __init__(self, entry: dict, hass: HomeAssistant, config_entry): self._attr_state = "unavailable" - self._hass.data[DOMAIN][config_entry.entry_id]["noiseSensorStarted"] = False - LOGGER.debug("TapoNoiseBinarySensor - init - end") async def startNoiseDetection(self): diff --git a/custom_components/tapo_control/select.py b/custom_components/tapo_control/select.py index 3d06d88d..7452f375 100644 --- a/custom_components/tapo_control/select.py +++ b/custom_components/tapo_control/select.py @@ -130,6 +130,15 @@ def updateTapo(self, camData): self._attr_state = self._attr_current_option async def async_select_option(self, option: str) -> None: + LOGGER.debug( + "setAlarm(" + + str(option != "off") + + ", " + + str(option == "off" or option in ["both", "sound"]) + + ", " + + str(option == "off" or option in ["both", "light"]) + + ")" + ) await self.hass.async_add_executor_job( self._controller.setAlarm, option != "off", @@ -161,6 +170,7 @@ def updateTapo(self, camData): else: self._attr_current_option = camData["motion_detection_sensitivity"] self._attr_state = self._attr_current_option + LOGGER.debug("Updating TapoMotionDetectionSelect to: " + self._attr_state) async def async_select_option(self, option: str) -> None: await self.hass.async_add_executor_job( @@ -168,6 +178,13 @@ async def async_select_option(self, option: str) -> None: option != "off", option if option != "off" else False, ) + LOGGER.debug( + "setMotionDetection(" + + str(option != "off") + + ", " + + (str(option) if option != "off" else str(False)) + + ")" + ) await self._coordinator.async_request_refresh() diff --git a/custom_components/tapo_control/switch.py b/custom_components/tapo_control/switch.py index 486c78bf..6eb077e0 100644 --- a/custom_components/tapo_control/switch.py +++ b/custom_components/tapo_control/switch.py @@ -105,11 +105,13 @@ async def async_turn_on(self) -> None: await self._hass.async_add_executor_job( self._controller.setPrivacyMode, True, ) + LOGGER.debug("setPrivacyMode(" + str(True) + ")") async def async_turn_off(self) -> None: await self._hass.async_add_executor_job( self._controller.setPrivacyMode, False, ) + LOGGER.debug("setPrivacyMode(" + str(False) + ")") def updateTapo(self, camData): if not camData: @@ -117,6 +119,7 @@ def updateTapo(self, camData): else: self._attr_is_on = camData["privacy_mode"] == "on" self._attr_state = "on" if self._attr_is_on else "off" + LOGGER.debug("Updating TapoPrivacySwitch to: " + self._attr_state) @property def icon(self) -> str: