Package: midea-beautiful-dehumidifier
This is a library that allows communication with Midea dehumidifier appliances via the local area network.midea-beautiful-dehumidifierThis library allows discovering Midea dehumidifiers on local network, getting their state and controlling then. The name comes from Chinese name for Midea (美的) which translates tobeautifulin English.This library inspired from the repository atmac-zhou/midea-msmartwhich provides similar functionality for air conditioners andbarban-dev/midea_inventor_dehumidifiercloud based functionality for dehumidifiers. This library may include verbatim or adapted portions of the code from those two projects.Thanks also toyitsushi's project,NeoAcheron's project,andersonshatch's project.Supported appliancesThe library works only Midea dehumidifiers supporting V3 protocol. Both appliances with and without ion function are supported.Some examples of supported dehumidifiers:Comfee MDDF-16DEN7-WF or MDDF-20DEN7-WF (tested with 20L version)Inventor EVA ΙΟΝ Pro Wi-Fi (EP3-WiFi 16L/20L) (tested with 20L version)Inventor Eva II Pro Wi-Fi (EVP-WF16L/20L)Pro Breeze 30L Smart Dehumidifier with Wifi / App ControlIt may as well work with other Midea Wi-Fi dehumidifiers.Dehumidifier dataThe following dehumidifier data is accessible via library:on/off switch (boolean, can be set)current relative humidity (read-only)target relative humidity (can be set)active mode (can be set)fan speed (can be set)ion mode status (boolean, can be set)tank is full (boolean, read-only)appliance name (read-only). Set through Midea mobile application.appliance serial number (read-only)appliance IPv4 address (read-only)token and key for local network access (read-only, only v3 appliances)filter replacement indicator (boolean, read-only, if supported on appliance)pump on/off switch (boolean, can be set, if supported on appliance)defrosting mode indicator (boolean, read-only, if supported on appliance)internal error code (read-only)DiscoveryThis library is able to discover appliances on local network. This is done by broadcasting UDP packets on all local networks interfaces to ports 6445. Appliances will respond to this broadcast with their description packet. Following discovery, communication switchers to TCP over port 6444. This communication is encrypted, and, for appliances with version 3 firmware the library needs a token/key combination associated to each appliance. This can be either provided as arguments or retrieved from Midea app account. Once obtained, the token/key pair can be reused for an appliance multiple times. The library can also retrieve the list of registered appliances from Midea app account and obtain additional information for devices (eg. name).Library connects to Midea cloud API using credentials from NetHome Plus mobile app. You can use other Midea app mobile applications if you obtain their application key and id. Seemidea_beautiful_dehumidifier/midea.pyfor some examples. Application key and application id must match, otherwise library won't be able to sign in.The discovery should work on Linux and Windows based systems, however it doesn't work in Windows Subsystem for Linux and may not work in Docker containers or VMs depending on network setup. For example, VM or container needs to have rights to broadcast to physical network to make discovery work. On workaround is to run discovery from non-virtualized environment host.If this discovery mechanism doesn't work on particular set-up, it is still possible to either target appliances directly using their IP address when it is known or to retrieve or setting their status using cloud service.Network considerationsDiscovery requires that both appliance and the machine performing discovery are present on the same subnet. Discovery process will issue UDP broadcast request on the local private networks discovered from host's network adapters. The library only scans private network ranges using this method (e.g. 10.0.0.0 – 10.255.255.255, 	172.16.0.0 – 172.31.255.255 and 192.168.0.0 – 192.168.255.255) It is also possible to explicitly provide networks or even single addresses to scan and in this case there is no limitation on address ranges, however, beware of sending broadcast requests to public ip networks.Local protocol supportLibrary supports following protocols:cloud based status reading and writing (no local access needed)v3 local protocol with compatible devices (requires TOKEN/KEY combination)v2 local protocol with compatible devices (TO BE TESTED)LoggingLibrary logs additional information at log level 5. Credentials information like username, password or token keys should never be logged, but you can use command line tool to display token and key data.Command Line UsageInstalling packagepipinstall--upgrademidea-beautiful-dehumidifierCommand line tool helpmidea_beautiful_dehumidifier-cli--help
midea_beautiful_dehumidifier-clidiscover--help
midea_beautiful_dehumidifier-cliset--help
midea_beautiful_dehumidifier-clistatus--helpDiscoveryDiscover dehumidifier appliances on the local network:midea_beautiful_dehumidifier-clidiscover--accountACCOUNT_EMAIL--passwordPASSWORDShow tokens used to connect to appliances via local networkmidea_beautiful_dehumidifier-clidiscover--accountACCOUNT_EMAIL--passwordPASSWORD--credentialsSearch for devices by providing explicit network addressmidea_beautiful_dehumidifier-clidiscover--accountACCOUNT_EMAIL--passwordPASSWORD--network192.0.1.3--credentialsSearch for devices by providing explicit network rangemidea_beautiful_dehumidifier-clidiscover--accountACCOUNT_EMAIL--passwordPASSWORD--network192.0.1.2/24--credentialsAppliance statusGet status of an appliance using known TOKEN and KEY (e.g. retrieved usingdiscovercommand)midea_beautiful_dehumidifier-clistatus--ipAPPLIANCE_IP_ADDRESS--tokenTOKEN--keyKEYGet status of an appliance using Midea app credentialsmidea_beautiful_dehumidifier-clistatus--ipAPPLIANCE_IP_ADDRESS--accountACCOUNT_EMAIL--passwordPASSWORDGet status of an appliance via Midea cloud API (note the usage of--idand--cloudoptions)midea_beautiful_dehumidifier-clistatus--idAPPLIANCE_ID--accountACCOUNT_EMAIL--passwordPASSWORD--cloudSet appliance attributeSet target relative humidity (0-100)midea_beautiful_dehumidifier-cliset--ipAPPLIANCE_IP_ADDRESS--tokenTOKEN--keyKEY--humidity55Sets operating mode (number 1 to 4)midea_beautiful_dehumidifier-cliset--ipAPPLIANCE_IP_ADDRESS--tokenTOKEN--keyKEY--mode1Set fan strength (0-100)midea_beautiful_dehumidifier-cliset--ipAPPLIANCE_IP_ADDRESS--tokenTOKEN--keyKEY--fan40Turn on/off ion mode (0 or 1)midea_beautiful_dehumidifier-cliset--ipAPPLIANCE_IP_ADDRESS--tokenTOKEN--keyKEY--ion1Turn on/off ion mode (0 or 1)midea_beautiful_dehumidifier-cliset--ipAPPLIANCE_IP_ADDRESS--tokenTOKEN--keyKEY--on1Turn on/off pump (0 or 1)midea_beautiful_dehumidifier-cliset--ipAPPLIANCE_IP_ADDRESS--tokenTOKEN--keyKEY--pump1Combinations multiple settingsmidea_beautiful_dehumidifier-cliset--ipAPPLIANCE_IP_ADDRESS--tokenTOKEN--keyKEY--fan60--humidity50Set target humidity via Midea cloud API (note the usage of--idand--cloudoptions)midea_beautiful_dehumidifier-cliset--idAPPLIANCE_ID--accountACCOUNT_EMAIL--passwordPASSWORD--humidity55--cloudWatch appliance statusWatch appliance status allows to debug packets received when polling it. It will repeatedly retrieve appliance status with specified pauses between each poll. Polling can be interrupted via keyboard.Continuously watch status of an appliance using known TOKEN and KEY (e.g. retrieved usingdiscovercommand) with interval of 10 seconds between pollingmidea_beautiful_dehumidifier-cliwatch--ipAPPLIANCE_IP_ADDRESS--tokenTOKEN--keyKEY--interval10Continuously watch status of an appliance using Midea app credentials with interval of 30 seconds between pollingmidea_beautiful_dehumidifier-clistatus--ipAPPLIANCE_IP_ADDRESS--accountACCOUNT_EMAIL--passwordPASSWORD--interval30Specifying log levelLog level is specified using--logoption:SetDEBUGlevelmidea_beautiful_dehumidifier-cli--logDEBUGdiscover--accountACCOUNT_EMAIL--passwordPASSWORDVery verbose level (may contain confidential information)midea_beautiful_dehumidifier-cli--logNOTSETdiscover--accountACCOUNT_EMAIL--passwordPASSWORDSetWARNINGlevel (default log level if option was not specified)midea_beautiful_dehumidifier-cli--logWARNINGdiscover--accountACCOUNT_EMAIL--passwordPASSWORDCode examplesDiscover appliances on local network:frommidea_beautiful_dehumidifierimportfind_appliancesappliances=find_appliances(account="USER_EMAIL@example.com",# Account e-mailpassword="secret_password",# Account password)forapplianceinappliances:print(f"{appliance!r}")Get appliance state:frommidea_beautiful_dehumidifierimportappliance_stateappliance=appliance_state(ip=192.0.1.2,# APPLIANCE_IP_ADDRESStoken="TOKEN",# TOKEN obtained from Midea APIkey="KEY",# Token KEY obtained from Midea API)print(f"{appliance!r}")Get appliance state from cloud:frommidea_beautiful_dehumidifierimportappliance_stateappliance=appliance_state(account="USER_EMAIL@example.com",# Account e-mailpassword="secret_password",# Account passwordid=123412341234,# Appliance id obtained from Midea API)print(f"{appliance!r}")Build the libraryLibrary is automatically built, packaged and published toPyPIwhen a Git Hub release is published.See alsohttps://github.com/nbogojevic/homeassistant-midea-dehumidifier-lan