valetudo-map-parser 0.1.9a3__tar.gz → 0.1.9a5__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 (27) hide show
  1. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/PKG-INFO +1 -1
  2. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/auto_crop.py +27 -16
  3. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/rand25_handler.py +86 -11
  4. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/pyproject.toml +1 -1
  5. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/LICENSE +0 -0
  6. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/NOTICE.txt +0 -0
  7. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/README.md +0 -0
  8. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/__init__.py +0 -0
  9. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/__init__.py +0 -0
  10. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/color_utils.py +0 -0
  11. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/colors.py +0 -0
  12. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/drawable.py +0 -0
  13. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/drawable_elements.py +0 -0
  14. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/enhanced_drawable.py +0 -0
  15. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/optimized_element_map.py +0 -0
  16. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/rand25_parser.py +0 -0
  17. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/room_outline.py +0 -0
  18. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/shared.py +0 -0
  19. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/types.py +0 -0
  20. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/config/utils.py +0 -0
  21. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/hypfer_draw.py +0 -0
  22. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/hypfer_handler.py +0 -0
  23. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/hypfer_rooms_handler.py +0 -0
  24. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/map_data.py +0 -0
  25. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/py.typed +0 -0
  26. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/reimg_draw.py +0 -0
  27. {valetudo_map_parser-0.1.9a3 → valetudo_map_parser-0.1.9a5}/SCR/valetudo_map_parser/rooms_handler.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: valetudo-map-parser
3
- Version: 0.1.9a3
3
+ Version: 0.1.9a5
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
@@ -186,22 +186,33 @@ class AutoCrop:
186
186
  try:
187
187
  # For Hypfer vacuums, check room_propriety first, then rooms_pos
188
188
  if hasattr(self.handler, 'room_propriety') and self.handler.room_propriety:
189
- for room_id, room_data in self.handler.room_propriety.items():
190
- if room_data.get('name') == room_name:
191
- outline = room_data.get('outline', [])
192
- if outline:
193
- xs, ys = zip(*outline)
194
- left, right = min(xs), max(xs)
195
- up, down = min(ys), max(ys)
196
-
197
- if rand256:
198
- # Apply scaling for rand256 vacuums
199
- left = round(left / 10)
200
- right = round(right / 10)
201
- up = round(up / 10)
202
- down = round(down / 10)
203
-
204
- return left, right, up, down
189
+ # Handle different room_propriety formats
190
+ room_data_dict = None
191
+
192
+ if isinstance(self.handler.room_propriety, dict):
193
+ # Hypfer handler: room_propriety is a dictionary
194
+ room_data_dict = self.handler.room_propriety
195
+ elif isinstance(self.handler.room_propriety, tuple) and len(self.handler.room_propriety) >= 1:
196
+ # Rand256 handler: room_propriety is a tuple (room_properties, zone_properties, point_properties)
197
+ room_data_dict = self.handler.room_propriety[0]
198
+
199
+ if room_data_dict and isinstance(room_data_dict, dict):
200
+ for room_id, room_data in room_data_dict.items():
201
+ if room_data.get('name') == room_name:
202
+ outline = room_data.get('outline', [])
203
+ if outline:
204
+ xs, ys = zip(*outline)
205
+ left, right = min(xs), max(xs)
206
+ up, down = min(ys), max(ys)
207
+
208
+ if rand256:
209
+ # Apply scaling for rand256 vacuums
210
+ left = round(left / 10)
211
+ right = round(right / 10)
212
+ up = round(up / 10)
213
+ down = round(down / 10)
214
+
215
+ return left, right, up, down
205
216
 
206
217
  # Fallback: check rooms_pos (used by both Hypfer and Rand256)
207
218
  if hasattr(self.handler, 'rooms_pos') and self.handler.rooms_pos:
@@ -231,8 +231,8 @@ class ReImageHandler(BaseHandler, AutoCrop):
231
231
  if not self.rooms_pos and not self.room_propriety:
232
232
  self.room_propriety = await self.get_rooms_attributes(destinations)
233
233
 
234
- # Always check robot position for zooming
235
- if self.rooms_pos and robot_position:
234
+ # Always check robot position for zooming (fallback)
235
+ if self.rooms_pos and robot_position and not hasattr(self, 'robot_pos'):
236
236
  self.robot_pos = await self.async_get_robot_in_room(
237
237
  (robot_position[0] * 10),
238
238
  (robot_position[1] * 10),
@@ -248,6 +248,68 @@ class ReImageHandler(BaseHandler, AutoCrop):
248
248
  size_x, size_y, background_color
249
249
  )
250
250
  self.img_base_layer = await self.async_copy_array(img_np_array)
251
+
252
+ # Check active zones BEFORE auto-crop to enable proper zoom functionality
253
+ # This needs to run on every frame, not just frame 0
254
+ if (
255
+ self.shared.image_auto_zoom
256
+ and self.shared.vacuum_state == "cleaning"
257
+ and robot_position
258
+ and destinations # Check if we have destinations data for room extraction
259
+ ):
260
+ _LOGGER.debug(
261
+ "%s: Attempting early room extraction for active zone checking",
262
+ self.file_name
263
+ )
264
+ # Extract room data early if we have destinations
265
+ try:
266
+ temp_room_properties = await self.rooms_handler.async_extract_room_properties(
267
+ m_json, destinations
268
+ )
269
+ if temp_room_properties:
270
+ # Create temporary rooms_pos for robot room detection
271
+ temp_rooms_pos = []
272
+ for room_id, room_data in temp_room_properties.items():
273
+ temp_rooms_pos.append(
274
+ {"name": room_data["name"], "outline": room_data["outline"]}
275
+ )
276
+
277
+ # Store original rooms_pos and temporarily use the new one
278
+ original_rooms_pos = self.rooms_pos
279
+ self.rooms_pos = temp_rooms_pos
280
+
281
+ # Perform robot room detection to check active zones
282
+ robot_room_result = await self.async_get_robot_in_room(
283
+ robot_position[0], robot_position[1], robot_position_angle
284
+ )
285
+
286
+ # Restore original rooms_pos
287
+ self.rooms_pos = original_rooms_pos
288
+
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
+ except Exception as e:
296
+ _LOGGER.debug(
297
+ "%s: Early room extraction failed: %s, falling back to robot-position zoom",
298
+ self.file_name,
299
+ e
300
+ )
301
+ # Fallback to robot-position-based zoom if room extraction fails
302
+ if (
303
+ self.shared.image_auto_zoom
304
+ and self.shared.vacuum_state == "cleaning"
305
+ and robot_position
306
+ ):
307
+ self.zooming = True
308
+ _LOGGER.debug(
309
+ "%s: Enabling fallback robot-position-based zoom",
310
+ self.file_name
311
+ )
312
+
251
313
  return self.img_base_layer, robot_position, robot_position_angle
252
314
 
253
315
  async def _draw_map_elements(
@@ -294,19 +356,32 @@ class ReImageHandler(BaseHandler, AutoCrop):
294
356
  img_np_array, robot_position, robot_position_angle, robot_color
295
357
  )
296
358
 
297
- # Check if zoom should be enabled based on conditions (similar to Hypfer handler)
298
- # For Rand256, robot room detection might happen after image generation
299
- # so we need to check zoom conditions before auto-crop
359
+ # Store robot position for potential zoom function use
360
+ if robot_position:
361
+ self.robot_position = robot_position
362
+
363
+ # Check if zoom should be enabled based on active zones
300
364
  if (
301
365
  self.shared.image_auto_zoom
302
366
  and self.shared.vacuum_state == "cleaning"
303
- and robot_position # Robot position is available
304
- and not self.zooming # Not already enabled
367
+ and robot_position
305
368
  ):
306
- # Enable zooming if all conditions are met
307
- self.zooming = True
308
- # Store robot position for zoom function to use
309
- self.robot_position = robot_position
369
+ # For Rand256, we need to check active zones differently since room data is not available yet
370
+ # Use a simplified approach: enable zoom if any active zones are set
371
+ active_zones = self.shared.rand256_active_zone
372
+ if active_zones and any(zone for zone in active_zones):
373
+ self.zooming = True
374
+ _LOGGER.debug(
375
+ "%s: Enabling zoom for Rand256 - active zones detected: %s",
376
+ self.file_name,
377
+ active_zones
378
+ )
379
+ else:
380
+ self.zooming = False
381
+ _LOGGER.debug(
382
+ "%s: Zoom disabled for Rand256 - no active zones set",
383
+ self.file_name
384
+ )
310
385
 
311
386
  img_np_array = await self.async_auto_trim_and_zoom_image(
312
387
  img_np_array,
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "valetudo-map-parser"
3
- version = "0.1.9a3"
3
+ version = "0.1.9a5"
4
4
  description = "A Python library to parse Valetudo map data returning a PIL Image object."
5
5
  authors = ["Sandro Cantarella <gsca075@gmail.com>"]
6
6
  license = "Apache-2.0"