-
-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add GetMapSetV2
command
#372
Conversation
- in function "GetMapSubSet" add check for compressed values, as newer bot's return value base64 7z compressed - but "GetMapSubSet" will not used for newer bot's now, as the new api will instead used "GetMapSetV2" - update "GetCachedMapInfo" to possible choose between GetMapSet v1 or v2 - add new command "GetMapSetV2" as the old api "GetMapSet" not responses working result for "vw/mw" - TODO: problem on event call for new "GetMapSetV2", on an event it still calls "GetMapSet" instead "GetMapSetV2" - deebot T10 update to use new map version - moved function "decompress_7z_base64_data" into "utils" file - update map coloring as new map use more different type to create a map - add/updates some test cases
Co-authored-by: mvladislav <dev@mvladislav.online>
It seams the map is in general updated with #373 for coloring and also improved for svg. This is my quick example """Main."""
from __future__ import annotations
import asyncio
import logging
from pathlib import Path
import time
from typing import TYPE_CHECKING
import aiohttp
from deebot_client.api_client import ApiClient
from deebot_client.authentication import Authenticator, create_rest_config
from deebot_client.device import Device
from deebot_client.events import CachedMapInfoEvent, MapChangedEvent
from deebot_client.mqtt_client import MqttClient, create_mqtt_config
from deebot_client.util import md5
if TYPE_CHECKING:
from deebot_client.models import DeviceInfo
_LOGGER = logging.getLogger(__name__)
# - getMapSubSet
# - Räumeinfos(Name,typ, ...),
# - virtual walls
# - no mop zones
# - GetMajorMap
# - crc32 für alle chucks
# - GetMinorMap
# - Raumstruktur (Wände, Teppich)
# - geänderten chunks
class Main:
"""Class main."""
device_id = md5(str(time.time()))
account_id = "abc@xy.local"
password_hash = md5("yourPassword")
continent = "eu"
country = "de"
_authenticator = None
_deebot_config = None
_devices: list[DeviceInfo] | None = None
_bot: Device | None = None
def __init__(self) -> None:
logging.basicConfig(level=logging.INFO)
async def _play_ground(self) -> None:
_LOGGER.info(f"==> try get map for bot '{self._bot.device_info.name}'...")
async def on_info(event: CachedMapInfoEvent) -> None:
_LOGGER.info(f"map info :: {event.name}")
async def on_changed(event: MapChangedEvent) -> None:
_LOGGER.info(f"map changed :: {event.when}")
a = self._bot.map.get_svg_map()
self._save_svg_img_to_file(a)
self._bot.events.subscribe(CachedMapInfoEvent, on_info)
self._bot.events.subscribe(MapChangedEvent, on_changed)
def _save_svg_img_to_file(
self, svg_string: str | None, output_filename: str = "image.svg"
) -> None:
if svg_string is not None:
with Path.open(output_filename, "w") as file:
file.write(svg_string)
async def main(self) -> None:
"""Call main function."""
my_session = aiohttp.ClientSession(
connector=aiohttp.TCPConnector(verify_ssl=False)
)
self._devices = await self._retrieve_devices(my_session)
await self._base_connect()
await self._play_ground()
async def _base_connect(self, bot_index: int = 0) -> None:
self._bot = Device(self._devices[bot_index], self._authenticator)
mqtt_config = create_mqtt_config(device_id=self.device_id, country=self.country)
mqtt = MqttClient(mqtt_config, self._authenticator)
await self._bot.initialize(mqtt)
async def _retrieve_devices(
self, my_session: aiohttp.ClientSession
) -> list[DeviceInfo]:
self._deebot_config = create_rest_config(
my_session,
device_id=self.device_id,
alpha_2_country=self.country.upper(),
)
self._authenticator = Authenticator(
self._deebot_config,
self.account_id,
self.password_hash,
)
api_client = ApiClient(self._authenticator)
return await api_client.get_devices()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.create_task(Main().main())
loop.run_forever() |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev #372 +/- ##
==========================================
+ Coverage 82.72% 83.10% +0.37%
==========================================
Files 72 73 +1
Lines 2895 2942 +47
Branches 515 528 +13
==========================================
+ Hits 2395 2445 +50
+ Misses 450 443 -7
- Partials 50 54 +4 ☔ View full report in Codecov by Sentry. |
- with current color set to #f00 background was black, needs to set to full hex name - reduce the alpha channel to be more transparent
- add check if "subsets" is not give to not get an error and possible handle event/atr call - add HandlingResult if it is called by event/atr
I like it, thanks :).
This is because of used color as |
By side i checked how
|
What do you think about, by extending the map with names, or maybe also with ID info? As Example:
|
For the new bots in V2 API the walls are separate drawn, for that the event In the app, the walls can be activated and deactivated, which will looks like:
Not sure if this is really needed, i have local a version which is half ready, but i get some errors which i can currently not fix. If this is something required, i can try to finish it, else i would remove it. It would be looks as follows:
|
- add notify 'MapSetType' into 'GetMapSetV2'
Please don't add it in this PR. We should discuss this first via Discord |
This is how it should be
Please implement By implementing the message |
We should keep this PR as small as possible and not add any more features... These features can be added in follow up PRs |
I will let that changes be backup tracked in issue for titles and walls, if the code will be needed. |
- move main code into message and use message in command - add note for future live map update todo - removed not needed lines - extend and cleanup test cases
- split get and on logic into the correct function-class - comment fix - include removed test_getMapSubSet_customName back
- create function getMapSet v1 and v2 to combine same function and easier handle - let getMapSet v2 call getMapSubSet instead of its own room defintion - getMapSubSet as room boarder defined - update test cases
Is a fix in the works? I'm really regretting buying an Ecovacs and not a Roborock at this point. |
Update map usage for newer bot's.
Updates differences:
GetCachedMapInfo
is usingGetMapSet
to draw "virtual walls" or "no map zones"GetMapSetV2
which can be choose byGetCachedMapInfo
on init by set version =1
or2
pixel_type
which needs to be colored0x04
=> floor which could be related to a room but could not be reached by bot0x05
=> any devices existing in a room like a couch, desk, ...0-5
, is now a room, which could make it possible to color each room in a different color, but is here now color each room into a single colorProblems to be fixed:
GetMapSetV2
GetMapSetV2
is workingGetMapSet
instead the new versionclient.py/tests/commands/json/test_map.py
Line 119 in 9f263b5
Related issue: