-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add Conga vacuum support — bump to v0.3.0b2 #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sca075
wants to merge
7
commits into
main
Choose a base branch
from
dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+133
−24
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d6029aa
feat: add Conga vacuum support — bump to v0.3.0b0
sca075 cdfdd59
feat: add Conga vacuum support — bump to v0.3.0b0
sca075 3642f36
Merge remote-tracking branch 'origin/dev' into dev
sca075 608af44
bump version
sca075 119c125
feat: add Conga vacuum support (0.3.0b1)
sca075 1ad1428
bump version
sca075 81286a4
fix: set_content_type round-trip and defensive JSON access in map_data
sca075 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| """ | ||
| Image Draw Class for Conga Vacuums. | ||
| Extends HypferImageDraw to provide a Conga-specific drawing layer. | ||
| Pixel data is already normalised to compressedPixels by the time it reaches | ||
| this class, so all Hypfer drawing routines apply unchanged. | ||
| The canvas is rendered at CONGA_SCALE × the native Conga size so each | ||
| boundary pixel becomes a dense CONGA_SCALE×CONGA_SCALE block, producing | ||
| filled-looking rooms. Entity coordinates are pre-scaled in the handler. | ||
| Version: 0.1.2 | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from .hypfer_draw import ImageDraw as HypferImageDraw | ||
|
|
||
|
|
||
| # Scale factor: Conga pixelSize=1 vs standard pixelSize=5. | ||
| # The handler scales the canvas and all entity coordinates by this factor. | ||
| CONGA_SCALE = 5 | ||
|
|
||
|
|
||
| class CongaImageDraw(HypferImageDraw): | ||
| """Drawing handler for Conga vacuums. | ||
|
|
||
| Inherits all drawing logic from HypferImageDraw unchanged. | ||
| Coordinate scaling is handled entirely in CongaMapImageHandler so | ||
| the draw methods receive already-scaled values. | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| """ | ||
| Conga Image Handler Class. | ||
| Extends HypferMapImageHandler for Conga vacuums. | ||
| Conga maps have pixelSize=1 and canvas size 800×800. Before rendering we | ||
| deep-copy the JSON and multiply pixelSize, canvas size, and all entity | ||
| coordinates by CONGA_SCALE so that every map pixel becomes a CONGA_SCALE×CONGA_SCALE | ||
| block, producing solid filled rooms. Entity positions stay consistent with | ||
| the scaled map coordinate space, so no post-upscale is required. | ||
| Version: 0.1.4 | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import copy | ||
|
|
||
| from PIL import Image | ||
|
|
||
| from .config.shared import CameraShared | ||
| from .config.types import JsonType | ||
| from .conga_draw import CONGA_SCALE, CongaImageDraw | ||
| from .hypfer_handler import HypferMapImageHandler | ||
| from .map_data import HyperMapData | ||
|
|
||
|
|
||
| class CongaMapImageHandler(HypferMapImageHandler): | ||
| """Image Handler for Conga vacuums. | ||
|
|
||
| Scales pixelSize, canvas size, and all entity coordinates by CONGA_SCALE | ||
| before handing the JSON to the standard Hypfer render pipeline. | ||
| """ | ||
|
|
||
| def __init__(self, shared_data: CameraShared) -> None: | ||
| """Initialise the Conga image handler.""" | ||
| super().__init__(shared_data) | ||
| self.imd = CongaImageDraw(self) | ||
|
|
||
| @staticmethod | ||
| def _scale_conga_json(m_json: JsonType, scale: int) -> JsonType: | ||
| """Return a deep copy of m_json with coordinates scaled by *scale*. | ||
|
|
||
| Patches: | ||
| - pixelSize → scale | ||
| - size.x / size.y → original × scale | ||
| - every entity's points list → each value × scale | ||
| """ | ||
| scaled = copy.deepcopy(m_json) | ||
| scaled["pixelSize"] = scale | ||
| size = scaled.get("size", {}) | ||
| scaled["size"] = { | ||
| "x": int(size.get("x", 800)) * scale, | ||
| "y": int(size.get("y", 800)) * scale, | ||
| } | ||
| for entity in scaled.get("entities", []): | ||
| pts = entity.get("points") | ||
| if isinstance(pts, list): | ||
| entity["points"] = [v * scale for v in pts] | ||
| return scaled | ||
|
|
||
| async def async_get_conga_from_json( | ||
| self, m_json: JsonType | None | ||
| ) -> Image.Image | None: | ||
| """Scale Conga JSON to pixel_size=CONGA_SCALE, then render normally.""" | ||
| if m_json is None: | ||
| return None | ||
| scaled_json = self._scale_conga_json(m_json, CONGA_SCALE) | ||
| self.json_data = await HyperMapData.async_from_valetudo_json(scaled_json) | ||
| return await super().async_get_image_from_json(m_json=scaled_json) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: sca075/Python-package-valetudo-map-parser
Length of output: 925
Set
shared_data.is_conga = Truein the Conga handler constructor to keep state synchronized.CameraShared.is_congais initialized toFalseand is never set toTruewhen the Conga handler is active. While the flag is not currently read elsewhere in the codebase, keeping shared state synchronized with the active handler is a valid code hygiene practice.Suggested fix
def __init__(self, shared_data: CameraShared) -> None: """Initialise the Conga image handler.""" super().__init__(shared_data) + self.shared.is_conga = True self.imd = CongaImageDraw(self)🤖 Prompt for AI Agents