valetudo-map-parser 0.1.7__tar.gz → 0.1.9a0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. valetudo_map_parser-0.1.9a0/PKG-INFO +93 -0
  2. valetudo_map_parser-0.1.9a0/README.md +71 -0
  3. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/__init__.py +50 -0
  4. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/config/async_utils.py +93 -0
  5. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/config/auto_crop.py +477 -0
  6. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/config/color_utils.py +105 -0
  7. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/config/colors.py +827 -0
  8. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/config/drawable.py +906 -0
  9. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/config/drawable_elements.py +292 -0
  10. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/config/enhanced_drawable.py +324 -0
  11. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/config/optimized_element_map.py +406 -0
  12. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/config/rand256_parser.py +395 -0
  13. {valetudo_map_parser-0.1.7 → valetudo_map_parser-0.1.9a0}/SCR/valetudo_map_parser/config/shared.py +94 -11
  14. {valetudo_map_parser-0.1.7 → valetudo_map_parser-0.1.9a0}/SCR/valetudo_map_parser/config/types.py +105 -52
  15. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/config/utils.py +1025 -0
  16. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/hypfer_draw.py +738 -0
  17. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/hypfer_handler.py +525 -0
  18. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/hypfer_rooms_handler.py +599 -0
  19. {valetudo_map_parser-0.1.7 → valetudo_map_parser-0.1.9a0}/SCR/valetudo_map_parser/map_data.py +56 -66
  20. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/rand256_handler.py +674 -0
  21. {valetudo_map_parser-0.1.7 → valetudo_map_parser-0.1.9a0}/SCR/valetudo_map_parser/reimg_draw.py +68 -84
  22. valetudo_map_parser-0.1.9a0/SCR/valetudo_map_parser/rooms_handler.py +474 -0
  23. {valetudo_map_parser-0.1.7 → valetudo_map_parser-0.1.9a0}/pyproject.toml +18 -29
  24. valetudo_map_parser-0.1.7/PKG-INFO +0 -23
  25. valetudo_map_parser-0.1.7/README.md +0 -2
  26. valetudo_map_parser-0.1.7/SCR/valetudo_map_parser/__init__.py +0 -35
  27. valetudo_map_parser-0.1.7/SCR/valetudo_map_parser/config/auto_crop.py +0 -288
  28. valetudo_map_parser-0.1.7/SCR/valetudo_map_parser/config/colors.py +0 -178
  29. valetudo_map_parser-0.1.7/SCR/valetudo_map_parser/config/drawable.py +0 -561
  30. valetudo_map_parser-0.1.7/SCR/valetudo_map_parser/config/rand25_parser.py +0 -398
  31. valetudo_map_parser-0.1.7/SCR/valetudo_map_parser/hypfer_draw.py +0 -422
  32. valetudo_map_parser-0.1.7/SCR/valetudo_map_parser/hypfer_handler.py +0 -418
  33. valetudo_map_parser-0.1.7/SCR/valetudo_map_parser/images_utils.py +0 -398
  34. valetudo_map_parser-0.1.7/SCR/valetudo_map_parser/rand25_handler.py +0 -455
  35. {valetudo_map_parser-0.1.7 → valetudo_map_parser-0.1.9a0}/LICENSE +0 -0
  36. {valetudo_map_parser-0.1.7 → valetudo_map_parser-0.1.9a0}/NOTICE.txt +0 -0
  37. {valetudo_map_parser-0.1.7 → valetudo_map_parser-0.1.9a0}/SCR/valetudo_map_parser/config/__init__.py +0 -0
  38. {valetudo_map_parser-0.1.7 → valetudo_map_parser-0.1.9a0}/SCR/valetudo_map_parser/py.typed +0 -0
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.3
2
+ Name: valetudo-map-parser
3
+ Version: 0.1.9a0
4
+ Summary: A Python library to parse Valetudo map data returning a PIL Image object.
5
+ License: Apache-2.0
6
+ Author: Sandro Cantarella
7
+ Author-email: gsca075@gmail.com
8
+ Requires-Python: >=3.12
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Requires-Dist: Pillow (>=10.3.0)
14
+ Requires-Dist: numpy (>=1.26.4)
15
+ Requires-Dist: scipy (>=1.12.0)
16
+ Project-URL: Bug Tracker, https://github.com/sca075/Python-package-valetudo-map-parser/issues
17
+ Project-URL: Changelog, https://github.com/sca075/Python-package-valetudo-map-parser/releases
18
+ Project-URL: Homepage, https://github.com/sca075/Python-package-valetudo-map-parser
19
+ Project-URL: Repository, https://github.com/sca075/Python-package-valetudo-map-parser
20
+ Description-Content-Type: text/markdown
21
+
22
+ # Python-package-valetudo-map-parser
23
+
24
+ ---
25
+ ### What is it:
26
+ ❗This is an _unofficial_ project and is not created, maintained, or in any sense linked to [valetudo.cloud](https://valetudo.cloud)
27
+
28
+ A Python library that converts Valetudo vacuum JSON map data into PIL (Python Imaging Library) images. This package is primarily developed for and used in the [MQTT Vacuum Camera](https://github.com/sca075/mqtt_vacuum_camera) project.
29
+
30
+ ---
31
+
32
+ ### Features:
33
+ - Processes map data from Valetudo-compatible robot vacuums
34
+ - Supports both Hypfer and Rand256 vacuum data formats
35
+ - Renders comprehensive map visualizations including:
36
+ - Walls and obstacles
37
+ - Robot position and cleaning path
38
+ - Room segments and boundaries
39
+ - Cleaning zones
40
+ - Virtual restrictions
41
+ - LiDAR data
42
+ - Provides auto-cropping and dynamic zooming
43
+ - Supports image rotation and aspect ratio management
44
+ - Enables custom color schemes
45
+ - Handles multilingual labels
46
+ - Implements thread-safe data sharing
47
+
48
+ ### Installation:
49
+ ```bash
50
+ pip install valetudo_map_parser
51
+ ```
52
+
53
+ ### Requirements:
54
+ - Python 3.12 or higher
55
+ - Dependencies:
56
+ - Pillow (PIL) for image processing
57
+ - NumPy for array operations
58
+
59
+ ### Usage:
60
+ The library is configured using a dictionary format. See our [sample code](https://github.com/sca075/Python-package-valetudo-map-parser/blob/main/tests/test.py) for implementation examples.
61
+
62
+ Key functionalities:
63
+ - Decodes raw data from Rand256 format
64
+ - Processes JSON data from compatible vacuums
65
+ - Returns Pillow PNG images
66
+ - Provides calibration and room property extraction
67
+ - Supports asynchronous operations
68
+
69
+ ### Development Status:
70
+ Current version: 0.1.9.b41
71
+ - Full functionality available in versions >= 0.1.9
72
+ - Actively maintained and enhanced
73
+ - Uses Poetry for dependency management
74
+ - Implements comprehensive testing
75
+ - Enforces code quality through ruff, isort, and pylint
76
+
77
+ ### Contributing:
78
+ Contributions are welcome! You can help by:
79
+ - Submitting code improvements
80
+ - Enhancing documentation
81
+ - Reporting issues
82
+ - Suggesting new features
83
+
84
+ ### Disclaimer:
85
+ This project is provided "as is" without warranty of any kind. Users assume all risks associated with its use.
86
+
87
+ ### License:
88
+ Apache-2.0
89
+
90
+ ---
91
+ For more information about Valetudo, visit [valetudo.cloud](https://valetudo.cloud)
92
+ Integration with Home Assistant: [MQTT Vacuum Camera](https://github.com/sca075/mqtt_vacuum_camera)
93
+
@@ -0,0 +1,71 @@
1
+ # Python-package-valetudo-map-parser
2
+
3
+ ---
4
+ ### What is it:
5
+ ❗This is an _unofficial_ project and is not created, maintained, or in any sense linked to [valetudo.cloud](https://valetudo.cloud)
6
+
7
+ A Python library that converts Valetudo vacuum JSON map data into PIL (Python Imaging Library) images. This package is primarily developed for and used in the [MQTT Vacuum Camera](https://github.com/sca075/mqtt_vacuum_camera) project.
8
+
9
+ ---
10
+
11
+ ### Features:
12
+ - Processes map data from Valetudo-compatible robot vacuums
13
+ - Supports both Hypfer and Rand256 vacuum data formats
14
+ - Renders comprehensive map visualizations including:
15
+ - Walls and obstacles
16
+ - Robot position and cleaning path
17
+ - Room segments and boundaries
18
+ - Cleaning zones
19
+ - Virtual restrictions
20
+ - LiDAR data
21
+ - Provides auto-cropping and dynamic zooming
22
+ - Supports image rotation and aspect ratio management
23
+ - Enables custom color schemes
24
+ - Handles multilingual labels
25
+ - Implements thread-safe data sharing
26
+
27
+ ### Installation:
28
+ ```bash
29
+ pip install valetudo_map_parser
30
+ ```
31
+
32
+ ### Requirements:
33
+ - Python 3.12 or higher
34
+ - Dependencies:
35
+ - Pillow (PIL) for image processing
36
+ - NumPy for array operations
37
+
38
+ ### Usage:
39
+ The library is configured using a dictionary format. See our [sample code](https://github.com/sca075/Python-package-valetudo-map-parser/blob/main/tests/test.py) for implementation examples.
40
+
41
+ Key functionalities:
42
+ - Decodes raw data from Rand256 format
43
+ - Processes JSON data from compatible vacuums
44
+ - Returns Pillow PNG images
45
+ - Provides calibration and room property extraction
46
+ - Supports asynchronous operations
47
+
48
+ ### Development Status:
49
+ Current version: 0.1.9.b41
50
+ - Full functionality available in versions >= 0.1.9
51
+ - Actively maintained and enhanced
52
+ - Uses Poetry for dependency management
53
+ - Implements comprehensive testing
54
+ - Enforces code quality through ruff, isort, and pylint
55
+
56
+ ### Contributing:
57
+ Contributions are welcome! You can help by:
58
+ - Submitting code improvements
59
+ - Enhancing documentation
60
+ - Reporting issues
61
+ - Suggesting new features
62
+
63
+ ### Disclaimer:
64
+ This project is provided "as is" without warranty of any kind. Users assume all risks associated with its use.
65
+
66
+ ### License:
67
+ Apache-2.0
68
+
69
+ ---
70
+ For more information about Valetudo, visit [valetudo.cloud](https://valetudo.cloud)
71
+ Integration with Home Assistant: [MQTT Vacuum Camera](https://github.com/sca075/mqtt_vacuum_camera)
@@ -0,0 +1,50 @@
1
+ """Valetudo map parser.
2
+ Version: 0.1.9"""
3
+
4
+ from .config.colors import ColorsManagement
5
+ from .config.drawable import Drawable
6
+ from .config.drawable_elements import DrawableElement, DrawingConfig
7
+ from .config.enhanced_drawable import EnhancedDrawable
8
+ from .config.rand256_parser import RRMapParser
9
+ from .config.shared import CameraShared, CameraSharedManager
10
+ from .config.types import (
11
+ CameraModes,
12
+ RoomsProperties,
13
+ RoomStore,
14
+ SnapshotStore,
15
+ TrimCropData,
16
+ UserLanguageStore,
17
+ JsonType,
18
+ PilPNG,
19
+ NumpyArray,
20
+ ImageSize,
21
+ )
22
+ from .hypfer_handler import HypferMapImageHandler
23
+ from .rand256_handler import ReImageHandler
24
+ from .rooms_handler import RoomsHandler, RandRoomsHandler
25
+
26
+
27
+ __all__ = [
28
+ "RoomsHandler",
29
+ "RandRoomsHandler",
30
+ "HypferMapImageHandler",
31
+ "ReImageHandler",
32
+ "RRMapParser",
33
+ "CameraShared",
34
+ "CameraSharedManager",
35
+ "ColorsManagement",
36
+ "Drawable",
37
+ "DrawableElement",
38
+ "DrawingConfig",
39
+ "EnhancedDrawable",
40
+ "SnapshotStore",
41
+ "UserLanguageStore",
42
+ "RoomStore",
43
+ "RoomsProperties",
44
+ "TrimCropData",
45
+ "CameraModes",
46
+ "JsonType",
47
+ "PilPNG",
48
+ "NumpyArray",
49
+ "ImageSize",
50
+ ]
@@ -0,0 +1,93 @@
1
+ """Async utility functions for making NumPy and PIL operations truly async."""
2
+
3
+ import asyncio
4
+ import io
5
+ from typing import Any, Callable
6
+
7
+ import numpy as np
8
+ from numpy import rot90
9
+ from PIL import Image
10
+
11
+
12
+ async def make_async(func: Callable, *args, **kwargs) -> Any:
13
+ """Convert a synchronous function to async by yielding control to the event loop."""
14
+ return await asyncio.to_thread(func, *args, **kwargs)
15
+
16
+
17
+ class AsyncNumPy:
18
+ """Async wrappers for NumPy operations that yield control to the event loop."""
19
+
20
+ @staticmethod
21
+ async def async_copy(array: np.ndarray) -> np.ndarray:
22
+ """Async array copying."""
23
+ return await make_async(np.copy, array)
24
+
25
+ @staticmethod
26
+ async def async_full(
27
+ shape: tuple, fill_value: Any, dtype: np.dtype = None
28
+ ) -> np.ndarray:
29
+ """Async array creation with fill value."""
30
+ return await make_async(np.full, shape, fill_value, dtype=dtype)
31
+
32
+ @staticmethod
33
+ async def async_rot90(array: np.ndarray, k: int = 1) -> np.ndarray:
34
+ """Async array rotation."""
35
+ return await make_async(rot90, array, k)
36
+
37
+
38
+ class AsyncPIL:
39
+ """Async wrappers for PIL operations that yield control to the event loop."""
40
+
41
+ @staticmethod
42
+ async def async_fromarray(array: np.ndarray, mode: str = "RGBA") -> Image.Image:
43
+ """Async PIL Image creation from NumPy array."""
44
+ return await make_async(Image.fromarray, array, mode)
45
+
46
+ @staticmethod
47
+ async def async_resize(
48
+ image: Image.Image, size: tuple, resample: int = None
49
+ ) -> Image.Image:
50
+ """Async image resizing."""
51
+ if resample is None:
52
+ resample = Image.LANCZOS
53
+ return await make_async(image.resize, size, resample)
54
+
55
+ @staticmethod
56
+ async def async_save_to_bytes(
57
+ image: Image.Image, format_type: str = "WEBP", **kwargs
58
+ ) -> bytes:
59
+ """Async image saving to bytes."""
60
+
61
+ def save_to_bytes():
62
+ buffer = io.BytesIO()
63
+ image.save(buffer, format=format_type, **kwargs)
64
+ return buffer.getvalue()
65
+
66
+ return await make_async(save_to_bytes)
67
+
68
+
69
+ class AsyncParallel:
70
+ """Helper functions for parallel processing with asyncio.gather()."""
71
+
72
+ @staticmethod
73
+ async def parallel_data_preparation(*tasks):
74
+ """Execute multiple data preparation tasks in parallel."""
75
+ return await asyncio.gather(*tasks, return_exceptions=True)
76
+
77
+ @staticmethod
78
+ async def parallel_array_operations(base_array: np.ndarray, operations: list):
79
+ """Execute multiple array operations in parallel on copies of the base array."""
80
+
81
+ # Create tasks for parallel execution
82
+ tasks = []
83
+ for operation_func, *args in operations:
84
+ # Each operation works on a copy of the base array
85
+ array_copy = await AsyncNumPy.async_copy(base_array)
86
+ tasks.append(operation_func(array_copy, *args))
87
+
88
+ # Execute all operations in parallel
89
+ results = await asyncio.gather(*tasks, return_exceptions=True)
90
+
91
+ # Filter out exceptions and return successful results
92
+ successful_results = [r for r in results if not isinstance(r, Exception)]
93
+ return successful_results