diff --git a/custom_components/valetudo_vacuum_camera/camera.py b/custom_components/valetudo_vacuum_camera/camera.py index b738e837..3e2a1144 100644 --- a/custom_components/valetudo_vacuum_camera/camera.py +++ b/custom_components/valetudo_vacuum_camera/camera.py @@ -1,5 +1,5 @@ """ -Camera Version v1.5.9-rc2 +Camera Version v1.5.9 Image Processing Threading implemented on Version 1.5.7. """ @@ -280,6 +280,7 @@ def camera_image( @property def supported_features(self) -> int: + """Return supported features.""" return CameraEntityFeature.ON_OFF @property @@ -426,8 +427,14 @@ async def async_update(self): # If we have data from MQTT, we process the image. self._shared.vacuum_battery = await self._mqtt.get_battery_level() - self._shared.vacuum_state = await self._mqtt.get_vacuum_status() self._shared.vacuum_connection = await self._mqtt.get_vacuum_connection_state() + if not self._shared.vacuum_connection: + self._shared.vacuum_state = "disconnected" + else: + if self._shared.vacuum_state == "disconnected": + self._shared.vacuum_state = "idle" + else: + self._shared.vacuum_state = await self._mqtt.get_vacuum_status() pid = os.getpid() # Start to log the CPU usage of this PID. proc = ProcInsp().psutil.Process(pid) # Get the process PID. process_data = await self._mqtt.is_data_available() @@ -443,6 +450,7 @@ async def async_update(self): self._shared.vacuum_state == "cleaning" or self._shared.vacuum_state == "moving" or self._shared.vacuum_state == "returning" + or self._shared.vacuum_state == "disconnected" or not self._shared.vacuum_bat_charged # text update use negative logic ): # grab the image from MQTT. diff --git a/custom_components/valetudo_vacuum_camera/manifest.json b/custom_components/valetudo_vacuum_camera/manifest.json index 30e7f17b..7fcb9880 100644 --- a/custom_components/valetudo_vacuum_camera/manifest.json +++ b/custom_components/valetudo_vacuum_camera/manifest.json @@ -8,5 +8,5 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/sca075/valetudo_vacuum_camera/issues", "requirements": ["pillow", "numpy", "svgwrite"], - "version": "v1.5.9-rc2" + "version": "v1.5.9" } diff --git a/custom_components/valetudo_vacuum_camera/valetudo/hypfer/image_handler.py b/custom_components/valetudo_vacuum_camera/valetudo/hypfer/image_handler.py index 7b7b2f55..2cd058d9 100644 --- a/custom_components/valetudo_vacuum_camera/valetudo/hypfer/image_handler.py +++ b/custom_components/valetudo_vacuum_camera/valetudo/hypfer/image_handler.py @@ -2,7 +2,7 @@ Image Handler Module. It returns the PIL PNG image frame relative to the Map Data extrapolated from the vacuum json. It also returns calibration, rooms data to the card and other images information to the camera. -Last Changed on Version: 1.5.9-rc2 +Last Changed on Version: 1.5.9 """ from __future__ import annotations @@ -13,7 +13,7 @@ import numpy as np import svgwrite -from PIL import Image # , ImageOps +from PIL import Image, ImageOps from psutil_home_assistant import PsutilWrapper as ProcInspector from svgwrite import shapes @@ -635,9 +635,14 @@ async def async_get_image_from_json( self.svg_wait = False del img_np_array # reduce the image size if the zoomed image is bigger then the original. - # if self.shared.image_auto_zoom and self.shared.vacuum_state == "cleaning" and self.zooming: - # return ImageOps.fit(pil_img, (self.shared.image_ref_width, - # self.shared.image_ref_height)) + if ( + self.shared.image_auto_zoom + and self.shared.vacuum_state == "cleaning" + and self.zooming + ): + width = self.shared.image_ref_width + self.shared.margins + height = self.shared.image_ref_height + self.shared.margins + return ImageOps.fit(pil_img, (width, height)) return pil_img except Exception as e: _LOGGER.warning(