MerossIot icon indicating copy to clipboard operation
MerossIot copied to clipboard

Sample Code meross_iot.model.http.exception.HttpApiError: ErrorCodes.CODE_BAD_PASSWORD_FORMAT

Open shin0x opened this issue 2 years ago • 4 comments

Hey there, first of all thank you for your work. I am currently trying to set-up my mss210 together with this library, but every time I try to connect I am getting the above error code. Right now I am using the sample code, mentioned here and in the README: https://pypi.org/project/meross-iot/ The only thing I changed so far is the model name and my credentials. Any ideas would be greatly appreciated.

shin0x avatar Oct 06 '22 20:10 shin0x

Hi! The BAD_PASSWORD_FORMAT error code should be related to the credentials. If you are using special characters, try to change them.

albertogeniola avatar Oct 08 '22 08:10 albertogeniola

Thank you for your response, However I alreeady thought about my password being the problem and changed it temporarily to "Test1234" which should not be a problem. The error code persisted never the lesss

Any other ideas?

shin0x avatar Oct 08 '22 10:10 shin0x

Hi @shin0x ,

Could please copy-paste your entire ode snippet, being sure to remove your credentials? I will try to run the same snippet with my creds to reproduce the issue.

albertogeniola avatar Oct 08 '22 13:10 albertogeniola

Hi, this is my entire script:

import asyncio
import os

from meross_iot.http_api import MerossHttpClient
from meross_iot.manager import MerossManager

EMAIL = "E-Mail"
PASSWORD = "Password"

async def main():
    # Setup the HTTP client API from user-password
    http_api_client = await MerossHttpClient.async_from_user_password(email=EMAIL, password=PASSWORD)

    # Setup and start the device manager
    manager = MerossManager(http_client=http_api_client)
    await manager.async_init()

    # Retrieve all the MSS310 devices that are registered on this account
    await manager.async_device_discovery()
    plugs = manager.find_devices(device_type="mss210")

    if len(plugs) < 1:
        print("No MSS210 plugs found...")
    else:
        # Turn it on channel 0
        # Note that channel argument is optional for MSS310 as they only have one channel
        print(plugs)
        dev = plugs[0]

        # The first time we play with a device, we must update its status
        await dev.async_update()

        # We can now start playing with that
        print(f"Turning on {dev.name}...")
        #await dev.async_turn_on(channel=0)
        print("Waiting a bit before turing it off")
        await asyncio.sleep(5)
        print(f"Turing off {dev.name}")
        await dev.async_turn_off(channel=0)

    # Close the manager and logout from http_api
    manager.close()
    await http_api_client.async_logout()


if __name__ == '__main__':
    # Windows and python 3.8 requires to set up a specific event_loop_policy.
    #  On Linux and MacOSX this is not necessary.
    if os.name == 'nt':
        asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
    loop.close()

shin0x avatar Oct 08 '22 23:10 shin0x

I am also getting the same error with the same script with the power monitoring switch MSS310, but I guess the device type isn't relevant here. I tried circuventing the exception, but I get an error afterwards that there are no token found which makes sense as is not able to authenticating into the server.

Here is the full exception with the response from the Meross api I got.

ERROR:Received non-ok API status code: CODE_BAD_PASSWORD_FORMAT. Failed request to API. Response was: {'apiStatus': 1006, 'sysStatus': 0, 'info': '', 'timeStamp': 1668265950, 'data': {}}
Traceback (most recent call last):
  File "/home/fantaso/github/meross/listing_devices.py", line 35, in <module>
    loop.run_until_complete(main())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/fantaso/github/meross/listing_devices.py", line 12, in main
    http_api_client = await MerossHttpClient.async_from_user_password(email=EMAIL, password=PASSWORD)
  File "/home/fantaso/.local/lib/python3.8/site-packages/meross_iot/http_api.py", line 106, in async_from_user_password
    creds = await cls.async_login(email=email,
  File "/home/fantaso/.local/lib/python3.8/site-packages/meross_iot/http_api.py", line 203, in async_login
    response_data = await MerossHttpClient._async_authenticated_post(url=url,
  File "/home/fantaso/.local/lib/python3.8/site-packages/meross_iot/http_api.py", line 318, in _async_authenticated_post
    raise HttpApiError(error)
meross_iot.model.http.exception.HttpApiError: ErrorCodes.CODE_BAD_PASSWORD_FORMAT

Fantaso avatar Nov 12 '22 13:11 Fantaso

Hi! I was not able to reproduce this issue. It looks like there is something strange with your password. Are you sure you are not copy-pasting some strange characters in the password?

albertogeniola avatar Jan 02 '23 09:01 albertogeniola

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 03 '23 11:03 stale[bot]