-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrea Cagnola
committed
Sep 6, 2024
1 parent
425b60f
commit 9694f6d
Showing
4 changed files
with
123 additions
and
14 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
pymammotion/http/dataclass/stream_subscription_response.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from dataclasses import dataclass | ||
from typing import List, Optional | ||
|
||
from mashumaro.config import BaseConfig | ||
from mashumaro.mixins.orjson import DataClassORJSONMixin | ||
|
||
@dataclass | ||
class Camera(DataClassORJSONMixin): | ||
cameraId: int | ||
token: str | ||
|
||
@dataclass | ||
class Data(DataClassORJSONMixin): | ||
appid: str | ||
cameras: List[Camera] | ||
channelName: str | ||
token: str | ||
uid: int | ||
|
||
@dataclass | ||
class StreamSubscriptionResponse(DataClassORJSONMixin): | ||
code: int | ||
msg: str | ||
data: Optional[Data] = None | ||
|
||
class Config(BaseConfig): | ||
omit_default = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import asyncio | ||
import logging | ||
import os | ||
|
||
from aiohttp import ClientSession | ||
import traceback | ||
|
||
from pymammotion import MammotionHTTP | ||
from pymammotion.aliyun.cloud_gateway import CloudIOTGateway | ||
from pymammotion.const import MAMMOTION_DOMAIN | ||
from pymammotion.http.http import connect_http | ||
from pymammotion.mammotion.commands.mammotion_command import MammotionCommand | ||
from pymammotion.mqtt.mammotion_mqtt import MammotionMQTT, logger | ||
from pymammotion.mammotion.devices.mammotion import MammotionBaseCloudDevice | ||
from pymammotion.data.model.account import Credentials | ||
from pymammotion.mammotion.devices.mammotion import create_devices, ConnectionPreference, Mammotion | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
async def run(): | ||
EMAIL = os.environ.get('EMAIL') | ||
PASSWORD = os.environ.get('PASSWORD') | ||
DEVICE_NAME = "Luba-VSXXXXXX" | ||
|
||
try: | ||
credentials = Credentials( | ||
email=EMAIL, | ||
password=PASSWORD | ||
) | ||
_mammotion = await create_devices(ble_device=None, cloud_credentials=credentials, preference=ConnectionPreference.WIFI) | ||
|
||
|
||
|
||
await _mammotion.get_stream_subsctiption(DEVICE_NAME) | ||
|
||
return _mammotion | ||
except Exception as ex: | ||
logger.error(f"{ex}") | ||
logger.error(traceback.format_exc()) | ||
return None | ||
|
||
|
||
if __name__ == '__main__': | ||
logging.basicConfig(level=logging.DEBUG) | ||
logger.getChild("paho").setLevel(logging.WARNING) | ||
event_loop = asyncio.new_event_loop() | ||
asyncio.set_event_loop(event_loop) | ||
cloud_client = event_loop.run_until_complete(run()) | ||
event_loop.run_forever() |