pymammotion 0.4.0b6__py3-none-any.whl → 0.4.0b8__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.
@@ -52,6 +52,7 @@ class StateManager:
52
52
  self._device = device
53
53
 
54
54
  def properties(self, thing_properties: ThingPropertiesMessage) -> None:
55
+ # TODO update device based off thing properties
55
56
  self._device.mqtt_properties = thing_properties
56
57
 
57
58
  def status(self, thing_status: ThingStatusMessage) -> None:
@@ -70,19 +71,19 @@ class StateManager:
70
71
  async def gethash_ack_callback(self, msg: NavGetHashListAck) -> None:
71
72
  if self.cloud_gethash_ack_callback:
72
73
  await self.cloud_gethash_ack_callback(msg)
73
- if self.ble_gethash_ack_callback:
74
+ elif self.ble_gethash_ack_callback:
74
75
  await self.ble_gethash_ack_callback(msg)
75
76
 
76
77
  async def on_notification_callback(self, res: tuple[str, Any | None]) -> None:
77
78
  if self.cloud_on_notification_callback:
78
79
  await self.cloud_on_notification_callback(res)
79
- if self.ble_on_notification_callback:
80
+ elif self.ble_on_notification_callback:
80
81
  await self.ble_on_notification_callback(res)
81
82
 
82
83
  async def get_commondata_ack_callback(self, comm_data: NavGetCommDataAck | SvgMessageAckT) -> None:
83
84
  if self.cloud_get_commondata_ack_callback:
84
85
  await self.cloud_get_commondata_ack_callback(comm_data)
85
- if self.ble_get_commondata_ack_callback:
86
+ elif self.ble_get_commondata_ack_callback:
86
87
  await self.ble_get_commondata_ack_callback(comm_data)
87
88
 
88
89
  async def notification(self, message: LubaMsg) -> None:
@@ -94,7 +95,7 @@ class StateManager:
94
95
  case "nav":
95
96
  await self._update_nav_data(message)
96
97
  case "sys":
97
- await self._update_sys_data(message)
98
+ self._update_sys_data(message)
98
99
  case "driver":
99
100
  self._update_driver_data(message)
100
101
  case "net":
@@ -130,7 +131,7 @@ class StateManager:
130
131
  converted_list = [AreaHashNameList(name=item.name, hash=item.hash) for item in hash_names.hashnames]
131
132
  self._device.map.area_name = converted_list
132
133
 
133
- async def _update_sys_data(self, message) -> None:
134
+ def _update_sys_data(self, message) -> None:
134
135
  """Update system."""
135
136
  sys_msg = betterproto.which_one_of(message.sys, "SubSysMsg")
136
137
  match sys_msg[0]:
@@ -148,8 +149,9 @@ class StateManager:
148
149
  self._device.mower_state.side_led = side_led
149
150
  case "device_product_type_info":
150
151
  device_product_type: DeviceProductTypeInfoT = sys_msg[1]
151
- self._device.mower_state.model_id = device_product_type.main_product_type
152
- self._device.mower_state.sub_model_id = device_product_type.sub_product_type
152
+ if device_product_type.main_product_type != "" or device_product_type.sub_product_type != "":
153
+ self._device.mower_state.model_id = device_product_type.main_product_type
154
+ self._device.mower_state.sub_model_id = device_product_type.sub_product_type
153
155
  case "toapp_dev_fw_info":
154
156
  device_fw_info: DeviceFwInfo = sys_msg[1]
155
157
  self._device.device_firmwares.device_version = device_fw_info.version
@@ -84,9 +84,15 @@ class MammotionMixedDeviceManager:
84
84
  def replace_cloud(self, cloud_device: MammotionBaseCloudDevice) -> None:
85
85
  self._cloud_device = cloud_device
86
86
 
87
+ def remove_cloud(self) -> None:
88
+ del self._cloud_device
89
+
87
90
  def replace_ble(self, ble_device: MammotionBaseBLEDevice) -> None:
88
91
  self._ble_device = ble_device
89
92
 
93
+ def remove_ble(self) -> None:
94
+ del self._ble_device
95
+
90
96
  def replace_mqtt(self, mqtt: MammotionCloud) -> None:
91
97
  device = self._cloud_device.device
92
98
  self._cloud_device = MammotionBaseCloudDevice(mqtt, cloud_device=device, state_manager=self._state_manager)
@@ -347,6 +347,7 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
347
347
 
348
348
  return
349
349
 
350
+ await self._state_manager.notification(new_msg)
350
351
  # may or may not be correct, some work could be done here to correctly match responses
351
352
  if self._notify_future and not self._notify_future.done():
352
353
  self._notify_future.set_result(data)
@@ -355,7 +356,6 @@ class MammotionBaseBLEDevice(MammotionBaseDevice):
355
356
  await self._execute_forced_disconnect()
356
357
 
357
358
  self._reset_disconnect_timer()
358
- await self._state_manager.notification(new_msg)
359
359
 
360
360
  async def _start_notify(self) -> None:
361
361
  """Start notification."""
@@ -184,6 +184,8 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
184
184
  self._mqtt.on_disconnected_event.remove_subscribers(self.on_disconnect)
185
185
  self._mqtt.on_connected_event.remove_subscribers(self.on_connect)
186
186
  self._mqtt.mqtt_message_event.remove_subscribers(self._parse_message_for_device)
187
+ self._state_manager.cloud_gethash_ack_callback = None
188
+ self._state_manager.cloud_get_commondata_ack_callback = None
187
189
  if self._ble_sync_task:
188
190
  self._ble_sync_task.cancel()
189
191
 
@@ -317,6 +319,8 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
317
319
  if new_msg.net.todev_ble_sync != 0 or has_field(new_msg.net.toapp_wifi_iot_status):
318
320
  return
319
321
 
322
+ await self._state_manager.notification(new_msg)
323
+
320
324
  if len(self._mqtt.waiting_queue) > 0:
321
325
  fut: MammotionFuture = self.dequeue_by_iot_id(self._mqtt.waiting_queue, self.iot_id)
322
326
  if fut is None:
@@ -325,7 +329,6 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
325
329
  fut = self.dequeue_by_iot_id(self._mqtt.waiting_queue, self.iot_id)
326
330
  if not fut.fut.cancelled():
327
331
  fut.resolve(cast(bytes, binary_data))
328
- await self._state_manager.notification(new_msg)
329
332
 
330
333
  @property
331
334
  def mqtt(self):
@@ -0,0 +1,5 @@
1
+ """Package for linkkit."""
2
+
3
+ from .linkkit import LinkKit
4
+
5
+ __all__ = ["LinkKit"]