-
-
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.
Implement Stream Subscription Retrieval and Response Handling (#60)
* Implement 'get stream subscription' * Correct function 'get_stream_subscription' name * Fixed double quote on '"Authorization": f"{cls._headers['Authorization']}"' and remove print * Update pymammotion/http/http.py Co-authored-by: Michael Arthur <[email protected]> * Update pymammotion/http/http.py Co-authored-by: Michael Arthur <[email protected]> * Update pymammotion/http/http.py Co-authored-by: Michael Arthur <[email protected]> * Update pymammotion/http/http.py Co-authored-by: Michael Arthur <[email protected]> * Update pymammotion/mammotion/devices/mammotion.py Co-authored-by: Michael Arthur <[email protected]> * Update pymammotion/mammotion/devices/mammotion.py Co-authored-by: Michael Arthur <[email protected]> * Update pymammotion/mammotion/devices/mammotion.py Co-authored-by: Michael Arthur <[email protected]> * Update pymammotion/mammotion/devices/mammotion.py Co-authored-by: Michael Arthur <[email protected]> * Update pymammotion/mammotion/devices/mammotion.py Co-authored-by: Michael Arthur <[email protected]> * Update pymammotion/mammotion/devices/mammotion.py Co-authored-by: Michael Arthur <[email protected]> * remove cloud_client * fix signature * Update pymammotion/http/http.py * Apply suggestions from code review * Update pymammotion/mammotion/devices/mammotion.py * Delete pymammotion/http/dataclass/stream_subscription_response.py --------- Co-authored-by: Andrea Cagnola <[email protected]> Co-authored-by: Michael Arthur <[email protected]>
- Loading branch information
1 parent
99662c6
commit b0c7d17
Showing
3 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
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_subscription(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() |