nbogojevic / midea-beautiful-air Goto Github PK
View Code? Open in Web Editor NEWPython client for accessing Midea air conditioners and dehumidifiers (Midea, Comfee, Inventor EVO) via local network
License: MIT License
Python client for accessing Midea air conditioners and dehumidifiers (Midea, Comfee, Inventor EVO) via local network
License: MIT License
Is your feature request related to a problem? Please describe.
Traceback (most recent call last):
File "/nano-py/server.py", line 56, in <module>
worker = Worker(root, deployment)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/nano-py/pipedream/worker.py", line 100, in __init__
self.load()
File "/nano-py/pipedream/worker.py", line 119, in load
self.step_modules[cell["id"]] = importlib.import_module(cell["importPath"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lang/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1381, in _gcd_import
File "<frozen importlib._bootstrap>", line 1354, in _find_and_load
File "<frozen importlib._bootstrap>", line 1325, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 929, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 994, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/tmp/__pdg__/dist/code/49e6bbab882d8ffde19328b54f2835934a80c799a4eaf5930534d3e44f6aa22f/code.py", line 3, in <module>
from midea_beautiful import find_appliances
File "/tmp/__pdg__/dist/python/midea_beautiful/__init__.py", line 7, in <module>
from midea_beautiful.lan import LanDevice, appliance_state
File "/tmp/__pdg__/dist/python/midea_beautiful/lan.py", line 13, in <module>
from midea_beautiful.appliance import Appliance
File "/tmp/__pdg__/dist/python/midea_beautiful/appliance.py", line 8, in <module>
from midea_beautiful.command import (
File "/tmp/__pdg__/dist/python/midea_beautiful/command.py", line 17, in <module>
_order_lock = RLock()
^^^^^^^
File "/var/lang/lib/python3.12/multiprocessing/context.py", line 73, in RLock
return RLock(ctx=self.get_context())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/lang/lib/python3.12/multiprocessing/synchronize.py", line 194, in __init__
SemLock.__init__(self, RECURSIVE_MUTEX, 1, 1, ctx=ctx)
File "/var/lang/lib/python3.12/multiprocessing/synchronize.py", line 57, in __init__
sl = self._semlock = _multiprocessing.SemLock(
^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory
Describe the solution you'd like
The error says it’s failing to find a file or directory. Perhaps this package downloads files to a specific directory during install?
It may need to be configured to download files to /tmp instead, because that’s the only directory that’s writeable in your workflow.
Additional context
https://pipedream.com/docs/code/python/import-mappings/#using-magic-comments
# pipedream add-package midea-beautiful-air
from midea_beautiful import appliance_state, connect_to_cloud
import os
def handler(pd: "pipedream"):
cloud = connect_to_cloud(
account=os.environ["Midea_U"],
password=os.environ["Midea_P"],
appname="MSmartHome"
)
appliance = appliance_state(
cloud=cloud,
id=os.environ["Midea_id"],
)
print(f"{appliance!r}")
Library version=0.9.15
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mapp.appsmb.com:443
DEBUG:urllib3.connectionpool:https://mapp.appsmb.com:443 "POST /v1/appliance/user/list/get HTTP/1.1" 200 None
DEBUG:midea_beautiful.cloud:HTTP response text: {"msg":"ok","result":{"list":[{"registerTime":"Wed Oct 12 10:54:58 UTC 2022","onlineStatus":"1","type":"0xAC","homegroupId":"","userId":"7125410","tsn":"","mac":"","des":"","activeStatus":"1","homegroupCreateUserId":"","wifiVersion":"150029092122","name":"AC-Nappali","modelNumber":"","homegroupNumber":"","id":"1451355349xxxxx","sn":"bb329d5aa7909e37a78167547835993b6ac8177dcd6335262b6be3f3998c28256c31104f896b27adebcd2ddc8fbxxxxx","userType":"1"}
..
DEBUG:midea_beautiful.scanner:Broadcast attempt 1 of max 3
DEBUG:midea_beautiful.scanner:Broadcasting to 255.255.255.255
DEBUG:midea_beautiful.scanner:UDP broadcast 255.255.255.255:6445 b'ZZ\x01\x11H\x00\x92\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7fu\xbdk>O\x8bv.\x84\x9cnW\x8de\x90\x03n\x9dCB\xa5\x0f\x1fV\x9e\xb8\xec\x91\x8e\x92\xe5'
DEBUG:midea_beautiful.scanner:Finished broadcast collection
..
DEBUG:midea_beautiful.scanner:Found 0 of 3 appliance(s)
WARNING:midea_beautiful.scanner:Some appliance(s) where not discovered on local network: 0 discovered out of 3
DEBUG:midea_beautiful.appliance:Creating AirConditionerAppliance 14513553493****
WARNING:midea_beautiful.scanner:Unable to discover registered appliance {'id': '14513553493****', 'name': 'AC-Nappali', 'sn': '000000P0000000Q1AC93C4D0********', 'type': '0xAC', 'modelNumber': ''}
DEBUG:midea_beautiful.appliance:Creating AirConditionerAppliance 14513553493****
WARNING:midea_beautiful.scanner:Unable to discover registered appliance {'id': '14513553493****', 'name': 'AC-Hálószoba', 'sn': '000000P0000000Q1AC93C4CF********', 'type': '0xAC', 'modelNumber': ''}
DEBUG:midea_beautiful.appliance:Creating AirConditionerAppliance 14623504656****
WARNING:midea_beautiful.scanner:Unable to discover registered appliance {'id': '14623504656****', 'name': 'Ebédlő', 'sn': '000000P0000000Q1AC93C4CF********', 'type': '0xAC', 'modelNumber': ''}
..
id 000000P0000000Q1AC93C4CFFD6xxxxx/1462350465xxxxx
id = 1462350465xxxxx
addr = Unknown
s/n = 000000P0000000Q1AC93C4CFFD6xxxxx
model = Air conditioner
ssid = None
online = False
name = Ebédlő
running = False
target = 0
indoor = 2.2250738585072014e-308
outdoor = 2.2250738585072014e-308
fan = 40
mode = 0
purify = False
eco = False
sleep = False
F = False
error = 0
supports= {}
version = 3
token = None
key =
MIDEA GAIA Air-Conditioner MGA-12-SP (on label: GAIA-12HRFN8-I)
As seen from the log, the device is not detected on LAN. Data is collected from cloud
No token and key provided by the tool that is required (version 3)
With Zenmap for windows I found all 3 devices with their 6444 port open
I would like to integrate these devices to Homeassistant.
Is your feature request related to a problem? Please describe.
The dehumidifier i bought only alows me to register to app "Inventor control"
as I'm not able to add it in the INVmateII or Midea Air
Describe the solution you'd like
Compatibility with this app
Hey everyone,
I've recently bought dehumidier from the brand Ariston and was surprised to find midea behind the smart side of the device.
The model of the device: Ariston Deos 16S NET.
The name of the manufacturer in the wifi router: GD Midea AirConditioning Equipment Co.,Ltd.
I'm trying to use this repo to be able to talk locally to the device but when I use the discover function it doesn't recognize my account:
WARNING:midea_beautiful.cloud:Authentication error: '3102' - 'this account does not exist'
I have tried with all three --app implemented.
I'm guessing since I'm supposed to use the application "Ariston Clima" on android that the accounts are separated. On the password reset page (https://mapp-iam.appsmb.com/v1/page/repwd?activeId=fra_x_yyyyy&appId=1005&lan=en_US&stamp=20231202191008816&sign=xxx) I can see this:
<input type="hidden" id="appId" name="appId" value="1005" />
So the appid is 1005 but no sign of appkey or signkey.
Can somebody find the appkey and signkey for the application Ariston Clima or tell me how I can extract this information?
Hi, I am stuck running midea-beautiful-air-cli --help or any other command. I updated my raspberry pi and for long time I have installed and running fine python 3.9.5.
Have anyone seen this error before?
pi@raspberrypi:~ $ midea-beautiful-air-cli --help
Traceback (most recent call last):
File "/home/pi/.local/bin/midea-beautiful-air-cli", line 5, in
from midea_beautiful.cli import cli
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/init.py", line 6, in
from midea_beautiful.cloud import MideaCloud
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/cloud.py", line 16, in
from midea_beautiful.crypto import Security
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/crypto.py", line 17, in
from midea_beautiful.midea import (
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/midea.py", line 58, in
"iotkey": decrypt_internal("f4dcd1511147af45775d7e680ac5312b"), # noqa: E501
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/midea.py", line 30, in decrypt_internal
decryptor = cipher.decryptor()
File "/home/pi/.local/lib/python3.9/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 135, in decryptor
from cryptography.hazmat.backends.openssl.backend import backend
File "/home/pi/.local/lib/python3.9/site-packages/cryptography/hazmat/backends/openssl/init.py", line 6, in
from cryptography.hazmat.backends.openssl.backend import backend
File "/home/pi/.local/lib/python3.9/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 63, in
from cryptography.hazmat.bindings.openssl import binding
File "/home/pi/.local/lib/python3.9/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 14, in
from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: libffi.so.7: cannot open shared object file: No such file or directory
Hello!
I've noticed that if the appliance type is not specified in appliance_state():
appl = appliance_state( cloud=cloud, use_cloud=True, appliance_id='15173260******, appliance_type='ac'. # this here )
The following timeout error is thrown in appliance_transparent_send's API request:
midea_beautiful.exceptions.CloudRequestError: Too many retries while calling /v1/appliance/transparent/send, last error HTTPSConnectionPool(host='mapp.appsmb.com', port=443): Read timed out. (read timeout=2)
I am not sure why this happens exactly. It's been a long day, and it might look like tomorrow. The wild guess is that without including the appliance type in the request, the API considers it unworthy of a reply, lol. Seems like a minor thing, the fix might be something as simple as making the appliance_type non-optional
When using the library i keep getting '3004' - 'value is illegal.' a bit unclear what the issue is. Any one else have this issue?
version': '2.22.0', 'systemVersion': '8.1.0'
midea-beautiful-air-cli --verbose --log DEBUG discover --account [email protected] --password xxxxx --credentials --app MSmartHome
DEBUG:midea_beautiful:Library version=0.9.15
DEBUG:midea_beautiful.cloud:HTTP request /v1/multicloud/platform/user/route: {'x-recipe-app': '1010', 'Authorization': 'Basic ********************************************************', 'sign': '5146f2233bd1654266e08e4f5a137ebb95e4af70d3f94eb7b8905ba8b7d06994', 'secretVersion': '1', 'random': '1691476063', 'version': '2.22.0', 'systemVersion': '8.1.0', 'platform': '0', 'Accept-Encoding': 'identity', 'Content-Type': 'application/json'} {'appId': 1010, 'format': 2, 'clientType': 1, 'language': 'en_US', 'src': 1010, 'stamp': '20230808082743', 'userName': 'jimmy.bjorklu*************', 'appVNum': '2.22.0', 'appVersion': '2.22.0', 'clientVersion': '2.22.0', 'platformId': '1', 'reqId': 'f41fd6b923bd4a5b9ab375e2e2913614', 'retryCount': '3', 'uid': '', 'userType': '0'}
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mp-prod.appsmb.com:443
DEBUG:urllib3.connectionpool:https://mp-prod.appsmb.com:443 "POST /mas/v5/app/proxy?alias=/v1/multicloud/platform/user/route HTTP/1.1" 200 168
DEBUG:midea_beautiful.cloud:HTTP response text: {"msg":"ok","code":0,"data":{"masUrl":"https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=","sseUrl":"https://sse.msmartlife.net","idAdapt":"131329","countryCode":"HK"}}
DEBUG:midea_beautiful.cloud:HTTP response: {'msg': 'ok', 'code': 0, 'data': {'masUrl': 'https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=', 'sseUrl': 'https://sse.msmartlife.net', 'idAdapt': '131329', 'countryCode': 'HK'}}
DEBUG:midea_beautiful.cloud:using key='data', result={'masUrl': 'https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=', 'sseUrl': 'https://sse.msmartlife.net', 'idAdapt': '131329', 'countryCode': 'HK'}
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mp-prod.appsmb.com:443
DEBUG:urllib3.connectionpool:https://mp-prod.appsmb.com:443 "POST /mas/v5/app/proxy?alias=/v1/user/login/id/get HTTP/1.1" 200 41
DEBUG:midea_beautiful.cloud:HTTP response: *** REDACTED ***
DEBUG:midea_beautiful.cloud:Restarting session: '3004' - 'value is illegal.'
The example states
from midea_beautiful import appliance_state
appliance = appliance_state(
account="[email protected]", # Account e-mail
password="secret_password", # Account password
id=123412341234, # Appliance id obtained from Midea API
)
print(f"{appliance!r}")
But in code looks like you have to handover a cloud object
Also is needed appliance_id instead of id and use_cloud
user:~$ ~/.local/bin/midea-beautiful-air-cli set --ip 192.168.*.* --token FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF --key 9999999999999999999999999999999999999999999999999999999999999 --fan-speed 40
Traceback (most recent call last):
File "/home/user/.local/bin/midea-beautiful-air-cli", line 8, in <module>
sys.exit(cli())
^^^^^
File "/home/user/.local/lib/python3.11/site-packages/midea_beautiful/cli.py", line 340, in cli
return function(args)
^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.11/site-packages/midea_beautiful/cli.py", line 263, in _run_set_command
return _process_attr_arguments(args, appliance, cloud)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.11/site-packages/midea_beautiful/cli.py", line 222, in _process_attr_arguments
appliance.set_state(**set_args)
File "/home/user/.local/lib/python3.11/site-packages/midea_beautiful/lan.py", line 848, in set_state
self.apply(cloud)
File "/home/user/.local/lib/python3.11/site-packages/midea_beautiful/lan.py", line 693, in apply
cmd = self.state.apply_command()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.11/site-packages/midea_beautiful/appliance.py", line 609, in apply_command
cmd.fan_speed = self.fan_speed
^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.11/site-packages/midea_beautiful/command.py", line 668, in fan_speed
self.data[13] |= speed & 0b01111111
~~~~~~^~~~~~~~~~~~
TypeError: unsupported operand type(s) for &: 'str' and 'int'
It would be nice if connect_to_cloud support the app parameter
At the moment all values have to handover if one is missing the default value from NetHome Plus is used
Maybe allow to set default_app like others parameters
Would it be possible to add a Python example how to set appliance state?
Hi Nenad
Would it be possible to extend this library to manage EVA II PRO WiFi Smart Dehumidifier appliance?
It is similar to midea.
Midea apk is also capable to control it as well as its own Invmade || apk.
There is a library to control it via cloud, but would be great if it could be managed over LAN.
I did some port scanning and seams that it is listenig on port 6444.
https://github.com/barban-dev/midea_inventor_dehumidifier
I am trying to run the program, but keep getting an error that I cannot resolve:
pi@hue ~ $ midea-beautiful-air-cli discover --help
Traceback (most recent call last):
File "/home/pi/.local/bin/midea-beautiful-air-cli", line 6, in
from midea_beautiful.cli import cli
File "/home/pi/.local/lib/python3.7/site-packages/midea_beautiful/init.py", line 6, in
from midea_beautiful.cloud import MideaCloud
File "/home/pi/.local/lib/python3.7/site-packages/midea_beautiful/cloud.py", line 304
if data := response.get("data", {}):
Hi,
thanks for this cool project.
Can you explain the workflow, I want to develop this in php for the SmartHome software which I use.
Thanks in advance,
Kai
midea-beautiful-air-cli discover --account [email protected] --password PW --credentials --app MSmartHome
id 000000X0000000XXX0XXXXXXXXXX0000/XXXXXXXXXXXXXX
id = XXXXXXXXXXXXXX
addr = 192.168.X.X
s/n = 000000X0000000XXX0XXXXXXXXXX0000
model = Air conditioner
ssid = net_ac_XXXX
online = True
name = XXXXXXX
running = False
target = 22.0
indoor = 24.5
outdoor = 37.5
fan = 102
mode = 2
purify = False
eco = False
sleep = False
F = False
error = 0
supports= {'eco': 1, 'heat_8': 0, 'mode': 0, 'fan_swing': 1, 'electricity': 1, 'filter_reminder': 1, 'strong_fan': 1}
version = 2
token = None
key =
Good evening and welcome,
I tried to install your tool on a raspberry pi. Installation went trough with no issues. But when I try running your tool, it always fails with the following syntax error:
openhabian@openhabian:~ $ midea-beautiful-air-cli --help
Traceback (most recent call last):
File "/home/openhabian/.local/bin/midea-beautiful-air-cli", line 5, in
from midea_beautiful.cli import cli
File "/home/openhabian/.local/lib/python3.7/site-packages/midea_beautiful/init.py", line 6, in
from midea_beautiful.cloud import MideaCloud
File "/home/openhabian/.local/lib/python3.7/site-packages/midea_beautiful/cloud.py", line 304
if data := response.get("data", {}):
^
SyntaxError: invalid syntax
Anything I could try to fix that? Any known issues maybe with one of the depencies?
Thanks a lot, Christian
I wanted to automate my Midea AC with the openhab bindign, but it is not working.
Then I wanted to try the direct communication with this script.
If I execute this:
midea-beautiful-air-cli status --ip 10.0.10.145 --token 388B14F891293....... --key EB84F8FF5FD3......
I receive this output:
WARNING:midea_beautiful.appliance:Midea B5 unknown property=b'@\x00'
WARNING:midea_beautiful.lan:Error getting device capabilities for sn=000000P0000000Q130B23717******** id=1979120933**** address=10.0.1***** version=3, cause Unable to send data after 3 retries, last error timed out for 000000P0000000Q130B23717******** (1979120933****)
Traceback (most recent call last):
File "/home/user/.local/lib/python3.8/site-packages/midea_beautiful/lan.py", line 804, in identify
responses = self._status(cmd, cloud if use_cloud else None)
File "/home/user/.local/lib/python3.8/site-packages/midea_beautiful/lan.py", line 540, in _status
responses = self.appliance_send(data)
File "/home/user/.local/lib/python3.8/site-packages/midea_beautiful/lan.py", line 685, in appliance_send
return self._appliance_send_8370(data)
File "/home/user/.local/lib/python3.8/site-packages/midea_beautiful/lan.py", line 590, in _appliance_send_8370
if packets := self._retry_send(original_data, response_buf):
File "/home/user/.local/lib/python3.8/site-packages/midea_beautiful/lan.py", line 670, in _retry_send
packets = self.appliance_send(data)
File "/home/user/.local/lib/python3.8/site-packages/midea_beautiful/lan.py", line 685, in appliance_send
return self._appliance_send_8370(data)
File "/home/user/.local/lib/python3.8/site-packages/midea_beautiful/lan.py", line 590, in _appliance_send_8370
if packets := self._retry_send(original_data, response_buf):
File "/home/user/.local/lib/python3.8/site-packages/midea_beautiful/lan.py", line 675, in _retry_send
raise MideaNetworkError(
midea_beautiful.exceptions.MideaNetworkError: Unable to send data after 3 retries, last error timed out for 000000P0000000Q130B23717******** (1979120933****)
id 000000P0000000Q130B23717.....
id = 19791....
addr = 10.0.10.145
s/n = 000000P0000000Q130B....
model = Air conditioner
ssid = net_ac_921F
online = True
name = 19791....
running = True
target = 26.0
indoor = 27.2
outdoor = 36.1
fan = 10
mode = 2
purify = False
eco = False
sleep = False
F = False
error = 0
supports= {'eco': 1, 'has_no_wind_feel': 0, 'mode': 1, 'fan_swing': 1, 'electricity': 0, 'strong_fan': 1, 'fan_speed': 1, 'humidity': 3, 'temperature0': 32, 'temperature1': 60, 'temperature2': 32, 'temperature3': 60, 'temperature4': 32, 'temperature5': 60, 'temperature6': 5}
version = 3
The printed values are ok from the ac, but the exception is why?
Can you please help me?
The set command also shows this exception, but the on/off command working, and the AC switches on/off.
Unable to connect to Midea cloud API (Cloud authentication error: this account does not exist (3102)).
But my account is valid i've tried logging in/out of the MSmartApp. Thanks!
Originally posted by @ethan021021 in #5 (comment)
Using the CLI, with Python 3.9.2, and Midea-beautiful-air v0.9.14: Any attempt to change fan speed on a Midea U (Model: MAW08V1QWT, current FW) using --fan_speed [int] command line option and value, results in the following unhandled exception resulting in the form of a TypeError.
Command Issued:
midea-beautiful-air-cli set --ip 10.0.1.105 --token [token] --key [key] --mode 5 --fan-speed 60
Traceback:
Traceback (most recent call last):
File "/home/meerb/.local/bin/midea-beautiful-air-cli", line 8, in
sys.exit(cli())
File "/home/meerb/.local/lib/python3.9/site-packages/midea_beautiful/cli.py", line 340, in cli
return function(args)
File "/home/meerb/.local/lib/python3.9/site-packages/midea_beautiful/cli.py", line 263, in _run_set_command
return _process_attr_arguments(args, appliance, cloud)
File "/home/meerb/.local/lib/python3.9/site-packages/midea_beautiful/cli.py", line 222, in _process_attr_arguments
appliance.set_state(**set_args)
File "/home/meerb/.local/lib/python3.9/site-packages/midea_beautiful/lan.py", line 827, in set_state
self.apply(cloud)
File "/home/meerb/.local/lib/python3.9/site-packages/midea_beautiful/lan.py", line 687, in apply
cmd = self.state.apply_command()
File "/home/meerb/.local/lib/python3.9/site-packages/midea_beautiful/appliance.py", line 605, in apply_command
cmd.fan_speed = self.fan_speed
File "/home/meerb/.local/lib/python3.9/site-packages/midea_beautiful/command.py", line 665, in fan_speed
self.data[13] |= speed & 0b01111111
TypeError: unsupported operand type(s) for &: 'str' and 'int'
It appears there is type confusion from an implied type conversion, although it looks as though there is the proper type declaration in the setter method, in command.py:662:
@fan_speed.setter def fan_speed(self, speed: int) -> None: self.data[13] &= ~0b01111111 # Clear the fan speed part self.data[13] |= speed & 0b01111111
There seems a potentially related issue with the fan_speed being set periodically set to "2", while the Cool function is running. If the Midea is running with APP mode OFF, this does not seem to happen. I'll detail further in separate issue.
Hi,
Thank you for your work.
I just bought a Midea MDDF-20DEN7 dehumidifier and I want to use it local only (and integrate into openhab).
Can you tell me why do I need to set cloud user and password to reach it locally? Only to get token and key?
I made a mistake and migrate my new Midea Air account to MSmartHome and I got "this account does not exist" error like in issue 6.
I use 0.9.10 but still account does not exist.
I can run discovery with IP only and I get some data but no token of course.
I tried the apiurl parameter but I don't what appkey and other should be.
Can someone help me to connect to my device? Now I block internet access of my dehumidifier, maybe that is another mistake :S
I noticed into my Home Assistant that temperature was lower than before even if my environment temperature did not change and is controlled by smart thermostats
It also looks like decimals were lost. I looked at commits from https://github.com/nbogojevic/homeassistant-midea-dehumidifier-lan but didn't find anything relevant except that it is using the midea-beautiful-dehumidifier.
Searching into commits led me to a calculation change for humidity and temperature in "class DehumidifierResponse:"
5bf0098
I don't know much about python and data received, but perhaps it may help you resolve the issue.
Thanks for the hard work and making this available
When I run the discovery command like:
discover --account xxxx --password xxxx --credentials --proxied
I get the following error message:
File "/usr/local/lib/python3.9/site-packages/midea_beautiful_air-0.9.10-py3.9.egg/midea_beautiful/crypto.py", line 536, in sign_proxied
msg += data
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'
It seems to be caused by using the proxied property and not specifying and IOT Key, but I just want to obtain the key and token by logging in using the cloud api. What discovery command should I use for this?
When I requesting status from an Air Conditioner via cloud I receiving
When request the capabilities
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mp-prod.appsmb.com:443
DEBUG:urllib3.connectionpool:https://mp-prod.appsmb.com:443 "POST /mas/v5/app/proxy?alias=/v1/appliance/transparent/send HTTP/1.1" 200 26
DEBUG:midea_beautiful.cloud:HTTP response text: {"code":"1000","msg":null}
DEBUG:midea_beautiful.cloud:HTTP response: {'code': '1000', 'msg': None}
midea_beautiful.exceptions.CloudError: Midea cloud API error: None (1000)
I'm not sure is this really an error or normal response for no capabilities
I saw also Creating DehumidifierAppliance
in the log for an Air Conditioner for Comfee Cool 7000-1
I'm trying to get a heat pump with an EU-OSK103 dongle connected - it works in the app but I don't see why Xi needs to have control over my equipment - but have thus far not been able to do so due to token/key errors. The thing does retrieve token/key combinations but these do not seem to work. These errors occur both in this application as well as similar ones, e.g. the openHAB MideaAC binding. While I normally have all IoT devices living on their own network which is unable to reach out to the 'net I temporarily gave the OSK103 full access to see whether that made any difference but it did not work either. I also tested this on a newly created container with a single network interface on the IoT network and access to the 'net, the result was the same.
The layout is as follows:
$ midea-beautiful-air-cli --verbose --log DEBUG discover --account 'MYACCOUNT' --password 'MYPASSWORD' --credentials --app MSmartHome --address 192.168.4.103
...
...
...
DEBUG:midea_beautiful.cloud:HTTP request /v1/iot/secure/getToken: {'uid': '********************************', 'accessToken': '*****************', 'x-recipe-app': '1010', 'Authorization': 'Basic ********************************************************', 'sign': 'aeb5ef9c0eb21c8c9886ecd27a824657472c6de3a618de5807c6c7c32e8ea8fd', 'secretVersion': '1', 'random': '1673264036', 'version': '2.22.0', 'systemVersion': '8.1.0', 'platform': '0', 'Accept-Encoding': 'identity', 'Content-Type': 'application/json'} {'appId': 1010, 'format': 2, 'clientType': 1, 'language': 'en_US', 'src': 1010, 'stamp': '20230109123356', 'udpid': '878a75fcceffe0f75fb51ac58ad845af', 'appVNum': '2.22.0', 'appVersion': '2.22.0', 'clientVersion': '2.22.0', 'platformId': '1', 'reqId': '910aadd78cdeb480113a101d5735c25b', 'retryCount': '3', 'uid': '********************************', 'userType': '0'}
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mp-prod.appsmb.com:443
DEBUG:urllib3.connectionpool:https://mp-prod.appsmb.com:443 "POST /mas/v5/app/proxy?alias=/v1/iot/secure/getToken HTTP/1.1" 200 303
DEBUG:midea_beautiful.cloud:HTTP response: *** REDACTED ***
DEBUG:midea_beautiful.cloud:using key='data', result=*** REDACTED ***
DEBUG:midea_beautiful.lan:token='334CA81C317D02AC0FB7C67B00924DBCB980571AFB94825C1462481D0D0DA5A3****************************************************************' key='af9894e535914104a25938409f7a9482********************************' for sn=000000P0000000Q1C43************* id=28111691538**** address=192.168.***** version=3
DEBUG:midea_beautiful.lan:Attempting new connection to sn=000000P0000000Q1C43************* id=28111691538**** address=192.168.***** version=3
DEBUG:midea_beautiful.lan:Sending to sn=000000P0000000Q1C43************* id=28111691538**** address=192.168.***** version=3, message=b'\x83p\x00@ \x00\x00\x003L\xa8\x1c1}\x02\xac\x0f\xb7\xc6{\x00\x92M\xbc\xb9\x80W\x1a\xfb\x94\x82\\\x14bH\x1d\r\r\xa5\xa3\x8f\xd6\xf7Y\xdc&\xca\xc7F\x86\x9d\x809K\x1a:=O0NU\xe6\\\xc5/\xc1MC\t+._'
DEBUG:midea_beautiful.lan:From sn=000000P0000000Q1C43************* id=28111691538**** address=192.168.***** version=3, message=b'\x83p\x00\x05 \x0f\x00\x00ERROR'
DEBUG:midea_beautiful.lan:handshake_response=b'\x83p\x00\x05 \x0f\x00\x00ERROR' for sn=000000P0000000Q1C43************* id=28111691538**** address=192.168.***** version=3
DEBUG:midea_beautiful.lan:Token check failed for udp_id=878a75fcceffe0f75fb51ac58ad845af, Failed to get TCP key for 000000P0000000Q1C43*************, cause Authentication failed - error packet
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/midea_beautiful/lan.py", line 517, in _get_tcp_key
tcp_key = self._security.tcp_key(response, binascii.unhexlify(self.key))
File "/usr/local/lib/python3.9/dist-packages/midea_beautiful/crypto.py", line 409, in tcp_key
raise AuthenticationError("Authentication failed - error packet")
midea_beautiful.exceptions.AuthenticationError: Authentication failed - error packet
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/midea_beautiful/lan.py", line 741, in _get_valid_token
self._authenticate()
File "/usr/local/lib/python3.9/dist-packages/midea_beautiful/lan.py", line 513, in _authenticate
self._get_tcp_key(response)
File "/usr/local/lib/python3.9/dist-packages/midea_beautiful/lan.py", line 528, in _get_tcp_key
raise AuthenticationError(
midea_beautiful.exceptions.AuthenticationError: Failed to get TCP key for 000000P0000000Q1C43*************, cause Authentication failed - error packet
...
...
...
WARNING:midea_beautiful.scanner:Unable to discover registered appliance {'id': '14293651172****', 'name': 'AA Heat pump office', 'sn': '000000P0000000Q1C4396060********', 'type': '0xAC', 'modelNumber': '-84'}
id 000000P0000000Q1C43*******************************
id = 14293651172****
addr = Unknown
s/n = 000000P0000000Q1C43*************',
model = Air conditioner
ssid = None
online = False
name = AA Heat pump office
running = False
target = 0
indoor = 2.2250738585072014e-308
outdoor = 2.2250738585072014e-308
fan = 40
mode = 0
purify = False
eco = False
sleep = False
F = False
error = 0
supports= {}
version = 3
token = None
key =
As an aside, things don't work in msmart (from which this project was derived) either, see mac-zhou/midea-msmart#105.
I do notice one oddity, the modelNumber is reported as a negative number in WARNING:midea_beautiful.scanner:Unable to discover registered appliance { .... 'type': '0xAC', 'modelNumber': '-84'}
in data returned from the cloud host (mp-prod.appsmb.com
).
The dongle is used in a Kaisai-branded AC, as said it works when using the Midea/MSmartHome/whatever app but hell will freeze over before I use any of these "cloud-based" control things - whoever came up with the concept of giving a third party total control over grid-connected networked equipment inside millions of homes either deserves a prize for coming up with such a cheap strategic weapon [1] or a one-way trip to the clink depending on your stand- and viewpoint.
[1] As it stands now whoever has control over these "cloud" servers can probably disable the grid in most of the "developed" countries in the world and half of the "developing" ones, simply by simultaneously switching on and off all devices under their control at a rapid pace.
When using both dscover or status command, i get always this following error (3 times).
WARNING:midea_beautiful.lan:Error getting device capabilities for sn=000000P0000000Q1AC93C421******** id=14513553495**** address=192.168.***** version=3, cause Unable to send data after 3 retries, last error timed out for 000000P0000000Q1AC93C421******** (14513553495****)
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/lan.py", line 809, in identify
responses = self._status(cmd, cloud if use_cloud else None)
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/lan.py", line 540, in _status
responses = self.appliance_send(data)
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/lan.py", line 685, in appliance_send
return self._appliance_send_8370(data)
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/lan.py", line 590, in _appliance_send_8370
if packets := self._retry_send(original_data, response_buf):
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/lan.py", line 670, in _retry_send
packets = self.appliance_send(data)
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/lan.py", line 685, in appliance_send
return self._appliance_send_8370(data)
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/lan.py", line 590, in _appliance_send_8370
if packets := self._retry_send(original_data, response_buf):
File "/home/pi/.local/lib/python3.9/site-packages/midea_beautiful/lan.py", line 675, in _retry_send
raise MideaNetworkError(
midea_beautiful.exceptions.MideaNetworkError: Unable to send data after 3 retries, last error timed out for 000000P0000000Q1AC93C421******** (14513553495****)
id 000000P0000000Q1AC93C421********/14513553495****
id = 145135534952750
addr = 192.168.1.201
s/n = 000000P0000000Q1AC93C421****
model = Air conditioner
ssid = net_ac_865A
online = True
name = AC - Living Room
running = False
target = 24.0
indoor = 24.1
outdoor = 19.0
fan = 101
mode = 1
purify = False
eco = False
sleep = False
F = False
error = 0
supports= {'eco': 0, 'mode': 1, 'fan_swing': 1, 'electricity': 0, 'strong_fan': 1, 'fan_speed': 1, 'temperature0': 32, 'temperature1': 60, 'temperature2': 32, 'temperature3': 60, 'temperature4': 32, 'temperature5': 60, 'temperature6': 0}
version = 3
Any idea why is this happening ?
Library version=0.9.5
LXD Host: Debian 11 (6.0.0-0.deb11.6-amd64)
LXC Container: Debian 12 (6.0.0-0.deb11.6-amd64)
Network: Full access
Python: 3.11.2
Model: MSMBBU-12HRFN1-QRD0G
The bug has occurred when I was trying to obtain TOKEN/KEY for our AC appliances via username/password.
Command:
midea-beautiful-air-cli --log DEBUG --verbose discover --app "MSmartHome" --account '[email protected]' --password 'password' --credentials
Local discover is working (without "--account" and "--password" arguments).
I have tried to do discovery using msmart lib (https://github.com/mac-zhou/midea-msmart) and got the same error but with more info:
ValueError: (1006, '[email protected] value is illegal.')
Tried with china server/proxied and phone number/email.
Log:
2023-08-02 08:35:37 mideacontrol midea_beautiful[6923] DEBUG Library version=0.9.15
2023-08-02 08:35:37 mideacontrol midea_beautiful.cloud[6923] DEBUG HTTP request /v1/multicloud/platform/user/route: {'x-recipe-app': '1010', 'Authorization': 'Basic ********************************************************', 'sign': 'f2c73eee6c6d166bbff82a417f47acc4e1cc285c3c62e8a130762cb7817fda74', 'secretVersion': '1', 'random': '1690965337', 'version': '2.22.0', 'systemVersion': '8.1.0', 'platform': '0', 'Accept-Encoding': 'identity', 'Content-Type': 'application/json'} {'appId': 1010, 'format': 2, 'clientType': 1, 'language': 'en_US', 'src': 1010, 'stamp': '20230802083537', 'userName': '[email protected]', 'appVNum': '2.22.0', 'appVersion': '2.22.0', 'clientVersion': '2.22.0', 'platformId': '1', 'reqId': 'e0e0e38a70ea17bdbe9a755e4047b72c', 'retryCount': '3', 'uid': '', 'userType': '0'}
2023-08-02 08:35:37 mideacontrol urllib3.connectionpool[6923] DEBUG Starting new HTTPS connection (1): mp-prod.appsmb.com:443
2023-08-02 08:35:38 mideacontrol urllib3.connectionpool[6923] DEBUG https://mp-prod.appsmb.com:443 "POST /mas/v5/app/proxy?alias=/v1/multicloud/platform/user/route HTTP/1.1" 200 168
2023-08-02 08:35:38 mideacontrol midea_beautiful.cloud[6923] DEBUG HTTP response text: {"msg":"ok","code":0,"data":{"masUrl":"https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=","sseUrl":"https://sse.msmartlife.net","idAdapt":"131329","countryCode":"HK"}}
2023-08-02 08:35:38 mideacontrol midea_beautiful.cloud[6923] DEBUG HTTP response: {'msg': 'ok', 'code': 0, 'data': {'masUrl': 'https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=', 'sseUrl': 'https://sse.msmartlife.net', 'idAdapt': '131329', 'countryCode': 'HK'}}
2023-08-02 08:35:38 mideacontrol midea_beautiful.cloud[6923] DEBUG using key='data', result={'masUrl': 'https://mp-prod.appsmb.com/mas/v5/app/proxy?alias=', 'sseUrl': 'https://sse.msmartlife.net', 'idAdapt': '131329', 'countryCode': 'HK'}
2023-08-02 08:35:38 mideacontrol midea_beautiful.cloud[6923] DEBUG HTTP request /v1/user/login/id/get: {'x-recipe-app': '1010', 'Authorization': 'Basic ********************************************************', 'sign': '63a766c37601fd23ed6125cc26d7fbfb142dbd575ca61bfc15fc51717d4c7bdc', 'secretVersion': '1', 'random': '1690965338', 'version': '2.22.0', 'systemVersion': '8.1.0', 'platform': '0', 'Accept-Encoding': 'identity', 'Content-Type': 'application/json'} {'appId': 1010, 'format': 2, 'clientType': 1, 'language': 'en_US', 'src': 1010, 'stamp': '20230802083538', 'loginAccount': '[email protected]', 'appVNum': '2.22.0', 'appVersion': '2.22.0', 'clientVersion': '2.22.0', 'platformId': '1', 'reqId': 'e603d06e5917e4c5e0e7ff27a4103a54', 'retryCount': '3', 'uid': '', 'userType': '0'}
2023-08-02 08:35:38 mideacontrol urllib3.connectionpool[6923] DEBUG Starting new HTTPS connection (1): mp-prod.appsmb.com:443
2023-08-02 08:35:38 mideacontrol urllib3.connectionpool[6923] DEBUG https://mp-prod.appsmb.com:443 "POST /mas/v5/app/proxy?alias=/v1/user/login/id/get HTTP/1.1" 200 41
2023-08-02 08:35:38 mideacontrol midea_beautiful.cloud[6923] DEBUG HTTP response text: {"code":"3004","msg":"value is illegal."}
2023-08-02 08:35:38 mideacontrol midea_beautiful.cloud[6923] DEBUG HTTP response: {'code': '3004', 'msg': 'value is illegal.'}
2023-08-02 08:35:38 mideacontrol midea_beautiful.cloud[6923] DEBUG Restarting session: '3004' - 'value is illegal.'
If you need any additional info I will try my best to provide it.
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.