Skip to main content

A Python library for local control of Midea (and associated brands) smart air conditioners. !! THIS IS A DEVELOPMENT PROJECT !! For the original, please refer to https://github.com/mill1000/midea-msmart

Project description

vogmidea

A Python library for local control of Midea (and associated brands) smart air conditioners.

!!! THIS IS A DEVELOPMENT FORK. DO NOT USE !!!

Code Quality Checks PyPI

If a devices uses one of the following apps it is likely supported:

  • Artic King (com.arcticking.ac)
  • Midea Air (com.midea.aircondition.obm)
  • NetHome Plus (com.midea.aircondition)
  • SmartHome/MSmartHome (com.midea.ai.overseas)
  • Toshiba AC NA (com.midea.toshiba)
  • 美的美居 (com.midea.ai.appliances)

Note: Only air conditioner devices (type 0xAC) are supported.

See usage to determine if a device is supported.

Features

Async Support

The device, LAN and cloud classes have all been rewritten to support async/await syntax.

from vogmidea.device import AirConditioner as AC

# Build device
device = AC(ip=DEVICE_IP, port=6444, device_id=int(DEVICE_ID))

# Get capabilities
await device.get_capabilities()

# Get current state
await device.refresh()

Device Discovery

A new discovery module can discover and return ready-to-use device objects from the network. A single device can be discovered by IP or hostname with the discover_single method.

Note: V3 devices are automatically authenticated via the Midea cloud.

from vogmidea.discover import Discover

# Discover all devices on the network
devices = await Discover.discover()

# Discover a single device by IP
device = await Discover.discover_single(DEVICE_IP)

Less Dependencies

Some external dependencies have been replaced with standard Python modules.

Code Quality

  • The majority of the code is now type annotated.
  • Code style and import sorting are enforced by autopep8 and isort via Github Actions.
  • Unit tests are implemented and executed by Github Actions.
  • A number of unused methods and modules have been removed from the code.
  • Naming conventions follow PEP8.

Installing

Use pip, remove the old msmart package if necessary, and install this fork vogmidea.

pip uninstall msmart
pip install vogmidea

Usage

CLI

A simple command line interface is provided to discover and query devices.

$ vogmidea --help
usage: vogmidea [-h] [-v] {discover,query} ...

Command line utility for vogmidea.

options:
  -h, --help        show this help message and exit
  -v, --version     show program's version number and exit

Command:
  {discover,query}

Each subcommand has additional help available. e.g. vogmidea discover --help

Discover

Discover all devices on the LAN with the vogmidea discover subcommand.

$ vogmidea discover
INFO:vogmidea.cli:Discovering all devices on local network.
...
INFO:vogmidea.cli:Found 2 devices.
INFO:vogmidea.cli:Found device:
{'ip': '10.100.1.140', 'port': 6444, 'id': 15393162840672, 'online': True, 'supported': True, 'type': <DeviceType.AIR_CONDITIONER: 172>, 'name': 'net_ac_F7B4', 'sn': '000000P0000000Q1F0C9D153F7B40000', 'key': None, 'token': None}
INFO:vogmidea.cli:Found device:
{'ip': '10.100.1.239', 'port': 6444, 'id': 147334558165565, 'online': True, 'supported': True, 'type': <DeviceType.AIR_CONDITIONER: 172>, 'name': 'net_ac_63BA', 'sn': '000000P0000000Q1B88C29C963BA0000', 'key': '3a13f53f335042f9ae5fd266a6bd779459ed7ee7e09842f1a0e03c024890fc96', 'token': '56a72747cef14d55e17e69b46cd98deae80607e318a7b55cb86bb98974501034c657e39e4a4032e3c8cc9a3cab00fd3ec0bab4a816a57f68b8038977406b7431'}

Check the output to ensure the type is 0xAC and the supported property is True.

Save the device ID, IP address, and port. Version 3 devices will also require the token and key fields to control the device.

Note: V1 Device Owners

Users with V1 devices will see the following error:

ERROR:vogmidea.discover:V1 device not supported yet.

I don't have any V1 devices to test with so please create an issue with the output of vogmidea discover --debug.

Query

Query device state and capabilities with the vogmidea query subcommand.

Note: Version 3 devices need to specify either the --auto argument or the --token, --key and --id arguments to make a connection.

$ vogmidea query <HOST>

Device capabilities can be queried with the --capabilities argument.

Home Assistant

Use this fork of midea-ac-py to control devices from Home Assistant.

Python

See the included example for controlling devices from a script.

Docker

A docker image is available on ghcr.io at ghcr.io/mill1000/vogmidea. The container should be run with --network=host to allow broadcast packets to reach devices on the local network. Additional arguments to the container are passed to the vogmidea CLI.

$ docker run --network=host ghcr.io/mill1000/vogmidea:latest --help
usage: vogmidea [-h] [-v] {discover,query} ...

Command line utility for vogmidea.

options:
  -h, --help        show this help message and exit
  -v, --version     show program's version number and exit

Command:
  {discover,query}

Gratitude

This project is a fork of mac-zhou/midea-msmart, and builds upon the work of

Project details


Download files

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

Source Distribution

vogmidea-0.1.2.tar.gz (21.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vogmidea-0.1.2-py3-none-any.whl (46.0 kB view details)

Uploaded Python 3

File details

Details for the file vogmidea-0.1.2.tar.gz.

File metadata

  • Download URL: vogmidea-0.1.2.tar.gz
  • Upload date:
  • Size: 21.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for vogmidea-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a96c26967b567cac8de0b08e7de80c29325bf4eecd9f75e06da2b69082dfb4aa
MD5 8172c9bca5b17440ffdfb56a544fecdd
BLAKE2b-256 ea204827ab6691a92a9623781f029dc780537a41dfe9005c6c26f896965db039

See more details on using hashes here.

File details

Details for the file vogmidea-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: vogmidea-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 46.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for vogmidea-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 24b7508e384092f676329389f5ebb4dde11b80b4e124048e66af13628cba2823
MD5 4079a542993349d120e7d7a90f1acb14
BLAKE2b-256 726f3f9004ea9288d8c55a108858bc40ae5f41bd5f73fc12ccfd5e17451b0c95

See more details on using hashes here.

Supported by

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