Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b62ca85
change local _LOGGER to LOGGER and shared.py optimized parsed zone cl…
sca075 Oct 2, 2025
537417c
typing and other parser touches.
sca075 Oct 3, 2025
6dc6b5d
bump mvcrender and change the async to sync usage.
sca075 Oct 3, 2025
d76d7c1
bump mvcrender isort and ruff and replace blending and some drawing f…
sca075 Oct 4, 2025
85f2bdd
Merge branch 'main' into dev
sca075 Oct 4, 2025
3eaa9b9
corrections done
sca075 Oct 5, 2025
14c8b57
Merge remote-tracking branch 'origin/dev' into dev_main
Oct 5, 2025
06508c1
corrections duplicate logger
sca075 Oct 5, 2025
470f31c
removing unused code.
sca075 Oct 7, 2025
e4298db
delete auto_crop.py and color_utils.py as not used anymore
sca075 Oct 7, 2025
b3dd06a
ruff formatted and some mod on drawable.py
sca075 Oct 7, 2025
c9147c7
Merge branch 'main' into dev
sca075 Oct 7, 2025
588b6d8
changes
sca075 Oct 7, 2025
0a29d0c
remove duplicate
sca075 Oct 7, 2025
c88110d
remove potential memory leak from code.
sca075 Oct 8, 2025
c5d704a
drawable.py use now mcvrender for the most.
sca075 Oct 8, 2025
3a5c905
version bump
sca075 Oct 8, 2025
6738b14
test new battery state and add streaming to the data
sca075 Oct 11, 2025
fab2bb6
charging state updated
sca075 Oct 11, 2025
88120ab
added need room_names in RoomStore
sca075 Oct 14, 2025
8f4b91b
Merge branch 'main' into dev
sca075 Oct 14, 2025
8c2ee27
status_text.py refactor removing if elif else for clarity
sca075 Oct 23, 2025
c85b71c
adding const.py and update types.py to separate const and types
sca075 Oct 23, 2025
ae071cc
map_data.py handle the Rand256 crash when no Segments ID are not avai…
sca075 Oct 23, 2025
66bf9ab
status_text.py
sca075 Oct 23, 2025
6ebae7d
const.py
sca075 Oct 23, 2025
3d86aa3
map_data.py
sca075 Oct 23, 2025
4c28fce
pylinted code and ruff fix stability of room data
sca075 Nov 2, 2025
d186556
last files for 12 isort / ruff and lint
sca075 Nov 4, 2025
cca7f99
Merge branch 'main' into dev
sca075 Nov 5, 2025
e850c0b
Merge branch 'main' into dev
sca075 Nov 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions SCR/valetudo_map_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
CONF_OFFSET_TOP,
CONF_SNAPSHOTS_ENABLE,
CONF_TRIMS_SAVE,
CONF_VACUUM_CONFIG_ENTRY_ID,
CONF_VACUUM_CONNECTION_STRING,
CONF_VACUUM_ENTITY_ID,
CONF_VACUUM_IDENTIFIERS,
CONF_VAC_STAT,
CONF_VAC_STAT_FONT,
CONF_VAC_STAT_POS,
CONF_VAC_STAT_SIZE,
CONF_VACUUM_CONFIG_ENTRY_ID,
CONF_VACUUM_CONNECTION_STRING,
CONF_VACUUM_ENTITY_ID,
CONF_VACUUM_IDENTIFIERS,
CONF_ZOOM_LOCK_RATIO,
DECODED_TOPICS,
DEFAULT_IMAGE_SIZE,
Expand Down
2 changes: 1 addition & 1 deletion SCR/valetudo_map_parser/config/async_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def async_resize(
) -> Image.Image:
"""Async image resizing."""
if resample is None:
resample = Image.LANCZOS
resample = Image.Resampling.LANCZOS
return await make_async(image.resize, size, resample)

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions SCR/valetudo_map_parser/config/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
)
from .types import LOGGER, Color


color_transparent = (0, 0, 0, 0)
color_charger = (0, 128, 0, 255)
color_move = (238, 247, 255, 255)
Expand Down
80 changes: 8 additions & 72 deletions SCR/valetudo_map_parser/config/drawable.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import logging
from pathlib import Path
from typing import Tuple, Union
from typing import Union

import numpy as np
from mvcrender.blend import get_blended_color, sample_and_blend_color
Expand Down Expand Up @@ -205,24 +205,6 @@ async def go_to_flag(
layer = Drawable._line(layer, xp1, yp1, xp2, yp2, pole_color, pole_width)
return layer

@staticmethod
def point_inside(x: int, y: int, points: list[Tuple[int, int]]) -> bool:
"""Check if a point (x, y) is inside a polygon defined by a list of points."""
n = len(points)
inside = False
inters_x = 0.0
p1x, p1y = points[0]
for i in range(1, n + 1):
p2x, p2y = points[i % n]
if y > min(p1y, p2y):
if y <= max(p1y, p2y) and x <= max(p1x, p2x):
if p1y != p2y:
inters_x = (y - p1y) * (p2x - p1x) / (p2y - p1y) + p1x
if p1x == p2x or x <= inters_x:
inside = not inside
p1x, p1y = p2x, p2y
return inside

@staticmethod
def _line(
layer: NumpyArray,
Expand Down Expand Up @@ -329,56 +311,6 @@ def _ellipse(
image[y1:y2, x1:x2] = color
return image

@staticmethod
def _polygon_outline(
arr: NumpyArray,
points: list[Tuple[int, int]],
width: int,
outline_color: Color,
fill_color: Color = None,
) -> NumpyArray:
"""
Draw the outline of a polygon on the array using _line, and optionally fill it.
Uses NumPy vectorized operations for improved performance.
"""
# Draw the outline
for i, _ in enumerate(points):
current_point = points[i]
next_point = points[(i + 1) % len(points)]
arr = Drawable._line(
arr,
current_point[0],
current_point[1],
next_point[0],
next_point[1],
outline_color,
width,
)

# Fill the polygon if a fill color is provided
if fill_color is not None:
# Get the bounding box of the polygon
min_x = max(0, min(p[0] for p in points))
max_x = min(arr.shape[1] - 1, max(p[0] for p in points))
min_y = max(0, min(p[1] for p in points))
max_y = min(arr.shape[0] - 1, max(p[1] for p in points))

# Create a mask for the polygon region
mask = np.zeros((max_y - min_y + 1, max_x - min_x + 1), dtype=bool)

# Adjust points to the mask's coordinate system
adjusted_points = [(p[0] - min_x, p[1] - min_y) for p in points]

# Test each point in the grid
for i in range(mask.shape[0]):
for j in range(mask.shape[1]):
mask[i, j] = Drawable.point_inside(j, i, adjusted_points)

# Apply the fill color to the masked region
arr[min_y : max_y + 1, min_x : max_x + 1][mask] = fill_color

return arr

@staticmethod
async def zones(layers: NumpyArray, coordinates, color: Color) -> NumpyArray:
"""
Expand Down Expand Up @@ -420,14 +352,18 @@ async def zones(layers: NumpyArray, coordinates, color: Color) -> NumpyArray:
mask_rgba = np.zeros((box_h, box_w, 4), dtype=np.uint8)

# Convert points to xs, ys arrays (adjusted to local bbox coordinates)
xs = np.array([int(pts[i] - min_x) for i in range(0, len(pts), 2)], dtype=np.int32)
ys = np.array([int(pts[i] - min_y) for i in range(1, len(pts), 2)], dtype=np.int32)
xs = np.array(
[int(pts[i] - min_x) for i in range(0, len(pts), 2)], dtype=np.int32
)
ys = np.array(
[int(pts[i] - min_y) for i in range(1, len(pts), 2)], dtype=np.int32
)

# Draw filled polygon on mask
polygon_u8(mask_rgba, xs, ys, (0, 0, 0, 0), 0, (255, 255, 255, 255))

# Extract boolean mask from first channel
zone_mask = (mask_rgba[:, :, 0] > 0)
zone_mask = mask_rgba[:, :, 0] > 0
del mask_rgba
del xs
del ys
Expand Down
Loading