valetudo-map-parser 0.1.9a5__py3-none-any.whl → 0.1.9a7__py3-none-any.whl

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.
@@ -7,6 +7,7 @@ import logging
7
7
 
8
8
  import numpy as np
9
9
  from numpy import rot90
10
+ from scipy import ndimage
10
11
 
11
12
  from .types import Color, NumpyArray, TrimCropData, TrimsData
12
13
  from .utils import BaseHandler
@@ -89,7 +90,7 @@ class AutoCrop:
89
90
 
90
91
  async def _async_auto_crop_data(self, tdata: TrimsData): # , tdata=None
91
92
  """Load the auto crop data from the Camera config."""
92
- _LOGGER.debug("Auto Crop data: %s, %s", str(tdata), str(self.auto_crop))
93
+ _LOGGER.debug("Auto Crop init data: %s, %s", str(tdata), str(self.auto_crop))
93
94
  if not self.auto_crop:
94
95
  trims_data = TrimCropData.from_dict(dict(tdata.to_dict())).to_list()
95
96
  (
@@ -139,7 +140,7 @@ class AutoCrop:
139
140
  ) -> tuple[int, int, int, int]:
140
141
  """Crop the image based on the auto crop area using scipy.ndimage for better performance."""
141
142
  # Import scipy.ndimage here to avoid import at module level
142
- from scipy import ndimage
143
+
143
144
 
144
145
  # Create a binary mask where True = non-background pixels
145
146
  # This is much more memory efficient than storing coordinates
@@ -269,7 +270,7 @@ class AutoCrop:
269
270
 
270
271
  # Get the current room name from robot_pos (not robot_in_room)
271
272
  current_room = self.handler.robot_pos.get("in_room") if self.handler.robot_pos else None
272
-
273
+ _LOGGER.info(f"Current room: {current_room}")
273
274
 
274
275
  if not current_room:
275
276
  # For Rand256 handler, try to zoom based on robot position even without room data
@@ -303,12 +304,9 @@ class AutoCrop:
303
304
  self.auto_crop[0] : self.auto_crop[2],
304
305
  ]
305
306
 
306
-
307
-
308
307
  # Calculate bounding box from room outline
309
308
  bounding_box = await self.async_get_room_bounding_box(current_room, rand256)
310
309
 
311
-
312
310
  if not bounding_box:
313
311
  _LOGGER.warning(
314
312
  "%s: Could not calculate bounding box for room '%s'. Using full image.",
@@ -328,9 +326,6 @@ class AutoCrop:
328
326
  trim_right = right + margin_size
329
327
  trim_up = up - margin_size
330
328
  trim_down = down + margin_size
331
-
332
-
333
-
334
329
  # Ensure valid trim values
335
330
  trim_left, trim_right = sorted([trim_left, trim_right])
336
331
  trim_up, trim_down = sorted([trim_up, trim_down])
@@ -473,14 +473,21 @@ class ImageDraw:
473
473
  "angle": angle,
474
474
  "in_room": self.img_h.robot_in_room["room"],
475
475
  }
476
- # Handle active zones
477
- if self.img_h.active_zones and (
478
- self.img_h.robot_in_room["id"]
479
- in range(len(self.img_h.active_zones))
480
- ):
481
- self.img_h.zooming = bool(
482
- self.img_h.active_zones[self.img_h.robot_in_room["id"]]
483
- )
476
+ # Handle active zones - Map segment ID to active_zones position
477
+ if self.img_h.active_zones:
478
+ from .config.types import RoomStore
479
+ segment_id = str(self.img_h.robot_in_room["id"])
480
+ room_store = RoomStore(self.file_name)
481
+ room_keys = list(room_store.get_rooms().keys())
482
+
483
+ if segment_id in room_keys:
484
+ position = room_keys.index(segment_id)
485
+ if position < len(self.img_h.active_zones):
486
+ self.img_h.zooming = bool(self.img_h.active_zones[position])
487
+ else:
488
+ self.img_h.zooming = False
489
+ else:
490
+ self.img_h.zooming = False
484
491
  else:
485
492
  self.img_h.zooming = False
486
493
  return temp
@@ -501,14 +508,21 @@ class ImageDraw:
501
508
  "angle": angle,
502
509
  "in_room": self.img_h.robot_in_room["room"],
503
510
  }
504
- # Handle active zones
505
- if self.img_h.active_zones and (
506
- self.img_h.robot_in_room["id"]
507
- in range(len(self.img_h.active_zones))
508
- ):
509
- self.img_h.zooming = bool(
510
- self.img_h.active_zones[self.img_h.robot_in_room["id"]]
511
- )
511
+ # Handle active zones - Map segment ID to active_zones position
512
+ if self.img_h.active_zones:
513
+ from .config.types import RoomStore
514
+ segment_id = str(self.img_h.robot_in_room["id"])
515
+ room_store = RoomStore(self.file_name)
516
+ room_keys = list(room_store.get_rooms().keys())
517
+
518
+ if segment_id in room_keys:
519
+ position = room_keys.index(segment_id)
520
+ if position < len(self.img_h.active_zones):
521
+ self.img_h.zooming = bool(self.img_h.active_zones[position])
522
+ else:
523
+ self.img_h.zooming = False
524
+ else:
525
+ self.img_h.zooming = False
512
526
  else:
513
527
  self.img_h.zooming = False
514
528
  return temp
@@ -574,14 +588,19 @@ class ImageDraw:
574
588
  "in_room": self.img_h.robot_in_room["room"],
575
589
  }
576
590
 
577
- # Handle active zones - Set zooming based on active zones
591
+ # Handle active zones - Map segment ID to active_zones position
578
592
  if self.img_h.active_zones:
579
- # Convert room ID to integer index
580
- room_id = int(self.img_h.robot_in_room["id"])
581
- if room_id < len(self.img_h.active_zones):
582
- self.img_h.zooming = bool(
583
- self.img_h.active_zones[room_id]
584
- )
593
+ from .config.types import RoomStore
594
+ segment_id = str(self.img_h.robot_in_room["id"])
595
+ room_store = RoomStore(self.file_name)
596
+ room_keys = list(room_store.get_rooms().keys())
597
+
598
+ if segment_id in room_keys:
599
+ position = room_keys.index(segment_id)
600
+ if position < len(self.img_h.active_zones):
601
+ self.img_h.zooming = bool(self.img_h.active_zones[position])
602
+ else:
603
+ self.img_h.zooming = False
585
604
  else:
586
605
  self.img_h.zooming = False
587
606
  else:
@@ -620,14 +639,19 @@ class ImageDraw:
620
639
  "in_room": self.img_h.robot_in_room["room"],
621
640
  }
622
641
 
623
- # Handle active zones - Set zooming based on active zones
642
+ # Handle active zones - Map segment ID to active_zones position
624
643
  if self.img_h.active_zones:
625
- # Convert room ID to integer index
626
- room_id = int(self.img_h.robot_in_room["id"])
627
- if room_id < len(self.img_h.active_zones):
628
- self.img_h.zooming = bool(
629
- self.img_h.active_zones[room_id]
630
- )
644
+ from .config.types import RoomStore
645
+ segment_id = str(self.img_h.robot_in_room["id"])
646
+ room_store = RoomStore(self.file_name)
647
+ room_keys = list(room_store.get_rooms().keys())
648
+
649
+ if segment_id in room_keys:
650
+ position = room_keys.index(segment_id)
651
+ if position < len(self.img_h.active_zones):
652
+ self.img_h.zooming = bool(self.img_h.active_zones[position])
653
+ else:
654
+ self.img_h.zooming = False
631
655
  else:
632
656
  self.img_h.zooming = False
633
657
  else:
@@ -131,6 +131,8 @@ class HypferMapImageHandler(BaseHandler, AutoCrop):
131
131
  # Get the pixels size and layers from the JSON data
132
132
  pixel_size = int(m_json["pixelSize"])
133
133
  layers, active = self.data.find_layers(m_json["layers"], {}, [])
134
+ # Populate active_zones from the JSON data
135
+ self.active_zones = active
134
136
  new_frame_hash = await self.calculate_array_hash(layers, active)
135
137
  if self.frame_number == 0:
136
138
  self.img_hash = new_frame_hash
@@ -2,7 +2,7 @@
2
2
  Image Handler Module for Valetudo Re Vacuums.
3
3
  It returns the PIL PNG image frame relative to the Map Data extrapolated from the vacuum json.
4
4
  It also returns calibration, rooms data to the card and other images information to the camera.
5
- Version: 0.1.9.b42
5
+ Version: 0.1.9.a6
6
6
  """
7
7
 
8
8
  from __future__ import annotations
@@ -97,10 +97,17 @@ class ReImageHandler(BaseHandler, AutoCrop):
97
97
 
98
98
  # Update self.rooms_pos from room_properties for compatibility with other methods
99
99
  self.rooms_pos = []
100
+ room_ids = [] # Collect room IDs for shared.map_rooms
100
101
  for room_id, room_data in room_properties.items():
101
102
  self.rooms_pos.append(
102
103
  {"name": room_data["name"], "outline": room_data["outline"]}
103
104
  )
105
+ # Store the room number (segment ID) for MQTT active zone mapping
106
+ room_ids.append(room_data["number"])
107
+
108
+ # Update shared.map_rooms with the room IDs for MQTT active zone mapping
109
+ self.shared.map_rooms = room_ids
110
+ _LOGGER.debug("Updated shared.map_rooms with room IDs: %s", room_ids)
104
111
 
105
112
  # get the zones and points data
106
113
  zone_properties = await self.async_zone_propriety(zones_data)
@@ -257,10 +264,6 @@ class ReImageHandler(BaseHandler, AutoCrop):
257
264
  and robot_position
258
265
  and destinations # Check if we have destinations data for room extraction
259
266
  ):
260
- _LOGGER.debug(
261
- "%s: Attempting early room extraction for active zone checking",
262
- self.file_name
263
- )
264
267
  # Extract room data early if we have destinations
265
268
  try:
266
269
  temp_room_properties = await self.rooms_handler.async_extract_room_properties(
@@ -286,12 +289,6 @@ class ReImageHandler(BaseHandler, AutoCrop):
286
289
  # Restore original rooms_pos
287
290
  self.rooms_pos = original_rooms_pos
288
291
 
289
- _LOGGER.debug(
290
- "%s: Early robot room detection for zoom: robot in %s, zooming=%s",
291
- self.file_name,
292
- robot_room_result.get("in_room", "unknown"),
293
- self.zooming
294
- )
295
292
  except Exception as e:
296
293
  _LOGGER.debug(
297
294
  "%s: Early room extraction failed: %s, falling back to robot-position zoom",
@@ -360,7 +357,7 @@ class ReImageHandler(BaseHandler, AutoCrop):
360
357
  if robot_position:
361
358
  self.robot_position = robot_position
362
359
 
363
- # Check if zoom should be enabled based on active zones
360
+ # Check if Zoom should be enabled based on active zones
364
361
  if (
365
362
  self.shared.image_auto_zoom
366
363
  and self.shared.vacuum_state == "cleaning"
@@ -586,7 +583,6 @@ class ReImageHandler(BaseHandler, AutoCrop):
586
583
 
587
584
  # Handle active zones - Set zooming based on active zones
588
585
  self.active_zones = self.shared.rand256_active_zone
589
- self.zooming = False
590
586
  if self.active_zones and (
591
587
  self.robot_in_room["id"]
592
588
  in range(len(self.active_zones))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: valetudo-map-parser
3
- Version: 0.1.9a5
3
+ Version: 0.1.9a7
4
4
  Summary: A Python library to parse Valetudo map data returning a PIL Image object.
5
5
  License: Apache-2.0
6
6
  Author: Sandro Cantarella
@@ -1,6 +1,6 @@
1
1
  valetudo_map_parser/__init__.py,sha256=Fz-gtKf_OlZcDQqVfGlBwIWi5DJAiRucMbBMdQ2tX_U,1060
2
2
  valetudo_map_parser/config/__init__.py,sha256=DQ9plV3ZF_K25Dp5ZQHPDoG-40dQoJNdNi-dfNeR3Zc,48
3
- valetudo_map_parser/config/auto_crop.py,sha256=m3D1EtsxiBpp4DUwymLVlLYOEX0-Lk7j8t0rxQNFpjQ,18757
3
+ valetudo_map_parser/config/auto_crop.py,sha256=2-xXVJuDbN8dB8wJq3xidl5vgPU7svT1BAbw5xFntCE,18806
4
4
  valetudo_map_parser/config/color_utils.py,sha256=nXD6WeNmdFdoMxPDW-JFpjnxJSaZR1jX-ouNfrx6zvE,4502
5
5
  valetudo_map_parser/config/colors.py,sha256=DG-oPQoN5gsnwDbEsuFr8a0hRCxmbFHObWa4_5pr-70,29910
6
6
  valetudo_map_parser/config/drawable.py,sha256=2MeVHXqZuVuJk3eerMJYGwo25rVetHx3xB_vxecEFOQ,34168
@@ -12,16 +12,16 @@ valetudo_map_parser/config/room_outline.py,sha256=D20D-yeyKnlmVbW9lI7bsPtQGn2Xkc
12
12
  valetudo_map_parser/config/shared.py,sha256=Yd0MlAH6DaAfqxrUw1NW2uHxYoLe9IwKxyFowQ6VJWg,12133
13
13
  valetudo_map_parser/config/types.py,sha256=TaRKoo7G7WIUw7ljOz2Vn5oYzKaLyQH-7Eb8ZYql8Ls,17464
14
14
  valetudo_map_parser/config/utils.py,sha256=CFuuiS5IufEu9aeaZwi7xa1jEF1z6yDZB0mcyVX79Xo,29261
15
- valetudo_map_parser/hypfer_draw.py,sha256=L1eM8dDLNsi4SOUt9499v9jLbQa1MwDKPfMYHcUEsXQ,26722
16
- valetudo_map_parser/hypfer_handler.py,sha256=xekDAFZMDBaErDchpGJY3ALIscUNbId9gR5k_vvj9rA,20655
15
+ valetudo_map_parser/hypfer_draw.py,sha256=jqNnL8McwUQoFmFEMpcLOzvwCy1oIdWjZ0Q65WhN_6M,28266
16
+ valetudo_map_parser/hypfer_handler.py,sha256=Wg2X6o8oYdKxN3mvK3ddWV8MyQJipE--aQtroDGvoyg,20757
17
17
  valetudo_map_parser/hypfer_rooms_handler.py,sha256=NkpOA6Gdq-2D3lLAxvtNuuWMvPXHxeMY2TO5RZLSHlU,22652
18
18
  valetudo_map_parser/map_data.py,sha256=3CG3l_fWeEwWCT5j9nfnqPuClU01m7exwuYWV3K9jIk,18618
19
19
  valetudo_map_parser/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
- valetudo_map_parser/rand25_handler.py,sha256=5iiF2J4LDiV4QCC9K7FIb24ezvVecZZ7-mT8KNdSCHM,27079
20
+ valetudo_map_parser/rand25_handler.py,sha256=Pq_9PnrJTKjtX8pTGKQX0EVv-DJT5vcADlB4Lht5-C8,27004
21
21
  valetudo_map_parser/reimg_draw.py,sha256=1q8LkNTPHEA9Tsapc_JnVw51kpPYNhaBU-KmHkefCQY,12507
22
22
  valetudo_map_parser/rooms_handler.py,sha256=YP8OLotBH-RXluv398l7TTT2zIBHJp91b8THWxl3NdI,17794
23
- valetudo_map_parser-0.1.9a5.dist-info/LICENSE,sha256=Lh-qBbuRV0-jiCIBhfV7NgdwFxQFOXH3BKOzK865hRs,10480
24
- valetudo_map_parser-0.1.9a5.dist-info/METADATA,sha256=79_OWGKVat6lwL24wVMN3FnDHPiXqqSpAHp_WKEcfPI,3320
25
- valetudo_map_parser-0.1.9a5.dist-info/NOTICE.txt,sha256=5lTOuWiU9aiEnJ2go8sc7lTJ7ntMBx0g0GFnNrswCY4,2533
26
- valetudo_map_parser-0.1.9a5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
27
- valetudo_map_parser-0.1.9a5.dist-info/RECORD,,
23
+ valetudo_map_parser-0.1.9a7.dist-info/LICENSE,sha256=Lh-qBbuRV0-jiCIBhfV7NgdwFxQFOXH3BKOzK865hRs,10480
24
+ valetudo_map_parser-0.1.9a7.dist-info/METADATA,sha256=M79X6g5ob5jjyP8o7qgaBQVxSaSWhAv1iuxJ9BjfmAc,3320
25
+ valetudo_map_parser-0.1.9a7.dist-info/NOTICE.txt,sha256=5lTOuWiU9aiEnJ2go8sc7lTJ7ntMBx0g0GFnNrswCY4,2533
26
+ valetudo_map_parser-0.1.9a7.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
27
+ valetudo_map_parser-0.1.9a7.dist-info/RECORD,,