Skip to content

Commit

Permalink
v2.0.0b9
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiğit Topcu committed Nov 22, 2023
1 parent 05d50d8 commit e3c1f0d
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 22 deletions.
8 changes: 4 additions & 4 deletions custom_components/dreame_vacuum/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,18 +562,18 @@ def _handle_coordinator_update(self) -> None:
self._frame_id = None
self._last_updated = None

if self._default_map == True or self._frame_id != map_data.frame_id:
if self._default_map == True or self._frame_id != map_data.frame_id or self._last_updated != map_data.last_updated:
self._frame_id = map_data.frame_id
if (
not self.device.status.active
or self._task_status != self.device.status.task_status
#or self._task_status != self.device.status.task_status
or self._error != self.device.status.error
or self._last_updated is None
):
self.update()
elif (
self._task_status != self.device.status.task_status
or self._error != self.device.status.error
self._error != self.device.status.error
#or self._task_status != self.device.status.task_status
):
self.update()

Expand Down
36 changes: 26 additions & 10 deletions custom_components/dreame_vacuum/dreame/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,14 +645,19 @@ def _map_recovery_status_changed(
) -> None:
if previous_map_recovery_status and self.status.map_recovery_status:
if (
self.status.previous_map_recovery_status
self.status.map_recovery_status
== DreameMapRecoveryStatus.SUCCESS.value
):
if not self._protocol.dreame_cloud:
self._last_map_list_request = 0
self._map_manager.request_next_map()
self._map_manager.request_next_recovery_map_list()
self._request_properties([DreameVacuumProperty.MAP_RECOVERY_STATUS])

if (
self.status.map_recovery_status
!= DreameMapRecoveryStatus.RUNNING.value
):
self._request_properties([DreameVacuumProperty.MAP_RECOVERY_STATUS])

def _map_backup_status_changed(
self, previous_map_backup_status: Any = None
Expand All @@ -662,7 +667,8 @@ def _map_backup_status_changed(
if not self._protocol.dreame_cloud:
self._last_map_list_request = 0
self._map_manager.request_next_recovery_map_list()
self._request_properties([DreameVacuumProperty.MAP_BACKUP_STATUS])
if self.status.map_backup_status != DreameMapBackupStatus.RUNNING.value:
self._request_properties([DreameVacuumProperty.MAP_BACKUP_STATUS])

def _cleaning_mode_changed(self, previous_cleaning_mode: Any = None) -> None:
value = self.get_property(DreameVacuumProperty.CLEANING_MODE)
Expand Down Expand Up @@ -2075,9 +2081,9 @@ def get_map_for_render(self, map_data: MapData) -> MapData | None:
render_map_data.furnitures = {}

if render_map_data.segments:
if (
render_map_data.task_cruise_points
or render_map_data.cleanup_method.value != 2
if render_map_data.task_cruise_points or (
render_map_data.cleanup_method is not None
and render_map_data.cleanup_method.value != 2
):
for k, v in render_map_data.segments.items():
render_map_data.segments[k].order = None
Expand Down Expand Up @@ -2356,9 +2362,6 @@ def update(self, from_action=False) -> None:
if self.capability.backup_map:
properties.append(DreameVacuumProperty.MAP_BACKUP_STATUS)

if self.status.map_recovery_status:
properties.append(DreameVacuumProperty.MAP_RECOVERY_STATUS)

now = time.time()
if self.status.active:
# Only changed when robot is active
Expand Down Expand Up @@ -3154,6 +3157,11 @@ def clean_zone(

self.schedule_update(10, True)
if not isinstance(zones, list):
raise InvalidActionException(
f"Invalid zone coordinates: %s", zones
)

if not isinstance(zones[0], list):
zones = [zones]

if suction_level is None or suction_level == "":
Expand All @@ -3179,6 +3187,11 @@ def clean_zone(
cleanlist = []
index = 0
for zone in zones:
if not isinstance(zone, list) or len(zone) != 4:
raise InvalidActionException(
f"Invalid zone coordinates: %s", zone
)

if isinstance(cleaning_times, list):
if index < len(cleaning_times):
repeat = cleaning_times[index]
Expand Down Expand Up @@ -6343,7 +6356,10 @@ def carpet_avoidance(self) -> bool:
@property
def resume_cleaning(self) -> bool:
"""Returns true when resume_cleaning is enabled."""
return bool(self._get_property(DreameVacuumProperty.RESUME_CLEANING) == (2 if self._capability.smart_charging else 1))
return bool(
self._get_property(DreameVacuumProperty.RESUME_CLEANING)
== (2 if self._capability.smart_charging else 1)
)

@property
def carpet_recognition(self) -> bool:
Expand Down
7 changes: 7 additions & 0 deletions custom_components/dreame_vacuum/dreame/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -8742,6 +8742,13 @@ def render_carpets(
int(math.ceil((carpet.y0 - top) / dimensions.grid_size)),
int(math.ceil((carpet.y2 - top) / dimensions.grid_size)),
):
if (
y < 0
or y >= dimensions.height
or x < 0
or x >= dimensions.width
):
continue
value = int(pixel_type[x, y])
if value > 0 and value != 255:
if value != 254 and carpet.segments:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/dreame_vacuum/dreame/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(
self._session = requests.session()
self._queue = queue.Queue()
self._thread = None
self._id = random.randint(1, 10000)
self._id = random.randint(1, 1000)
self._host = None
self._model = None
self._ti = None
Expand Down
2 changes: 1 addition & 1 deletion custom_components/dreame_vacuum/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
"tzlocal",
"paho-mqtt"
],
"version": "v2.0.0b8"
"version": "v2.0.0b9"
}
10 changes: 5 additions & 5 deletions docs/map.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion install
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if [ -n "$path" ]; then
mkdir "$path/custom_components"
fi
cd "$path/custom_components"
wget "https://github.com/Tasshack/dreame-vacuum/releases/download/v2.0.0b8/dreame_vacuum.zip"
wget "https://github.com/Tasshack/dreame-vacuum/releases/download/v2.0.0b9/dreame_vacuum.zip"
if [ -d "$path/custom_components/dreame_vacuum" ]; then
rm -R "$path/custom_components/dreame_vacuum"
fi
Expand Down

0 comments on commit e3c1f0d

Please sign in to comment.