Skip to content
Merged
10 changes: 7 additions & 3 deletions SCR/valetudo_map_parser/config/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class RoomProperty(TypedDict):
@dataclass
class TrimCropData:
"""Dataclass for trim and crop data."""


floor: str
trim_left: int
trim_up: int
trim_right: int
Expand All @@ -72,6 +73,7 @@ class TrimCropData:
def to_dict(self) -> dict:
"""Convert dataclass to dictionary."""
return {
"floor": self.floor,
"trim_left": self.trim_left,
"trim_up": self.trim_up,
"trim_right": self.trim_right,
Expand All @@ -82,6 +84,7 @@ def to_dict(self) -> dict:
def from_dict(data: dict):
"""Create dataclass from dictionary."""
return TrimCropData(
floor=data["floor"],
trim_left=data["trim_left"],
trim_up=data["trim_up"],
trim_right=data["trim_right"],
Expand All @@ -93,9 +96,10 @@ def to_list(self) -> list:
return [self.trim_left, self.trim_up, self.trim_right, self.trim_down]

@staticmethod
def from_list(data: list):
"""Create dataclass from list."""
def from_list(data: list, floor: Optional[str] = "floor_0"):
"""Create dataclass from list [trim_left, trim_up, trim_right, trim_down]."""
return TrimCropData(
floor=floor,
trim_left=data[0],
trim_up=data[1],
trim_right=data[2],
Expand Down
4 changes: 3 additions & 1 deletion SCR/valetudo_map_parser/config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ def prepare_resize_params(

def update_trims(self) -> None:
"""Update the trims."""
self.shared.trims = TrimsData.from_list(self.crop_area)
self.shared.trims = TrimsData.from_list(
self.crop_area, floor=self.shared.current_floor
)

def get_charger_position(self) -> ChargerPosition | None:
"""Return the charger position."""
Expand Down
2 changes: 1 addition & 1 deletion SCR/valetudo_map_parser/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"vac_status_position": True,
"get_svg_file": False,
"save_trims": True,
"trims_data": {"trim_left": 0, "trim_up": 0, "trim_right": 0, "trim_down": 0},
"trims_data": {"floor": "floor_0", "trim_left": 0, "trim_up": 0, "trim_right": 0, "trim_down": 0},
"enable_www_snapshots": False,
"color_charger": [255, 128, 0],
"color_move": [238, 247, 255],
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "valetudo-map-parser"
version = "0.1.14"
version = "0.1.15"
description = "A Python library to parse Valetudo map data returning a PIL Image object."
authors = ["Sandro Cantarella <gsca075@gmail.com>"]
license = "Apache-2.0"
Expand All @@ -18,7 +18,7 @@ python = ">=3.13"
numpy = ">=1.26.4"
Pillow = ">=10.3.0"
scipy = ">=1.12.0"
mvcrender = "==0.0.6"
mvcrender = "==0.0.7"

[tool.poetry.group.dev.dependencies]
ruff = "*"
Expand Down