Skip to content

Commit

Permalink
Updated to use PyMammotion (#45)
Browse files Browse the repository at this point in the history
* Updated to use PyMammotion

* Removed old file

* Bumpped version

* Ran ruff

* Disabled ruff

* enabled again
  • Loading branch information
jLynx authored Jul 14, 2024
1 parent 21671a4 commit cb82be6
Show file tree
Hide file tree
Showing 56 changed files with 188 additions and 184 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
[![Supported Python Versions][img_pyversions]][url_pyversions]

[img_version]: https://img.shields.io/static/v1.svg?label=SemVer&message=0.0.1&color=blue
[url_version]: https://pypi.org/project/pyluba/
[url_version]: https://pypi.org/project/pymammotion/

[img_pypi]: https://img.shields.io/badge/PyPI-wheels-green.svg
[url_pypi]: https://pypi.org/project/pyluba/#files
[url_pypi]: https://pypi.org/project/pymammotion/#files

[img_pyversions]: https://img.shields.io/pypi/pyversions/pyluba.svg
[url_pyversions]: https://pypi.python.org/pypi/pyluba
[img_pyversions]: https://img.shields.io/pypi/pyversions/pymammotion.svg
[url_pyversions]: https://pypi.python.org/pypi/pymammotion

💬 [Join us on Discord](https://discord.gg/vpZdWhJX8x)

Expand All @@ -28,7 +28,7 @@ This library is the foundation for the [Mammotion Home Assistant integration](ht
You can install PyMammotion using pip:

```bash
pip install pyluba
pip install pymammotion
```

## Development 🔧
Expand Down
8 changes: 4 additions & 4 deletions pymammotion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import os

# works outside HA on its own
from pyluba.bluetooth.ble import LubaBLE
from pyluba.http.http import LubaHTTP, connect_http
from pymammotion.bluetooth.ble import LubaBLE
from pymammotion.http.http import LubaHTTP, connect_http

# TODO make a working device that will work outside HA too.
from pyluba.mammotion.devices import MammotionBaseBLEDevice
from pyluba.mqtt.mqtt import LubaMQTT, logger
from pymammotion.mammotion.devices import MammotionBaseBLEDevice
from pymammotion.mqtt.mqtt import LubaMQTT, logger

# TODO provide interface to pick between mqtt/cloud/bluetooth

Expand Down
18 changes: 10 additions & 8 deletions pymammotion/aliyun/cloud_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
from alibabacloud_tea_util.client import Client as UtilClient
from alibabacloud_tea_util.models import RuntimeOptions

from pyluba.aliyun.dataclass.aep_response import AepResponse
from pyluba.aliyun.dataclass.connect_response import ConnectResponse
from pyluba.aliyun.dataclass.dev_by_account_response import ListingDevByAccountResponse
from pyluba.aliyun.dataclass.login_by_oauth_response import LoginByOAuthResponse
from pyluba.aliyun.dataclass.regions_response import RegionResponse
from pyluba.aliyun.dataclass.session_by_authcode_response import (
from pymammotion.aliyun.dataclass.aep_response import AepResponse
from pymammotion.aliyun.dataclass.connect_response import ConnectResponse
from pymammotion.aliyun.dataclass.dev_by_account_response import (
ListingDevByAccountResponse,
)
from pymammotion.aliyun.dataclass.login_by_oauth_response import LoginByOAuthResponse
from pymammotion.aliyun.dataclass.regions_response import RegionResponse
from pymammotion.aliyun.dataclass.session_by_authcode_response import (
SessionByAuthCodeResponse,
)
from pyluba.const import ALIYUN_DOMAIN, APP_KEY, APP_SECRET, APP_VERSION
from pyluba.utility.datatype_converter import DatatypeConverter
from pymammotion.const import ALIYUN_DOMAIN, APP_KEY, APP_SECRET, APP_VERSION
from pymammotion.utility.datatype_converter import DatatypeConverter

logger = getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions pymammotion/bluetooth/ble.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from bleak import BleakClient, BleakScanner, BLEDevice
from bleak.backends.characteristic import BleakGATTCharacteristic

from pyluba.bluetooth.const import (
from pymammotion.bluetooth.const import (
SERVICE_CHANGED_CHARACTERISTIC,
UUID_NOTIFICATION_CHARACTERISTIC,
)
from pyluba.event.event import BleNotificationEvent
from pymammotion.event.event import BleNotificationEvent

# TODO setup for each Luba
address = "90:38:0C:6E:EE:9E"
Expand Down
18 changes: 9 additions & 9 deletions pymammotion/bluetooth/ble_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
from bleak import BleakClient
from jsonic.serializable import serialize

from pyluba.aliyun.tmp_constant import tmp_constant
from pyluba.bluetooth.const import UUID_WRITE_CHARACTERISTIC
from pyluba.bluetooth.data.convert import parse_custom_data
from pyluba.bluetooth.data.framectrldata import FrameCtrlData
from pyluba.bluetooth.data.notifydata import BlufiNotifyData
from pyluba.data.model.execute_boarder import ExecuteBorder
from pyluba.mammotion.commands.messages.navigation import MessageNavigation
from pyluba.proto import (
from pymammotion.aliyun.tmp_constant import tmp_constant
from pymammotion.bluetooth.const import UUID_WRITE_CHARACTERISTIC
from pymammotion.bluetooth.data.convert import parse_custom_data
from pymammotion.bluetooth.data.framectrldata import FrameCtrlData
from pymammotion.bluetooth.data.notifydata import BlufiNotifyData
from pymammotion.data.model.execute_boarder import ExecuteBorder
from pymammotion.mammotion.commands.messages.navigation import MessageNavigation
from pymammotion.proto import (
dev_net_pb2,
luba_msg_pb2,
)
from pyluba.utility.constant.device_constant import bleOrderCmd
from pymammotion.utility.constant.device_constant import bleOrderCmd

_LOGGER = logging.getLogger(__name__)

Expand Down
5 changes: 3 additions & 2 deletions pymammotion/bluetooth/data/convert.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from google.protobuf.message import DecodeError
from pyluba.proto import luba_msg_pb2

from pymammotion.proto import luba_msg_pb2


def parse_custom_data(data: bytes):
Expand All @@ -23,4 +24,4 @@ def store_sys_data(sys):
)
chargeStateTemp = longValue9
longValue10 = tard_state_data_list[6]
longValue11 = tard_state_data_list[7]
longValue11 = tard_state_data_list[7]
1 change: 0 additions & 1 deletion pymammotion/data/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
from .plan import Plan
from .rapid_state import RapidState, RTKStatus
from .region_data import RegionData

16 changes: 8 additions & 8 deletions pymammotion/data/model/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from dataclasses import dataclass

from pyluba.proto.dev_net import DevNet
from pyluba.proto.luba_msg import LubaMsg
from pyluba.proto.luba_mul import SocMul
from pyluba.proto.mctrl_driver import MctlDriver
from pyluba.proto.mctrl_nav import MctlNav
from pyluba.proto.mctrl_ota import MctlOta
from pyluba.proto.mctrl_pept import MctlPept
from pyluba.proto.mctrl_sys import MctlSys
from pymammotion.proto.dev_net import DevNet
from pymammotion.proto.luba_msg import LubaMsg
from pymammotion.proto.luba_mul import SocMul
from pymammotion.proto.mctrl_driver import MctlDriver
from pymammotion.proto.mctrl_nav import MctlNav
from pymammotion.proto.mctrl_ota import MctlOta
from pymammotion.proto.mctrl_pept import MctlPept
from pymammotion.proto.mctrl_sys import MctlSys


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion pymammotion/data/mqtt/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from mashumaro.mixins.orjson import DataClassORJSONMixin
from mashumaro.types import SerializableType

from pyluba.proto import luba_msg_pb2
from pymammotion.proto import luba_msg_pb2


class Base64EncodedProtobuf(SerializableType):
Expand Down
6 changes: 5 additions & 1 deletion pymammotion/http/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
from mashumaro import DataClassDictMixin
from mashumaro.mixins.orjson import DataClassORJSONMixin

from pyluba.const import MAMMOTION_CLIENT_ID, MAMMOTION_CLIENT_SECRET, MAMMOTION_DOMAIN
from pymammotion.const import (
MAMMOTION_CLIENT_ID,
MAMMOTION_CLIENT_SECRET,
MAMMOTION_DOMAIN,
)

DataT = TypeVar("DataT")

Expand Down
4 changes: 2 additions & 2 deletions pymammotion/luba/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Callable, Optional

from pyluba.data.model.rapid_state import RapidState, RTKStatus
from pyluba.data.mqtt.status import StatusType
from pymammotion.data.model.rapid_state import RapidState, RTKStatus
from pymammotion.data.mqtt.status import StatusType


class BaseLuba:
Expand Down
12 changes: 6 additions & 6 deletions pymammotion/mammotion/commands/mammotion_command.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pyluba.mammotion.commands.messages.navigation import MessageNavigation
from pyluba.mammotion.commands.messages.network import MessageNetwork
from pyluba.mammotion.commands.messages.ota import MessageOta
from pyluba.mammotion.commands.messages.system import MessageSystem
from pyluba.mammotion.commands.messages.video import MessageVideo
from pyluba.proto import dev_net_pb2, luba_msg_pb2
from pymammotion.mammotion.commands.messages.navigation import MessageNavigation
from pymammotion.mammotion.commands.messages.network import MessageNetwork
from pymammotion.mammotion.commands.messages.ota import MessageOta
from pymammotion.mammotion.commands.messages.system import MessageSystem
from pymammotion.mammotion.commands.messages.video import MessageVideo
from pymammotion.proto import dev_net_pb2, luba_msg_pb2


class MammotionCommand(
Expand Down
4 changes: 2 additions & 2 deletions pymammotion/mammotion/commands/messages/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from abc import ABC
from logging import getLogger

from pyluba.mammotion.commands.abstract_message import AbstractMessage
from pyluba.proto import luba_msg_pb2, mctrl_driver_pb2
from pymammotion.mammotion.commands.abstract_message import AbstractMessage
from pymammotion.proto import luba_msg_pb2, mctrl_driver_pb2

logger = getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions pymammotion/mammotion/commands/messages/media.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# === sendOrderMsg_Media ===
from pyluba.proto import luba_msg_pb2, luba_mul_pb2
from pyluba.proto.luba_mul import MUL_LANGUAGE
from pymammotion.proto import luba_msg_pb2, luba_mul_pb2
from pymammotion.proto.luba_mul import MUL_LANGUAGE


class MessageMedia:
Expand Down
12 changes: 6 additions & 6 deletions pymammotion/mammotion/commands/messages/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from abc import ABC
from typing import List

from pyluba.data.model import GenerateRouteInformation
from pyluba.data.model.plan import Plan
from pyluba.data.model.region_data import RegionData
from pyluba.mammotion.commands.abstract_message import AbstractMessage
from pyluba.proto.luba_msg import LubaMsg, MsgCmdType, MsgDevice, MsgAttr
from pyluba.proto.mctrl_nav import (
from pymammotion.data.model import GenerateRouteInformation
from pymammotion.data.model.plan import Plan
from pymammotion.data.model.region_data import RegionData
from pymammotion.mammotion.commands.abstract_message import AbstractMessage
from pymammotion.proto.luba_msg import LubaMsg, MsgAttr, MsgCmdType, MsgDevice
from pymammotion.proto.mctrl_nav import (
AppRequestCoverPathsT,
MctlNav,
NavGetCommData,
Expand Down
6 changes: 3 additions & 3 deletions pymammotion/mammotion/commands/messages/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import time
from typing import Dict

from pyluba.aliyun.tmp_constant import tmp_constant
from pyluba.mammotion.commands.messages.navigation import MessageNavigation
from pyluba.proto import dev_net_pb2, luba_msg_pb2
from pymammotion.aliyun.tmp_constant import tmp_constant
from pymammotion.mammotion.commands.messages.navigation import MessageNavigation
from pymammotion.proto import dev_net_pb2, luba_msg_pb2


class MessageNetwork:
Expand Down
2 changes: 1 addition & 1 deletion pymammotion/mammotion/commands/messages/ota.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# === sendOrderMsg_Ota ===
from pyluba.proto import luba_msg_pb2, mctrl_ota_pb2
from pymammotion.proto import luba_msg_pb2, mctrl_ota_pb2


class MessageOta:
Expand Down
10 changes: 5 additions & 5 deletions pymammotion/mammotion/commands/messages/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import datetime
from typing import List

from pyluba.mammotion.commands.abstract_message import AbstractMessage
from pyluba.mammotion.commands.messages.navigation import MessageNavigation
from pyluba.proto import luba_msg_pb2, mctrl_sys_pb2
from pyluba.proto.mctrl_sys import RptInfoType
from pyluba.utility.device_type import DeviceType
from pymammotion.mammotion.commands.abstract_message import AbstractMessage
from pymammotion.mammotion.commands.messages.navigation import MessageNavigation
from pymammotion.proto import luba_msg_pb2, mctrl_sys_pb2
from pymammotion.proto.mctrl_sys import RptInfoType
from pymammotion.utility.device_type import DeviceType


class MessageSystem(AbstractMessage):
Expand Down
6 changes: 3 additions & 3 deletions pymammotion/mammotion/commands/messages/video.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# === sendOrderMsg_Video ===
from pyluba.mammotion.commands.abstract_message import AbstractMessage
from pyluba.proto import luba_msg_pb2, luba_mul_pb2
from pyluba.utility.device_type import DeviceType
from pymammotion.mammotion.commands.abstract_message import AbstractMessage
from pymammotion.proto import luba_msg_pb2, luba_mul_pb2
from pymammotion.utility.device_type import DeviceType


class MessageVideo(AbstractMessage):
Expand Down
6 changes: 3 additions & 3 deletions pymammotion/mammotion/control/joystick.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from pyjoystick.sdl2 import Key, run_event_loop
from pyjoystick.utils import PeriodicThread

from pyluba import MammotionBaseBLEDevice
from pyluba.event import BleNotificationEvent
from pyluba.utility.rocker_util import RockerControlUtil
from pymammotion import MammotionBaseBLEDevice
from pymammotion.event import BleNotificationEvent
from pymammotion.utility.rocker_util import RockerControlUtil

bleNotificationEvt = BleNotificationEvent()

Expand Down
10 changes: 4 additions & 6 deletions pymammotion/mammotion/devices/luba.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
establish_connection,
)

from pyluba.bluetooth import BleMessage
from pyluba.data.model.device import MowingDevice
from pyluba.mammotion.commands.mammotion_command import MammotionCommand
from pyluba.proto.dev_net import DevNet
from pyluba.proto.luba_msg import LubaMsg
from pymammotion.bluetooth import BleMessage
from pymammotion.data.model.device import MowingDevice
from pymammotion.mammotion.commands.mammotion_command import MammotionCommand
from pymammotion.proto.luba_msg import LubaMsg


class CharacteristicMissingError(Exception):
Expand Down Expand Up @@ -191,7 +190,6 @@ async def start_sync(self, retry: int):
await self._send_command("get_report_cfg", retry)
await self._send_command_with_args("read_plan", sub_cmd=2, plan_index=0)


RW = await self._send_command_with_args(
"allpowerfull_rw", id=5, context=1, rw=1
)
Expand Down
14 changes: 7 additions & 7 deletions pymammotion/mqtt/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from linkkit.linkkit import LinkKit
from paho.mqtt.client import Client, MQTTMessage, MQTTv311, connack_string

from pyluba.data.model import RapidState
from pyluba.data.mqtt.event import ThingEventMessage
from pyluba.data.mqtt.properties import ThingPropertiesMessage
from pyluba.data.mqtt.status import ThingStatusMessage
from pyluba.luba.base import BaseLuba
from pyluba.mammotion.commands.mammotion_command import MammotionCommand
from pyluba.proto import luba_msg_pb2
from pymammotion.data.model import RapidState
from pymammotion.data.mqtt.event import ThingEventMessage
from pymammotion.data.mqtt.properties import ThingPropertiesMessage
from pymammotion.data.mqtt.status import ThingStatusMessage
from pymammotion.luba.base import BaseLuba
from pymammotion.mammotion.commands.mammotion_command import MammotionCommand
from pymammotion.proto import luba_msg_pb2

logger = getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion pymammotion/proto/common.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pymammotion/proto/common_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pymammotion/proto/dev_net.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cb82be6

Please sign in to comment.