Skip to content

Commit 119c125

Browse files
committed
feat: add Conga vacuum support (0.3.0b1)
- Add CongaMapImageHandler subclassing HypferMapImageHandler with JSON coordinate scaling (pixelSize=1 → 5) via async_get_conga_from_json - Add CongaImageDraw subclassing HypferImageDraw as Conga draw engine - Add is_conga: bool = False to CameraShared for vacuum type detection - Route Conga in BaseHandler._generate_new_image via hasattr duck-typing - Remove is_conga_map() from ImageData and detect_vacuum_type() from BaseHandler — detection is mqtt_vacuum_camera's responsibility - Export CongaMapImageHandler and ImageData from public API
1 parent 608af44 commit 119c125

4 files changed

Lines changed: 6 additions & 31 deletions

File tree

SCR/valetudo_map_parser/config/shared.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def __init__(self, file_name):
7171
self.rand256_active_zone: list = []
7272
self.rand256_zone_coordinates: list = []
7373
self.is_rand: bool = False
74+
self.is_conga: bool = False
7475
self._new_mqtt_message = False
7576
self.last_image = Image.new("RGBA", (250, 150), (128, 128, 128, 255))
7677
self.new_image: PilPNG | None = None

SCR/valetudo_map_parser/config/utils.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import numpy as np
1212
from PIL import Image, ImageOps
1313

14-
from ..map_data import HyperMapData, ImageData
14+
from ..map_data import HyperMapData
1515
from .async_utils import AsyncNumPy
1616
from .colors import ColorIndex
1717
from .drawable import Drawable
@@ -80,23 +80,6 @@ def __init__(self):
8080
self.drawing_config: Optional[DrawingConfig] = None
8181
self.draw: Optional[Drawable] = None
8282

83-
@staticmethod
84-
def detect_vacuum_type(json_data: dict) -> str:
85-
"""Detect the vacuum type from the raw JSON map data.
86-
87-
Returns:
88-
'conga' — Conga vacuum (congaPixels present in layers)
89-
'hypfer' — Standard Hypfer/Valetudo vacuum
90-
'rand256' — Rand256 / Valetudo Re vacuum (rrm key present)
91-
"""
92-
if not isinstance(json_data, dict):
93-
return "hypfer"
94-
if "rrm" in json_data or json_data.get("__class") == "RRMap":
95-
return "rand256"
96-
if ImageData.is_conga_map(json_data):
97-
return "conga"
98-
return "hypfer"
99-
10083
def get_frame_number(self) -> int:
10184
"""Return the frame number of the image."""
10285
return self.frame_number
@@ -168,6 +151,9 @@ async def _generate_new_image(
168151
m_json=m_json,
169152
destinations=destinations,
170153
)
154+
155+
if hasattr(self, "async_get_conga_from_json"):
156+
return await self.async_get_conga_from_json(m_json=m_json)
171157

172158
if hasattr(self, "async_get_image_from_json"):
173159
self.json_data = await HyperMapData.async_from_valetudo_json(m_json)

SCR/valetudo_map_parser/conga_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _scale_conga_json(m_json: JsonType, scale: int) -> JsonType:
5656
entity["points"] = [v * scale for v in pts]
5757
return scaled
5858

59-
async def async_get_image_from_json(
59+
async def async_get_conga_from_json(
6060
self, m_json: JsonType | None
6161
) -> Image.Image | None:
6262
"""Scale Conga JSON to pixel_size=CONGA_SCALE, then render normally."""

SCR/valetudo_map_parser/map_data.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,18 +273,6 @@ def _extract_segment_metadata(
273273
if segment_id and material:
274274
materials_dict[segment_id] = material
275275

276-
@staticmethod
277-
def is_conga_map(json_data: Any) -> bool:
278-
"""Detect whether the JSON data originates from a Conga vacuum.
279-
280-
Conga maps are identified by the presence of a 'congaPixels' field
281-
in at least one layer entry.
282-
"""
283-
layers = json_data.get("layers", []) if isinstance(json_data, dict) else []
284-
return any(
285-
"congaPixels" in layer for layer in layers if isinstance(layer, dict)
286-
)
287-
288276
@staticmethod
289277
def _process_map_layer(
290278
json_obj: dict,

0 commit comments

Comments
 (0)