Skip to main content

A simple library to deal with Meross devices. At the moment MSS110, MSS210, MSS310, MSS310H smart plugs and the MSS425E power strip. Other meross device might work out of the box with limited functionality. Give it a try and, in case of problems, let the developer know by opening an issue on Github.

Project description

Build status Deployment Test status PyPI version Downloads PyPI - Downloads Beerpay

Meross IoT library

A pure-python based library providing API for controlling Meross IoT devices over the internet.

To see what devices are currently supported, checkout the Currently supported devices section. Hopefully, more Meross hardware will be supported in the future.

This library is still work in progress, therefore use it with caution.

Installation

Due to the popularity of the library, I've decided to list it publicly on the Pipy index. So, the installation is as simple as typing the following command:

pip install meross_iot --upgrade

Usage

The following script demonstrates how to use this library.

from meross_iot.api import MerossHttpClient
from meross_iot.supported_devices.power_plugs import GenericPlug
from meross_iot.supported_devices.light_bulbs import GenericBulb

if __name__=='__main__':
    httpHandler = MerossHttpClient(email="YOUR_MEROSS_CLOUD_EMAIL", password="YOUR_PASSWORD")

    print("Listing online devices...")

    # Retrieves the list of supported and ONLINE devices.
    # If you also want to list offline devices, pass the online_only=False parameter.
    # Note! Trying to control an offline device will generate an exception.
    devices = httpHandler.list_supported_devices()
    for d in devices:
        print("-", d)

    for device in devices:
        print("\n-------------------------------\n"
              "Playing with device: %s"
              "\n-------------------------------" % device)

        # Returns most of the info about the power plug
        print("\nGetting system data...")
        data = device.get_sys_data()
        print(data)

        # If the device supports multiple channels, let's play with each one.
        n_channels = len(device.get_channels())
        print("The device supports %d channels" % n_channels)

        for channel in range(0, n_channels):
            # Turns the power-plug on
            print("\nTurning channel %d on..." % channel)
            device.turn_on_channel(channel)

            # Turns the power-plug off
            print("Turning channel %d off..." % channel)
            device.turn_off_channel(channel)

        # If the current device is a bulb, let's play with it!
        if isinstance(device, GenericBulb) and device.supports_light_control():
            print("Controlling light color: make it blue at 50% power")
            device.set_light_color(rgb=(0, 0, 255), luminance=50)
            device.turn_on()

        # Some devices also have a dedicated channel for USB
        if isinstance(device, GenericPlug):
            usb_channel_index = device.get_usb_channel_index()
            if usb_channel_index is not None:
                # Turns the USB on
                print("\nTurning on USB...")
                device.turn_on_channel(usb_channel_index)

                # Turns the power-plug off
                print("Turning off USB...")
                device.turn_off_channel(usb_channel_index)

            # Some devices support reading consumption data
            if device.supports_consumption_reading():
                print("\nReading consumption data...")
                consumption = device.get_power_consumption()
                print(consumption)

            # Some devices support reading consumption data
            if device.supports_electricity_reading():
                print("\nReading electricity data...")
                electricity = device.get_electricity()
                print(electricity)

        # Returns the list of WIFI Network available for the plug
        # (Note. this takes some time to complete)
        print("\nScanning Wifi...")
        wifi_list = device.get_wifi_list()
        print(wifi_list)

Currently supported devices

Starting from v0.2.0.0, this library should support the majority of Meross devices on the market. The list of tested devices is the following:

  • MSL120
  • MSS110
  • MSS210
  • MSS310
  • MSS310h
  • MSS425e
  • MSS530H

I'd like to thank all the people who contributed to the early stage of library development, who stimulated me to continue the development and making this library support more devices:

Thanks to DanoneKiD, virtualdj, ictes, soberstadt, ping-localhost.

Protocol details

This library was implemented by reverse-engineering the network communications between the plug and the meross network. Anyone can do the same by simply installing a Man-In-The-Middle proxy and routing the ssl traffic of an Android emulator through the sniffer.

If you want to understand how the Meross protocol works, have a look at the Wiki. Be aware: this is still work in progress, so some pages of the wiki might still be blank/under construction.

Donate!

I like reverse engineering and protocol inspection, I think it keeps your mind trained and healthy. However, if you liked or appreciated by work, why don't you buy me a beer? It would really motivate me to continue working on this repository to improve documentation, code and extend the supported meross devices.

Moreover, donations will make me raise money to spend on other Meross devices. So far, I've bought the following devices:

  • MSL120
  • MSS210
  • MSS310
  • MSS425E
  • MSS530H

By issuing a donation, you will:

  1. Give me the opportunity to buy new devices and support them in this library
  2. Pay part of electricity bill used to keep running the plugs 24/7 (Note that they are used for Unit-Testing on the continuous integration engine when someone pushes a PR... I love DEVOPing!)
  3. You'll increase the quality of my coding sessions with free-beer!

Buy me a beer

Beerpay Beerpay

Look at these babies!

Look at the test environment that ensures high quality code of the library!

Current test environemnt

When a pull-request is performed against this repository, a CI pipeline takes care of building the code, testing it on Python 3.5/3.6/3.7, relying on some junit tests and, if all the tests pass as expected, the library is released on Pypi. However, to ensure that the code really works, the pipeline will issue on/off commands against real devices, that are dedicated 24/7 to the tests. Such devices have been bought by myself (with contributions received by donators). Hoever, keeping such devices connected 24/7 has a cost, which I sustain happily due to the success of the library. Anyways, feel free to contribute via donations!

Changelog

0.2.2.3

  • Implemented random UUID generation when connecting to the Meross MQTT broker

0.2.2.2

  • Updated README documentation: added missing imports
  • Handled MSS560 as a bulb
  • Handling max_capacity parameter by looking at the get_abilities response.

0.2.2.1

  • Added basic bulb support: turning on/off and light control
  • Implemented MSL120 support
  • Implemented MSL120 automatic test
  • Extended example script usage to show how to control the light bulbs
  • Added maximum retry limit for execute_command and connect()

0.2.1.1

  • Code refactoring to support heterogeneous devices (bulbs, plugs, garage openers)

0.2.1.0

  • Implemented auto-reconnect on lost connection
  • Improving locking system in order to prevent library hangs when no ack is received

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meross_iot-0.2.2.3.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

meross_iot-0.2.2.3-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file meross_iot-0.2.2.3.tar.gz.

File metadata

  • Download URL: meross_iot-0.2.2.3.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for meross_iot-0.2.2.3.tar.gz
Algorithm Hash digest
SHA256 cc646c42788f79c245743c4b2da87091d5340811169744d1705f72602efffd3f
MD5 05f547300e875b44fc50e7ad9d4147d7
BLAKE2b-256 a48c697f0a9fbb9c454e5d167d326454bf4acc266582c608b509af47588793d4

See more details on using hashes here.

File details

Details for the file meross_iot-0.2.2.3-py3-none-any.whl.

File metadata

  • Download URL: meross_iot-0.2.2.3-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for meross_iot-0.2.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1b69d537ba7678fef6064ee48d0971019c55cfcfe27e1594ba3b56c6cfbb6284
MD5 bc6668052544e5ea9d09737ee6354067
BLAKE2b-256 a3e6fad55166cc1b03e5254ccafd1c5dc2f5f32997c3aac72cbeb9da8f7b42c2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page