Skip to content

Commit

Permalink
Addressed #324
Browse files Browse the repository at this point in the history
  • Loading branch information
albertogeniola committed Oct 26, 2023
1 parent 33e2c26 commit b359682
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.6.0rc3
0.4.6.0rc4
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Due to the popularity of the library, I've decided to list it publicly on the Pi
So, the installation is as simple as typing the following command:

```bash
pip install meross_iot==0.4.6.0rc3
pip install meross_iot==0.4.6.0rc4
```

## Usage & Full Documentation
Expand Down Expand Up @@ -191,7 +191,7 @@ Anyway, feel free to contribute via donations!
</p>

## Changelog
#### 0.4.6.0rc3
#### 0.4.6.0rc4
- NOTE: this API version breaks backward compatibility with LOGIN method. When upgrading to this version,
make sure to pass the new api_base_url value correctly as described in the documentation.
- Switched the login API to the new signIn path as old /Auth/login is being deprecated
Expand All @@ -200,6 +200,7 @@ make sure to pass the new api_base_url value correctly as described in the docum
- Added mac-address attribute to BaseDevice class
- Fix recursive import error for CLI utility and updated help command for API-BASE-URL parameter
- Handling MFA code errors
- Fix sniffer script and added MFA disable disclaimer

<details>
<summary>Older</summary>
Expand Down
21 changes: 18 additions & 3 deletions utilities/meross_sniffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
from typing import List, Dict, Tuple
from zipfile import ZipFile

from meross_iot.controller.device import BaseDevice

from meross_iot.http_api import MerossHttpClient
from meross_iot.manager import MerossManager, TransportMode
from meross_iot.model.credentials import MerossCloudCreds
from meross_iot.model.enums import Namespace, OnlineStatus
from meross_iot.model.http.device import HttpDeviceInfo
from utilities.meross_fake_app import AppSniffer
from utilities.meross_fake_device import FakeDeviceSniffer
from urllib.parse import urlparse

SNIFF_LOG_FILE = 'sniff.log'
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
Expand Down Expand Up @@ -48,10 +49,24 @@ def _print_welcom_message():
"Although this utility won't collect your email/password, we recommend you to change "
"your Meross account password to a temporary one before using this software. Once you are done, "
"you can restore back your original password. By doing so, you are 100% sure you are not leaking any "
"real password to the developers.")
"real password to the developers.\n\n"
"ATTENTION: The sniffer does not support MFA login. Please disable MFA if willing to use this script.\n\n")


async def _async_gather_http_client() -> MerossHttpClient:
api_base_url = environ.get("MEROSS_API_URL", "https://iotx-us.meross.com")
if api_base_url is None:
api_base_url = input("Please specify the meross API base url. It should be 'https://iotx-us.meross.com' or 'https://iotx-eu.meross.com' or 'https://iotx-ap.meross.com'. "
"Leave blank if unsure: ")
api_base_url = api_base_url.strip()
if api_base_url is None:
api_base_url = "https://iotx-us.meross.com"
print(f"Assuming API Base URL: {api_base_url}")
try:
urlparse(api_base_url)
except:
print("Invalid API/URL provided.")
exit(2)
email = environ.get("MEROSS_EMAIL")
if email is None:
email = input("Please specify your meross email: ")
Expand All @@ -61,7 +76,7 @@ async def _async_gather_http_client() -> MerossHttpClient:
if password is None:
password = getpass.getpass(prompt='Please specify your Meross password: ', stream=sys.stdout).strip()
try:
return await MerossHttpClient.async_from_user_password(email, password)
return await MerossHttpClient.async_from_user_password(api_base_url=api_base_url, email=email, password=password)
except Exception:
print("An error occurred while gathering MerossAPI Client. Make sure your email-password credentials are valid.")
exit(1)
Expand Down

0 comments on commit b359682

Please sign in to comment.