diff --git a/custom_components/mqtt_vacuum_camera/camera.py b/custom_components/mqtt_vacuum_camera/camera.py index eb94d79c..bf7db82f 100755 --- a/custom_components/mqtt_vacuum_camera/camera.py +++ b/custom_components/mqtt_vacuum_camera/camera.py @@ -57,9 +57,9 @@ async def async_setup_entry( - hass: core.HomeAssistant, - config_entry: config_entries.ConfigEntry, - async_add_entities, + hass: core.HomeAssistant, + config_entry: config_entries.ConfigEntry, + async_add_entities, ) -> None: """Setup camera from a config entry created in the integrations UI.""" config = hass.data[DOMAIN][config_entry.entry_id] @@ -145,7 +145,7 @@ def _init_clear_www_folder(self): """Remove PNG and ZIP's stored in HA config WWW""" # If enable_snapshots check if for png in www if not self._shared.enable_snapshots and os.path.isfile( - f"{self._homeassistant_path}/www/snapshot_{self._file_name}.png" + f"{self._homeassistant_path}/www/snapshot_{self._file_name}.png" ): os.remove(f"{self._homeassistant_path}/www/snapshot_{self._file_name}.png") # If there is a log zip in www remove it @@ -203,13 +203,13 @@ def is_streaming(self) -> bool: """Return true if the device is streaming.""" updated_status = self._shared.vacuum_state self._attr_is_streaming = ( - updated_status not in NOT_STREAMING_STATES - or not self._shared.vacuum_bat_charged + updated_status not in NOT_STREAMING_STATES + or not self._shared.vacuum_bat_charged ) return self._attr_is_streaming def camera_image( - self, width: Optional[int] = None, height: Optional[int] = None + self, width: Optional[int] = None, height: Optional[int] = None ) -> Optional[bytes]: """Camera Image""" return self.Image @@ -252,8 +252,8 @@ async def handle_obstacle_view(self, event): return await self.async_update() if ( - self._shared.obstacles_data - and self._shared.camera_mode == CameraModes.MAP_VIEW + self._shared.obstacles_data + and self._shared.camera_mode == CameraModes.MAP_VIEW ): _LOGGER.debug(f"Received event: {event.event_type}, Data: {event.data}") if event.data.get("entity_id") == self.entity_id: @@ -405,8 +405,6 @@ async def download_image(url: str, storage_path: str, filename: str): _LOGGER.error(f"Error downloading image: {e}") return None - - @property def should_poll(self) -> bool: """ON/OFF Camera Polling""" @@ -624,12 +622,12 @@ def _log_memory_usage(self, proc): """Log the memory usage.""" memory_percent = round( ( - (proc.memory_info()[0] / 2.0**30) - / (ProcInsp().psutil.virtual_memory().total / 2.0**30) + (proc.memory_info()[0] / 2.0**30) + / (ProcInsp().psutil.virtual_memory().total / 2.0**30) ) * 100, 2, - ) + ) _LOGGER.debug( f"{self._file_name} Camera Memory usage in GB: " f"{round(proc.memory_info()[0] / 2. ** 30, 2)}, {memory_percent}% of Total." @@ -682,8 +680,8 @@ async def run_async_pil_to_bytes(self, pil_img): pil_img_list = [pil_img for _ in range(num_processes)] loop = get_event_loop() - with (ThreadPoolExecutor( - max_workers=1, thread_name_prefix=f"{self._file_name}_camera") + with ThreadPoolExecutor( + max_workers=1, thread_name_prefix=f"{self._file_name}_camera" ) as executor: tasks = [ loop.run_in_executor( diff --git a/custom_components/mqtt_vacuum_camera/coordinator.py b/custom_components/mqtt_vacuum_camera/coordinator.py index 7fcf6307..9adcb00f 100644 --- a/custom_components/mqtt_vacuum_camera/coordinator.py +++ b/custom_components/mqtt_vacuum_camera/coordinator.py @@ -154,7 +154,7 @@ async def async_update_sensor_data(self, sensor_data): if not vacuum_room: vacuum_room = {"in_room": "Unsupported"} - if last_loaded_map=={}: + if last_loaded_map == {}: last_loaded_map = {"name", "Default"} formatted_data = { diff --git a/custom_components/mqtt_vacuum_camera/valetudo/hypfer/image_draw.py b/custom_components/mqtt_vacuum_camera/valetudo/hypfer/image_draw.py index 50cbabc1..190d1e52 100755 --- a/custom_components/mqtt_vacuum_camera/valetudo/hypfer/image_draw.py +++ b/custom_components/mqtt_vacuum_camera/valetudo/hypfer/image_draw.py @@ -126,7 +126,7 @@ async def async_draw_obstacle( self.img_h.shared.obstacles_data = compose_obstacle_links( self.img_h.shared.vacuum_ips, obstacle_objects ) - elif self.img_h.shared.vacuum_api: # Fall back to API usage if no IP. + elif self.img_h.shared.vacuum_api: # Fall back to API usage if no IP. self.img_h.shared.obstacles_data = compose_obstacle_links( self.img_h.shared.vacuum_api.split("http://")[1], obstacle_objects )