Skip to content

Commit

Permalink
camera.py add vacuum state disconnected.
Browse files Browse the repository at this point in the history
image_handler.py ImageOps keep size
manifest.json v1.5.9

Signed-off-by: SCA075 <[email protected]>
Signed-off-by: [email protected] <[email protected]>
  • Loading branch information
sca075 committed Mar 3, 2024
1 parent 6ac28fb commit 1f0ed14
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
12 changes: 10 additions & 2 deletions custom_components/valetudo_vacuum_camera/camera.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Camera Version v1.5.9-rc2
Camera Version v1.5.9
Image Processing Threading implemented on Version 1.5.7.
"""

Expand Down Expand Up @@ -280,6 +280,7 @@ def camera_image(

@property
def supported_features(self) -> int:
"""Return supported features."""
return CameraEntityFeature.ON_OFF

@property
Expand Down Expand Up @@ -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()
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion custom_components/valetudo_vacuum_camera/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 1f0ed14

Please sign in to comment.