From 6a1fea4c25b8ad5f2d77b55ad7bc5f853d95cb0f Mon Sep 17 00:00:00 2001 From: SCA075 <82227818+sca075@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:35:04 +0200 Subject: [PATCH] black and format. coordinator.py shedule_update refactor. Signed-off-by: 82227818+sca075@users.noreply.github.com <82227818+sca075@users.noreply.github.com> --- custom_components/mqtt_vacuum_camera/const.py | 2 +- custom_components/mqtt_vacuum_camera/coordinator.py | 10 ++++++---- .../mqtt_vacuum_camera/valetudo/MQTT/connector.py | 4 +--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/custom_components/mqtt_vacuum_camera/const.py b/custom_components/mqtt_vacuum_camera/const.py index e8e5fad9..0810ba0b 100755 --- a/custom_components/mqtt_vacuum_camera/const.py +++ b/custom_components/mqtt_vacuum_camera/const.py @@ -67,7 +67,7 @@ "last_bin_out": 0, "last_bin_full": 0, "last_loaded_map": "NoMap", - "robot_in_room": "Unsupported" + "robot_in_room": "Unsupported", } DEFAULT_PIXEL_SIZE = 5 diff --git a/custom_components/mqtt_vacuum_camera/coordinator.py b/custom_components/mqtt_vacuum_camera/coordinator.py index 0c74168e..6b7776e4 100644 --- a/custom_components/mqtt_vacuum_camera/coordinator.py +++ b/custom_components/mqtt_vacuum_camera/coordinator.py @@ -11,6 +11,7 @@ import async_timeout from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant +from homeassistant.helpers.event import async_call_later from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed @@ -60,16 +61,17 @@ def schedule_refresh(self) -> None: """Schedule coordinator refresh after 1 second.""" if self.scheduled_refresh: self.scheduled_refresh.cancel() - self.scheduled_refresh = self.hass.loop.call_later( - 1, lambda: asyncio.create_task(self.async_refresh()) + self.scheduled_refresh = async_call_later( + self.hass, 1, lambda: asyncio.create_task(self.async_refresh()) ) async def _async_update_data(self): """ Fetch data from the MQTT topics for sensors. """ - if (self.sensor_data == SENSOR_NO_DATA) or ( - self.shared is not None and self.shared.vacuum_state != "docked" + if ( + (self.sensor_data == SENSOR_NO_DATA) + or (self.shared is not None and self.shared.vacuum_state != "docked") ) and self.connector: try: async with async_timeout.timeout(10): diff --git a/custom_components/mqtt_vacuum_camera/valetudo/MQTT/connector.py b/custom_components/mqtt_vacuum_camera/valetudo/MQTT/connector.py index af1fa493..57fcd9e3 100755 --- a/custom_components/mqtt_vacuum_camera/valetudo/MQTT/connector.py +++ b/custom_components/mqtt_vacuum_camera/valetudo/MQTT/connector.py @@ -1,7 +1,5 @@ """ Version: v2024.11.0 -- Removed the PNG decode, the json is extracted from map-data instead of map-data-hass. -- Refactoring the subscribe method and decode payload method. """ import asyncio @@ -327,7 +325,7 @@ async def rrm_handle_active_segments(self, msg) -> None: self._shared.rand256_active_zone = rrm_active_segments async def async_fire_event_restart_camera( - self, event_text:str="event_vacuum_start", data:str ="" + self, event_text: str = "event_vacuum_start", data: str = "" ): """Fire Event to reset the camera trims""" self._hass.bus.async_fire(