Package: meross-iot
Meross IoT libraryA pure-python based library providing API for controlling Meross IoT devices over the internet.To see what devices are currently supported, checkout theCurrently supported devicessection.
However, some devicesmight work as expected even if they are not listedamong the supported devices.
In such cases, you're invited to open an issue and report tbe working/non-working status of your device.
This will help us to keep track of new devices and current support status of the library.This library is still work in progress, therefore use it with caution.RequirementsThis library requiresPython 3.7+. Previous versions won't be supported by this library.
In case working with previous versions of python is mandatory for your project, consider using 0.3.X.X versions
of this library (although it's highly recommended to migrate to 0.4.X.X).InstallationDue 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:pipinstallmeross_iot==0.4.6.2Usage & Full DocumentationRefer to thedocumentation pagesfor detailed usage instructions,
or simply have a look at the/examplesdirectory.If you are really impatient to use this library, refer to the following snippet of code that looks for a
mss310 smart plug and turns it on/off.importasyncioimportosfrommeross_iot.http_apiimportMerossHttpClientfrommeross_iot.managerimportMerossManagerEMAIL=os.environ.get('MEROSS_EMAIL')or"YOUR_MEROSS_CLOUD_EMAIL"PASSWORD=os.environ.get('MEROSS_PASSWORD')or"YOUR_MEROSS_CLOUD_PASSWORD"asyncdefmain():# Setup the HTTP client API from user-password# When choosing the API_BASE_URL env var, choose from one of the above based on your location.# Asia-Pacific: "iotx-ap.meross.com"# Europe: "iotx-eu.meross.com"# US: "iotx-us.meross.com"http_api_client=awaitMerossHttpClient.async_from_user_password(api_base_url='https://iotx-eu.meross.com',email=EMAIL,password=PASSWORD)# Setup and start the device managermanager=MerossManager(http_client=http_api_client)awaitmanager.async_init()# Retrieve all the MSS310 devices that are registered on this accountawaitmanager.async_device_discovery()plugs=manager.find_devices(device_type="mss310")iflen(plugs)<1:print("No MSS310 plugs found...")else:# Turn it on channel 0# Note that channel argument is optional for MSS310 as they only have one channeldev=plugs[0]# The first time we play with a device, we must update its statusawaitdev.async_update()# We can now start playing with thatprint(f"Turning on{dev.name}...")awaitdev.async_turn_on(channel=0)print("Waiting a bit before turing it off")awaitasyncio.sleep(5)print(f"Turing off{dev.name}")awaitdev.async_turn_off(channel=0)# Close the manager and logout from http_apimanager.close()awaithttp_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.ifos.name=='nt':asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())loop=asyncio.get_event_loop()loop.run_until_complete(main())loop.stop()Currently supported devicesStarting from v0.4.0.0, this library should support the majority of Meross devices on the market.
The list of tested devices is the following:MSL120 (RGB Bulb)MSS110 (Smart plug)MSS210 (Smart plug)MSS310 (Smart plug with power consumption)MSS310h (Smart plug with power consumption)MSS425E/MSS425F (Smart strip)MSS530H (Wall-mount switches)MSG100 (Garage opener)MSG200 (3-doors Garage opener)MSH300 (Smart hub + valve thermostat)MS100 (Smart hub + temperature/humidity sensor)MSS710MSXH0 (Smart Humidifier)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 toDanoneKiD,virtualdj,ictes,soberstadt,ping-localhost,tdippon.Special thanks go to the github sponsors supporting this and other projects. Thanks a lot!Unsupported device or feature?In case you own a Meross Device that is not currently supported by this library, you may ask the developers to
add specific support for that device. To do so, you will need to "sniff" low-level communication between your Meross
App and the specific device. Such data can help the developers to add support for that device.Pleasehave a look at thereto discover how to use the Meross Sniffing tool to do so.Homeassistant integrationYeah, it happened. As soon as I started developing this library, I've discovered the HomeAssistant world.
Thus, I've decided to spend some time to develop a full featured Homeassistant custom component, that you findhere.
Thanks to @troykelly who made a wish and supported my efforts in developing such component!Running on OSX?If so, please make sure you did install client certificates.Follow instructions here.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:MSL120MSS210MSS310MSS425EMSS530HMSG100MSH300MSXH0MSG200MTS200MRS100MOD150By issuing a donation, you will:Give me the opportunity to buy new devices and support them in this libraryPay 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!)You'll increase the quality of my coding sessions with free-beer!Look at these babies!Look at the test environment that ensures high quality code of the library!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 codereally 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 donors).
However, keeping such devices connected 24/7 has a cost, which I sustain happily due to the success of the library.
Anyway, feel free to contribute via donations!Changelog0.4.6.2Fix dependency specification for paho-mqtt and other librariesOlder#### 0.4.6.0
- 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
- Improved CloudCreds to carry also API and MQTT endpoints
- Handled auto-retry in case of wrong endpoint being used for login
- 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 disclaimer0.4.5.9Improve meross_sniffer utility: add support to collect messages spoofing the hardware device on meross cloud.Allow string namespace value for execute_command within manager.0.4.5.7Fix regression introduced with the latest refactor: missing properties on SubDevices.0.4.5.4Fix #274, due to Meross API change0.4.5.4-rc1Fix testsImplement auto-discovery control parameter for theMerossManager0.4.5.3Implement device registry dumper (#255)0.4.5.2Adds support for Runtime mixin (addresses #270)Improves documentation0.4.5.1Adds support for MOD150 oil diffuserEnables position set for MSR100 devices (might not work with non-HomeKit versions, though)0.4.5.0Introduced support for local-lan-http command handlingRollerShutter refactor and code improvementsAdded RollerShutter automatic testsAdded support for do-not-disturb modeImplemented ThermostatMixin and added support for MTS2000.4.4.7Added manager options to override default mqtt server host/port connection info.0.4.4.5Added Content-Type header to API calls0.4.4.4Added support for MSG2000.4.4.3Improved mqtt client and async: switched back to mixed async/threading approach.Added triggerSrc and uuid attributes to headerFixed a bug affecting message dispatching to sub-devices0.4.4.2Removed rate limiting logic/switchesFixed light_rgb test failing when issuing commands to smart-humidifier ledHandling HUB_ONLINE event at subdevice level0.4.3.1Fixed MQTT reconnection issue0.4.3.0Refactored asyncio calls affected by loop parameter deprecationVarioussubdeviceevent handling improvements and bugfixes0.4.2.4Added manager reference to Manager push notification handlersImproved push notification tests0.4.2.3Added new HTTP request headers (introduced with latest APP versions)Added custom user agent customization option to MerossHttpClientImplemented pending task cancellation when shutting down the managerImplemented HTTP API stats countingFixed bug affecting push notification parsing when multiple sensors/valves were in use0.4.2.2Fixed asyncio and threading bug in _schedule_later() utilityImproved timeout argument not being always passed downstreamImplemented default command execution property on base-deviceAdded configurable timeout automatic testImplemented device filtering by multiple typesFixed client reconnection not working as expected0.4.2.1Fixed "None error" when calling limiter apiUpdated aiohttp dependency to 3.7.4 due to security issues0.4.2.0Refactored MerossManager avoiding usage of multiple threadsImplemented multiple mqtt connections to different serversAdded custom API URL endpointMerged #150 (Added MSS620 support)Added ErrorCode 1022Renamed MerossManager domain and port parametersImproved disconnection/reconnection event handlingOnlineEvent is now being re-issued after client disconnection/reconnectionImplemented disconnect/reconnect automatic test0.4.1.0rc8Implemented first roller_shutter support (merged #160), thanks to @adrigonzalvez0.4.1.0rc7Implemented exponential backoff for api-rate limiterFixed memory leakage that occurred for long-lived sessions of the MerossManagerStatic known device types support addedReturning newly discovery devices from the discovery method()Implemented first version of meross_api_cliImproved device state recover after connection dropAdded API rate skip optionsTuned API rate limiting defaultsFixed meross_sniffer utility not starting when ran from commandlineAddressed problems with online events not being propagated correctly in some edge casesFixed some known-cached types that were missing SystemOnline and SystemAll mixinsRemoved warning logs from LightMixin when checking supported modes0.4.0.6Added device internal id parameter to async event handlers0.4.0.5Implemented MQTT rate-limiterUpdated documentationFixed error occurring with paho-mqtt > 1.5.00.4.0.3Improved sniffing data maskingAdded light.py update instructionAdded error logs in case of missing async_update() call first call0.4.0.2Re-Implemented Meross Sniffer utility0.4.0.1Fixed #117Extended API error codesUpdated paho-mqtt dependency to v1.5.0Fixed errors caused in tests when running on windows system / Python 3.80.4.0.0Complete re-engineerization of the library.Asynchronous approach using asyncioRuntime ability discovery using runtime pluggable mixin architectureDramatically increased performance using low-level asynchronous aiohttp and almost no locking primitiveAdded full-featured documentationAdded python type hintsMoved CI/CD to GitHub pages for letting PR test with on-premise Meross devices0.3.4.0RCAdded HTTP API logout capabilityRefactored MerossManager/HTTPClient classes0.3.3.3Added lock-assistant capability to help debug deadlock casesImproved tests0.3.3.0Added auto-reconnection capabilities by defaultImproved automated testing skipping0.3.2.22Fixed MerossManager not being thread-safe0.3.2.21Fixed status integer not being parsed as INT0.3.2.20Merged PR that adds supports for humidity sensor0.3.2.17Added Offline event emulation0.3.2.15Fixed deadlock occurring when handling ThermostatImplementing callback/timeouts0.3.2.14Added option to force status-update on devicesget_sys_data now ignores online status in order to allow full status update (including online status)0.3.2.12Hotfix for introduced regressionMinor fix for power_plugs0.3.2.9Implemented battery stats fetch for HUB devices (valve)0.3.2.7Added support for smart humidifier0.3.2.6Added support for binding/unbinding events0.3.2.5Fixed set_target_temperature not working as intended0.3.2.4Improved thermostat supportNew handling of Hub and subdevicesGeneral refactor0.3.1.12Implemented meross_sniffer tool for collecting unknown devices logs0.3.1.11Implemented meross_info_gather script0.3.1.10Improved logging0.3.1.9Fixed missing method implementationImproved loggingMinor improvementsstrmethods0.3.1.8Added HUB + thermostat support0.3.1.6Improved light bulb driver (capacity)0.3.1.5Fixed wrong MerossEventType being advertised for DeviceDoorStatusEvent0.3.1.3Added event fire capability to GenericBulb class.Fixed bulb state kwargs bugImproved set_light_color function for bulbs0.3.0.2Fixed door closing checks when using the async + callback close() and open() methods.0.3.0.1Added get_power_consumption() and get_electricity() methods as abstract methods of AbstractMerossDeviceFixed regression passing manager parameter when firing Meross events.0.3.0.0rc4Added added switch_state to the generated event0.3.0.0rc3Added quick fix for MSS560 color control0.3.0.0rc2Fixed Major bugs with MSG100Updated README examples0.3.0.0rc1Added MSG100 supportFixed errors being logged when power consumptionX command was issued on powerplugs0.3.0.0b1General refactor of the libraryAdded event-based supportFixed default mqtt broker address for non-european devices0.2.2.1Added basic bulb support: turning on/off and light controlImplemented MSL120 supportImplemented MSL120 automatic testExtended example script usage to show how to control the light bulbsAdded maximum retry limit for execute_command and connect()0.2.1.1Code refactoring to support heterogeneous devices (bulbs, plugs, garage openers)0.2.1.0Implemented auto-reconnect on lost connectionImproving locking system in order to prevent library hangs when no ack is received