Giter Site home page Giter Site logo

midea-local's Introduction

Midea-local python lib

Python build codecov

Control your Midea M-Smart appliances via local area network.

This library is part of https://github.com/georgezhao2010/midea_ac_lan code. It was separated to segregate responsibilities.

⭐If this component is helpful for you, please star it, it encourages me a lot.

Getting started

Finding your device

from midealocal.discover import discover
# Without knowing the ip address
discover()
# If you know the ip address
discover(ip_address="203.0.113.11")
# The device type is in hexadecimal as in midealocal/devices/TYPE
type_code = hex(list(discover().values())[0]['type'])[2:]

Getting data from device

from midealocal.discover import discover
from midealocal.devices import device_selector

token = '...'
key = '...'

# Get the first device
d = list(discover().values())[0]
# Select the device
ac = device_selector(
  name="AC",
  device_id=d['device_id'],
  device_type=d['type'],
  ip_address=d['ip_address'],
  port=d['port'],
  token=token,
  key=key,
  protocol=d['protocol'],
  model=d['model'],
  subtype=0,
  customize="",
)

# Connect and authenticate
ac.connect()

# Getting the attributes
print(ac.attributes)
# Setting the temperature
ac.set_target_temperature(23.0, None)
# Setting the swing
ac.set_swing(False, False)

midea-local's People

Contributors

bwrsandman avatar chemelli74 avatar dependabot[bot] avatar necroneco avatar pre-commit-ci[bot] avatar qianli-ma avatar rokam avatar wuwentao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

midea-local's Issues

B8 can't get token

Dear rokam,
Thank you with your B8 code,and when I test it,I found there are won't show the token.
Can we use the connect without token? Or how to use it?
I don't know how to get the token. Could you help me?

Installing 1.0.0 does not bring in the backports/enum.py script

How to repro:

  1. Install midea-local 1.0.0 with pip
  2. Import the device module.

Expected result:
The module imports without problems and with this, you can use the MideaDevice class.

Actual result:

>>> from midealocal import device
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/.venv/lib/python3.12/site-packages/midealocal/device.py", line 7, in <module>
    from .backports.enum import StrEnum
ModuleNotFoundError: No module named 'midealocal.backports'

Installing the 1.0.0 package does not bring in devices

I may be doing this wrong but after investigating why devices.device_selector was returning None, I checked if it may be because the import_module call was failing.

This bit of code seems to imply that I should be able to import a device like this from midealocal.devices import ac.device

if device_type < 0xA0:
device_path = f".{'x%02x' % device_type}.device"
else:
device_path = f".{'%02x' % device_type}.device"
module = import_module(device_path, __package__)

After spending too much time debugging the import function, I had a look at the installed files and they weren't there.

How to repo:

  1. virtualenv .venv
  2. source .venv/bin/activate
  3. pip install midea-local

Expected result:

$ ls .venv/lib/python3.12/site-packages/midealocal/devices/
a1 ac [...] __init__.py  __pycache__

Actual result:

$ ls .venv/lib/python3.12/site-packages/midealocal/devices/
__init__.py  __pycache__

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.