pymammotion 0.5.5__py3-none-any.whl → 0.5.7__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.
Potentially problematic release.
This version of pymammotion might be problematic. Click here for more details.
- pymammotion/data/model/device.py +13 -10
- pymammotion/data/state_manager.py +11 -0
- pymammotion/mammotion/devices/mammotion_cloud.py +11 -3
- {pymammotion-0.5.5.dist-info → pymammotion-0.5.7.dist-info}/METADATA +1 -1
- {pymammotion-0.5.5.dist-info → pymammotion-0.5.7.dist-info}/RECORD +7 -7
- {pymammotion-0.5.5.dist-info → pymammotion-0.5.7.dist-info}/LICENSE +0 -0
- {pymammotion-0.5.5.dist-info → pymammotion-0.5.7.dist-info}/WHEEL +0 -0
pymammotion/data/model/device.py
CHANGED
|
@@ -7,12 +7,14 @@ from mashumaro.mixins.orjson import DataClassORJSONMixin
|
|
|
7
7
|
|
|
8
8
|
from pymammotion.data.model import HashList, RapidState
|
|
9
9
|
from pymammotion.data.model.device_info import DeviceFirmwares, DeviceNonWorkingHours, MowerInfo
|
|
10
|
+
from pymammotion.data.model.errors import DeviceErrors
|
|
10
11
|
from pymammotion.data.model.location import Location
|
|
11
12
|
from pymammotion.data.model.report_info import ReportData
|
|
12
13
|
from pymammotion.data.model.work import CurrentTaskSettings
|
|
14
|
+
from pymammotion.data.mqtt.event import ThingEventMessage
|
|
13
15
|
from pymammotion.data.mqtt.properties import ThingPropertiesMessage
|
|
14
16
|
from pymammotion.data.mqtt.status import ThingStatusMessage
|
|
15
|
-
from pymammotion.http.model.http import CheckDeviceVersion
|
|
17
|
+
from pymammotion.http.model.http import CheckDeviceVersion
|
|
16
18
|
from pymammotion.proto import DeviceFwInfo, MowToAppInfoT, ReportInfoData, SystemRapidStateTunnelMsg, SystemUpdateBufMsg
|
|
17
19
|
from pymammotion.utility.constant import WorkMode
|
|
18
20
|
from pymammotion.utility.conversions import parse_double
|
|
@@ -30,15 +32,14 @@ class MowingDevice(DataClassORJSONMixin):
|
|
|
30
32
|
mower_state: MowerInfo = field(default_factory=MowerInfo)
|
|
31
33
|
mqtt_properties: ThingPropertiesMessage | None = None
|
|
32
34
|
status_properties: ThingStatusMessage | None = None
|
|
35
|
+
device_event: ThingEventMessage | None = None
|
|
33
36
|
map: HashList = field(default_factory=HashList)
|
|
34
37
|
work: CurrentTaskSettings = field(default_factory=CurrentTaskSettings)
|
|
35
38
|
location: Location = field(default_factory=Location)
|
|
36
39
|
mowing_state: RapidState = field(default_factory=RapidState)
|
|
37
40
|
report_data: ReportData = field(default_factory=ReportData)
|
|
38
41
|
device_firmwares: DeviceFirmwares = field(default_factory=DeviceFirmwares)
|
|
39
|
-
|
|
40
|
-
err_code_list_time: list | None = field(default_factory=list)
|
|
41
|
-
error_codes: dict[str, ErrorInfo] = field(default_factory=dict)
|
|
42
|
+
errors: DeviceErrors = field(default_factory=DeviceErrors)
|
|
42
43
|
non_work_hours: DeviceNonWorkingHours = field(default_factory=DeviceNonWorkingHours)
|
|
43
44
|
|
|
44
45
|
def buffer(self, buffer_list: SystemUpdateBufMsg) -> None:
|
|
@@ -54,9 +55,9 @@ class MowingDevice(DataClassORJSONMixin):
|
|
|
54
55
|
self.location.dock.longitude = parse_double(buffer_list.update_buf_data[8], 4.0)
|
|
55
56
|
self.location.dock.rotation = buffer_list.update_buf_data[3] + 180
|
|
56
57
|
case 2:
|
|
57
|
-
self.err_code_list.clear()
|
|
58
|
-
self.err_code_list_time.clear()
|
|
59
|
-
self.err_code_list.extend(
|
|
58
|
+
self.errors.err_code_list.clear()
|
|
59
|
+
self.errors.err_code_list_time.clear()
|
|
60
|
+
self.errors.err_code_list.extend(
|
|
60
61
|
[
|
|
61
62
|
buffer_list.update_buf_data[3],
|
|
62
63
|
buffer_list.update_buf_data[5],
|
|
@@ -70,7 +71,7 @@ class MowingDevice(DataClassORJSONMixin):
|
|
|
70
71
|
buffer_list.update_buf_data[21],
|
|
71
72
|
]
|
|
72
73
|
)
|
|
73
|
-
self.err_code_list_time.extend(
|
|
74
|
+
self.errors.err_code_list_time.extend(
|
|
74
75
|
[
|
|
75
76
|
buffer_list.update_buf_data[4],
|
|
76
77
|
buffer_list.update_buf_data[6],
|
|
@@ -86,6 +87,7 @@ class MowingDevice(DataClassORJSONMixin):
|
|
|
86
87
|
)
|
|
87
88
|
|
|
88
89
|
def update_report_data(self, toapp_report_data: ReportInfoData) -> None:
|
|
90
|
+
"""Set report data for the mower."""
|
|
89
91
|
coordinate_converter = CoordinateConverter(self.location.RTK.latitude, self.location.RTK.longitude)
|
|
90
92
|
for index, location in enumerate(toapp_report_data.locations):
|
|
91
93
|
if index == 0 and location.real_pos_y != 0:
|
|
@@ -111,6 +113,7 @@ class MowingDevice(DataClassORJSONMixin):
|
|
|
111
113
|
self.report_data.update(toapp_report_data.to_dict(casing=betterproto.Casing.SNAKE))
|
|
112
114
|
|
|
113
115
|
def run_state_update(self, rapid_state: SystemRapidStateTunnelMsg) -> None:
|
|
116
|
+
"""Set lat long, work zone of RTK and robot."""
|
|
114
117
|
coordinate_converter = CoordinateConverter(self.location.RTK.latitude, self.location.RTK.longitude)
|
|
115
118
|
self.mowing_state = RapidState().from_raw(rapid_state.rapid_state_data)
|
|
116
119
|
self.location.position_type = self.mowing_state.pos_type
|
|
@@ -124,13 +127,13 @@ class MowingDevice(DataClassORJSONMixin):
|
|
|
124
127
|
)
|
|
125
128
|
|
|
126
129
|
def mow_info(self, toapp_mow_info: MowToAppInfoT) -> None:
|
|
127
|
-
|
|
130
|
+
"""Set mow info."""
|
|
128
131
|
|
|
129
132
|
def report_missing_data(self) -> None:
|
|
130
133
|
"""Report missing data so we can refetch it."""
|
|
131
134
|
|
|
132
135
|
def update_device_firmwares(self, fw_info: DeviceFwInfo) -> None:
|
|
133
|
-
"""
|
|
136
|
+
"""Set firmware versions on all parts of the robot or RTK."""
|
|
134
137
|
for mod in fw_info.mod:
|
|
135
138
|
match mod.type:
|
|
136
139
|
case 1:
|
|
@@ -12,6 +12,7 @@ from pymammotion.data.model.device_info import SideLight
|
|
|
12
12
|
from pymammotion.data.model.enums import ConnectionPreference
|
|
13
13
|
from pymammotion.data.model.hash_list import AreaHashNameList, NavGetCommData, NavGetHashListData, Plan, SvgMessage
|
|
14
14
|
from pymammotion.data.model.work import CurrentTaskSettings
|
|
15
|
+
from pymammotion.data.mqtt.event import ThingEventMessage
|
|
15
16
|
from pymammotion.data.mqtt.properties import ThingPropertiesMessage
|
|
16
17
|
from pymammotion.data.mqtt.status import ThingStatusMessage
|
|
17
18
|
from pymammotion.event.event import DataEvent
|
|
@@ -62,6 +63,7 @@ class StateManager:
|
|
|
62
63
|
|
|
63
64
|
self.properties_callback = DataEvent()
|
|
64
65
|
self.status_callback = DataEvent()
|
|
66
|
+
self.device_event_callback = DataEvent()
|
|
65
67
|
|
|
66
68
|
def get_device(self) -> MowingDevice:
|
|
67
69
|
"""Get device."""
|
|
@@ -84,6 +86,10 @@ class StateManager:
|
|
|
84
86
|
self._device.mower_state.product_key = thing_status.params.productKey
|
|
85
87
|
await self.on_status_callback(thing_status)
|
|
86
88
|
|
|
89
|
+
async def device_event(self, device_event: ThingEventMessage) -> None:
|
|
90
|
+
self._device.mqtt_device_event = device_event
|
|
91
|
+
await self.on_device_event_callback(device_event)
|
|
92
|
+
|
|
87
93
|
@property
|
|
88
94
|
def online(self) -> bool:
|
|
89
95
|
return self._device.online
|
|
@@ -114,6 +120,11 @@ class StateManager:
|
|
|
114
120
|
if self.status_callback:
|
|
115
121
|
await self.status_callback.data_event(thing_status)
|
|
116
122
|
|
|
123
|
+
async def on_device_event_callback(self, device_event: ThingEventMessage) -> None:
|
|
124
|
+
"""Execute the status callback if it is set."""
|
|
125
|
+
if self.device_event_callback:
|
|
126
|
+
await self.device_event_callback.data_event(device_event)
|
|
127
|
+
|
|
117
128
|
async def get_commondata_ack_callback(self, comm_data: NavGetCommDataAck | SvgMessageAckT) -> None:
|
|
118
129
|
"""Asynchronously calls the appropriate callback based on available handlers."""
|
|
119
130
|
if self.cloud_get_commondata_ack_callback:
|
|
@@ -31,6 +31,7 @@ class MammotionCloud:
|
|
|
31
31
|
"""Per account MQTT cloud."""
|
|
32
32
|
|
|
33
33
|
def __init__(self, mqtt_client: MammotionMQTT, cloud_client: CloudIOTGateway) -> None:
|
|
34
|
+
"""Initialize MammotionCloud."""
|
|
34
35
|
self.cloud_client = cloud_client
|
|
35
36
|
self.loop = asyncio.get_event_loop()
|
|
36
37
|
self.is_ready = False
|
|
@@ -39,6 +40,7 @@ class MammotionCloud:
|
|
|
39
40
|
self.mqtt_message_event = DataEvent()
|
|
40
41
|
self.mqtt_properties_event = DataEvent()
|
|
41
42
|
self.mqtt_status_event = DataEvent()
|
|
43
|
+
self.mqtt_device_event = DataEvent()
|
|
42
44
|
self.on_ready_event = DataEvent()
|
|
43
45
|
self.on_disconnected_event = DataEvent()
|
|
44
46
|
self.on_connected_event = DataEvent()
|
|
@@ -49,9 +51,6 @@ class MammotionCloud:
|
|
|
49
51
|
self._mqtt_client.on_message = self._on_mqtt_message
|
|
50
52
|
self._mqtt_client.on_ready = self.on_ready
|
|
51
53
|
|
|
52
|
-
# temporary for testing only
|
|
53
|
-
# self._start_sync_task = self.loop.call_later(30, lambda: asyncio.ensure_future(self.start_sync(0)))
|
|
54
|
-
|
|
55
54
|
async def on_ready(self) -> None:
|
|
56
55
|
loop = asyncio.get_event_loop()
|
|
57
56
|
loop.create_task(self.process_queue())
|
|
@@ -129,6 +128,8 @@ class MammotionCloud:
|
|
|
129
128
|
_LOGGER.debug("Protobuf event")
|
|
130
129
|
# Call the callbacks for each cloudDevice
|
|
131
130
|
await self.mqtt_message_event.data_event(event)
|
|
131
|
+
if event.method == "thing.events":
|
|
132
|
+
await self.mqtt_device_event.data_event(event)
|
|
132
133
|
if event.method == "thing.properties":
|
|
133
134
|
await self.mqtt_properties_event.data_event(event)
|
|
134
135
|
_LOGGER.debug(event)
|
|
@@ -170,6 +171,7 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
|
|
|
170
171
|
self._mqtt.mqtt_message_event.add_subscribers(self._parse_message_for_device)
|
|
171
172
|
self._mqtt.mqtt_properties_event.add_subscribers(self._parse_message_properties_for_device)
|
|
172
173
|
self._mqtt.mqtt_status_event.add_subscribers(self._parse_message_status_for_device)
|
|
174
|
+
self._mqtt.mqtt_device_event.add_subscribers(self._parse_device_event_for_device)
|
|
173
175
|
self._mqtt.on_ready_event.add_subscribers(self.on_ready)
|
|
174
176
|
self._mqtt.on_disconnected_event.add_subscribers(self.on_disconnect)
|
|
175
177
|
self._mqtt.on_connected_event.add_subscribers(self.on_connect)
|
|
@@ -188,6 +190,7 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
|
|
|
188
190
|
self._mqtt.mqtt_message_event.remove_subscribers(self._parse_message_for_device)
|
|
189
191
|
self._mqtt.mqtt_properties_event.remove_subscribers(self._parse_message_properties_for_device)
|
|
190
192
|
self._mqtt.mqtt_status_event.remove_subscribers(self._parse_message_status_for_device)
|
|
193
|
+
self._mqtt.mqtt_device_event.remove_subscribers(self._parse_device_event_for_device)
|
|
191
194
|
self._state_manager.cloud_gethash_ack_callback = None
|
|
192
195
|
self._state_manager.cloud_get_commondata_ack_callback = None
|
|
193
196
|
self._state_manager.cloud_get_plan_callback = None
|
|
@@ -319,6 +322,11 @@ class MammotionBaseCloudDevice(MammotionBaseDevice):
|
|
|
319
322
|
return
|
|
320
323
|
await self.state_manager.status(status)
|
|
321
324
|
|
|
325
|
+
async def _parse_device_event_for_device(self, status: ThingStatusMessage) -> None:
|
|
326
|
+
if status.params.iotId != self.iot_id:
|
|
327
|
+
return
|
|
328
|
+
await self.state_manager.device_event(status)
|
|
329
|
+
|
|
322
330
|
async def _parse_message_for_device(self, event: ThingEventMessage) -> None:
|
|
323
331
|
params = event.params
|
|
324
332
|
new_msg = LubaMsg()
|
|
@@ -25,7 +25,7 @@ pymammotion/const.py,sha256=lWRxvTVdXnNHuxqvRkjO5ziK0Ic-fZMM6J2dbe5M6Nc,385
|
|
|
25
25
|
pymammotion/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
26
|
pymammotion/data/model/__init__.py,sha256=UVRbSXGOjYnWv30ZEvzT5QRpdVqAbyeToo-t0QBWyi4,292
|
|
27
27
|
pymammotion/data/model/account.py,sha256=vJM-KTf2q6eBfVC-UlNHBSmJvqHiCawZ40vnuhXhaz8,140
|
|
28
|
-
pymammotion/data/model/device.py,sha256=
|
|
28
|
+
pymammotion/data/model/device.py,sha256=eu0GA_2FJFgrm_qB2U0Y_LU7xMmLH41kVN9nNlIzcPM,7892
|
|
29
29
|
pymammotion/data/model/device_config.py,sha256=DTnoePsMwJrKVXqGeKvbZQjs8Zab61U5T3b-c-w0WlM,2654
|
|
30
30
|
pymammotion/data/model/device_info.py,sha256=Q5PbPdTfd948ZWc8EHjN5zwU6pha5MCr47ZEXzCYKNY,1148
|
|
31
31
|
pymammotion/data/model/device_limits.py,sha256=m8HdxD-RaAkPm7jHYb9GLxMEH9IfzBPz0ZypmsLnId4,1946
|
|
@@ -45,7 +45,7 @@ pymammotion/data/mqtt/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdr
|
|
|
45
45
|
pymammotion/data/mqtt/event.py,sha256=C8TGRJs9wNxwg9FFmr9qcsweDnl5v5kcVcwiHxtYzJw,5384
|
|
46
46
|
pymammotion/data/mqtt/properties.py,sha256=laud9rE-JqBHWKZ44Dov2yMkp3Ld8ghpBwlZ4_3g9uQ,4321
|
|
47
47
|
pymammotion/data/mqtt/status.py,sha256=SgdrpE1Uldb01hybO6hYhgU1Sp1eILghC0UhMZMHrdQ,1091
|
|
48
|
-
pymammotion/data/state_manager.py,sha256=
|
|
48
|
+
pymammotion/data/state_manager.py,sha256=K3o__YsjBS5C5tEujANnxI-lgQpbXhPMUIy3sgVc3QI,12056
|
|
49
49
|
pymammotion/event/__init__.py,sha256=mgATR6vPHACNQ-0zH5fi7NdzeTCDV1CZyaWPmtUusi8,115
|
|
50
50
|
pymammotion/event/event.py,sha256=Z8WYxv_-5khEqKjL1w4c_Et24G1Kdm8QFuIBylD3h3U,3021
|
|
51
51
|
pymammotion/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -74,7 +74,7 @@ pymammotion/mammotion/devices/__init__.py,sha256=f2qQFPgLGmV85W2hSlMUh5BYuht9o_A
|
|
|
74
74
|
pymammotion/mammotion/devices/base.py,sha256=qDh7P7fnakDKgxTqjNLcQg8eE-6gHJaXAV0ONjhy_IU,12038
|
|
75
75
|
pymammotion/mammotion/devices/mammotion.py,sha256=dvFNLJvYS_Fu3JFkrJE3ljhECzewNJYMIPGuTAeFYHY,15170
|
|
76
76
|
pymammotion/mammotion/devices/mammotion_bluetooth.py,sha256=dSDw8xLUfAU2c9vKX65w87Rm2E78284WjJ72CKniPt4,19349
|
|
77
|
-
pymammotion/mammotion/devices/mammotion_cloud.py,sha256=
|
|
77
|
+
pymammotion/mammotion/devices/mammotion_cloud.py,sha256=aJ_SS2KgQsdD_qpSaHmGfhOyENPwatA6ae2Me41F8UI,15344
|
|
78
78
|
pymammotion/mqtt/__init__.py,sha256=Ocs5e-HLJvTuDpVXyECEsWIvwsUaxzj7lZ9mSYutNDY,105
|
|
79
79
|
pymammotion/mqtt/linkkit/__init__.py,sha256=ENgc3ynd2kd9gMQR3-kgmCu6Ed9Y6XCIzU0zFReUlkk,80
|
|
80
80
|
pymammotion/mqtt/linkkit/h2client.py,sha256=w9Nvi_nY4CLD_fw-pHtYChwQf7e2TiAGeqkY_sF4cf0,19659
|
|
@@ -124,7 +124,7 @@ pymammotion/utility/movement.py,sha256=N75oAoAgFydqoaOedYIxGUHmuTCtPzAOtb-d_29tp
|
|
|
124
124
|
pymammotion/utility/mur_mur_hash.py,sha256=xEfOZVbqRawJj66eLgtnZ85OauDR47oIPr29OHelzPI,4468
|
|
125
125
|
pymammotion/utility/periodic.py,sha256=MbeSb9cfhxzYmdT_RiE0dZe3H9IfbQW_zSqhmSX2RUc,3321
|
|
126
126
|
pymammotion/utility/rocker_util.py,sha256=6tX7sS87qoQC_tsxbx3NLL-HgS08wtzXiZkhDiz7uo0,7179
|
|
127
|
-
pymammotion-0.5.
|
|
128
|
-
pymammotion-0.5.
|
|
129
|
-
pymammotion-0.5.
|
|
130
|
-
pymammotion-0.5.
|
|
127
|
+
pymammotion-0.5.7.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
128
|
+
pymammotion-0.5.7.dist-info/METADATA,sha256=UAJpuhAZxf_jnb5I0uxjVpG-n05QuyduCKc9faQOdTo,3870
|
|
129
|
+
pymammotion-0.5.7.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
130
|
+
pymammotion-0.5.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|