美的wifi智能空调接入homeassistant和homekit的教程

前言

如果觉得一楼的方法操作不了或者你的空调是接入美居的中央空调类,直接跳到二楼的教程操作。

分体美的美居空调接入办法

插件原文

  • 这个办法做做一直在更新,如果不追求稳定性可以帮忙测试,它是支持局域网协议的。
  1. 20220713之后购买的智趣盒子内置了midea lan这个插件,不需要安装直接跳到第4步
  2. 20220712之前的智趣盒子,手动在hacs商店搜索Midea AC LAN,把插件下载到盒子,然后重启home-assistant
  3. 20220712之前的智趣盒子,如果在hacs商店搜索不到Midea AC LAN,那么下载附件的文件包,解压之后,从midea_ac_lan-masterl-custom_components文件夹里面把midea_ac_lan这个文件夹复制到盒子的
    config-custom_components文件夹里面,然后重启home-assistant。
    midea_ac_lan-master.zip (31.3 KB)
  4. 从8123管理界面进入,左侧栏【配置】-【设备与服务】-【添加集成】,搜索Midea AC LAN





  5. Midea AC LAN配置美的美居空调,基本自动识别局域网内的空调,


注意:

如果需要添加多台空调,再重复4-5这两个步骤。

  1. 使用遥控器逐个测试接入的空调,给他们分配区域和自定义命名

手动写代码的方法

  1. 智趣盒子2021.5.17以后版本已经内置了msmart工具,之前所有版本都预设了midea ac插件。
  2. 美的的空调,wifi版本的,如果是v2协议的,应该都可以接入。但是型号太多,没有逐个验证。
  3. 应该20年以前的wifi空调都是v2协议的,貌似最近新的空调是v3版本的。v3版本,插件作者还没有更新支持。
  4. 插件原地址:

https://github.com/mac-zhou/midea-ac-py/blob/master/中文.md#

具体步骤

  1. 打开ssh,链接到盒子后台,输入一下命令,获取空调的ip和id:
apt install python3-pip
apt-get install python3-setuptools
pip3 install msmart
# 智趣盒子用户只需要输入这一条(上面的命令不用输入):
midea-discover





  1. 配置美的空调的接入文件信息



climate:
  - platform: midea_ac
    host: 192.168.xx.52
    id: 1627xxxx128683

上面的代码的host和id,记得改为自己对应的。

  1. 重启home assistant,让配置生效。


  2. homeassistant重新启动后,检查是否接入成功,一般会命名为:

  • climate.midea_ac_xxxxxxx

  1. 对接进入homekit——如果之前已经把homeassistant对接进入homekit,新添加的设备,会在homekit自动出现。

第二章 美的能接入美居的空调通过 climate_ewelink插件接入

智趣盒子默认内置,不需要下载插件,直接跳到第二步

原帖地址

一、具体操作方式:

  1. 下载附件的工具包,解压,得到climate_ewelink-main文件夹,把里面的custom_components/climate_ewelink文件通过samba文件管理器,放到盒子的:config/custom_components里面。这个一定要放对!!放好之后重启homeassistant core。

  2. 在手机下载易微联app,然后在易微联app里面,把美居的账号绑定,然后看看易微联app是否可以控制空调。
  3. 重启homeassistant core 之后,进入集成,添加搜ewelink,选择第二个。添加账号的时候,如果是电话号码做账号,千万别漏了电话号码前面+86


  4. 点击x个设备,修改空调的相关信息:

  5. 接入homekit,按照一楼的教程操作即可。

climate_ewelink-main.zip (15.3 KB)

1 个赞

怎么更新msmart啊

萝卜大佬,美的的洗衣机、烘干机,有插件可以接入吗?

3 个赞

同求 你接入成功了嘛!

两种方法,方法二易微联是不是不能本地执行?就是断网就没用了?

易微联的不能断网。

如果使用第一种方法,有3台空调的话,第二步:把配置代码复制到刚刚新建的yaml文件,是不是要建立3个yaml文件?还是只要建立一个,把三台空调的都复制进去?

使用方法一,输入:midea-dicover, 显示错误啊。
Last login: Mon Apr 4 16:00:02 2022 from 127.0.0.1

root@smarthomefansbox:~# midea-discover
INFO:msmart.cli:msmart version: 0.1.35 Currently only supports ac devices.
INFO:msmart.cli:Sending Device Scan Broadcast…
Traceback (most recent call last):
File “/usr/local/bin/midea-discover”, line 10, in
sys.exit(discover())
File “/usr/local/lib/python3.7/dist-packages/click/core.py”, line 1128, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python3.7/dist-packages/click/core.py”, line 1053, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python3.7/dist-packages/click/core.py”, line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python3.7/dist-packages/click/core.py”, line 754, in invoke
return __callback(*args, **kwargs)
File “/usr/local/lib/python3.7/dist-packages/msmart/cli.py”, line 43, in discover
found_devices = loop.run_until_complete(discovery.get_all())
File “/usr/lib/python3.7/asyncio/base_events.py”, line 584, in run_until_complete
return future.result()
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 179, in get_all
[self.result.add(task.result()) for task in tasks]
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 179, in
[self.result.add(task.result()) for task in tasks]
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 42, in support_test
_device = await self.support_testv3(account, password)
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 57, in support_testv3
token, key = await loop.run_in_executor(None, gettoken, udpid, account, password)
File “/usr/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 234, in gettoken
Client.login()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 120, in login
‘password’: self.security.encryptPassword(self.login_id, self.password)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 86, in api_request
self.handle_api_error(int(response[‘errorCode’]), response[‘msg’])
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 233, in handle_api_error
handler()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 211, in restart_full
self.login()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 120, in login
‘password’: self.security.encryptPassword(self.login_id, self.password)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 86, in api_request
self.handle_api_error(int(response[‘errorCode’]), response[‘msg’])
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 233, in handle_api_error
handler()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 211, in restart_full
self.login()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 120, in login
‘password’: self.security.encryptPassword(self.login_id, self.password)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 86, in api_request
self.handle_api_error(int(response[‘errorCode’]), response[‘msg’])
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 233, in handle_api_error
handler()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 211, in restart_full
self.login()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 120, in login
‘password’: self.security.encryptPassword(self.login_id, self.password)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 86, in api_request
self.handle_api_error(int(response[‘errorCode’]), response[‘msg’])
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 233, in handle_api_error
handler()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 219, in throw
raise ValueError(error_code, message)
ValueError: (3101, ‘password error,please enter again.’)
ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<scandevice.support_test() done, defined at /usr/local/lib/python3.7/dist-packages/msmart/scanner.py:40> exception=ValueError(3101, ‘password error,please enter again.’)>
Traceback (most recent call last):
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 42, in support_test
_device = await self.support_testv3(account, password)
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 57, in support_testv3
token, key = await loop.run_in_executor(None, gettoken, udpid, account, password)
File “/usr/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 234, in gettoken
Client.login()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 120, in login
‘password’: self.security.encryptPassword(self.login_id, self.password)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 86, in api_request
self.handle_api_error(int(response[‘errorCode’]), response[‘msg’])
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 233, in handle_api_error
handler()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 211, in restart_full
self.login()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 120, in login
‘password’: self.security.encryptPassword(self.login_id, self.password)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 86, in api_request
self.handle_api_error(int(response[‘errorCode’]), response[‘msg’])
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 233, in handle_api_error
handler()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 211, in restart_full
self.login()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 120, in login
‘password’: self.security.encryptPassword(self.login_id, self.password)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 86, in api_request
self.handle_api_error(int(response[‘errorCode’]), response[‘msg’])
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 233, in handle_api_error
handler()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 219, in throw
raise ValueError(error_code, message)
ValueError: (3101, ‘password error,please enter again.’)
ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<scandevice.support_test() done, defined at /usr/local/lib/python3.7/dist-packages/msmart/scanner.py:40> exception=ValueError(3101, ‘password error,please enter again.’)>
Traceback (most recent call last):
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 42, in support_test
_device = await self.support_testv3(account, password)
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 57, in support_testv3
token, key = await loop.run_in_executor(None, gettoken, udpid, account, password)
File “/usr/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 234, in gettoken
Client.login()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 120, in login
‘password’: self.security.encryptPassword(self.login_id, self.password)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 91, in api_request
return self.api_request(endpoint, args)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 86, in api_request
self.handle_api_error(int(response[‘errorCode’]), response[‘msg’])
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 233, in handle_api_error
handler()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 211, in restart_full
self.login()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 120, in login
‘password’: self.security.encryptPassword(self.login_id, self.password)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 86, in api_request
self.handle_api_error(int(response[‘errorCode’]), response[‘msg’])
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 233, in handle_api_error
handler()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 211, in restart_full
self.login()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 120, in login
‘password’: self.security.encryptPassword(self.login_id, self.password)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 91, in api_request
return self.api_request(endpoint, args)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 91, in api_request
return self.api_request(endpoint, args)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 91, in api_request
return self.api_request(endpoint, args)
[Previous line repeated 124 more times]
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 86, in api_request
self.handle_api_error(int(response[‘errorCode’]), response[‘msg’])
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 233, in handle_api_error
handler()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 211, in restart_full
self.login()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 120, in login
‘password’: self.security.encryptPassword(self.login_id, self.password)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 86, in api_request
self.handle_api_error(int(response[‘errorCode’]), response[‘msg’])
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 233, in handle_api_error
handler()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 219, in throw
raise ValueError(error_code, message)
ValueError: (3101, ‘password error,please enter again.’)
ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<scandevice.support_test() done, defined at /usr/local/lib/python3.7/dist-packages/msmart/scanner.py:40> exception=ValueError(3101, ‘password error,please enter again.’)>
Traceback (most recent call last):
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 42, in support_test
_device = await self.support_testv3(account, password)
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 57, in support_testv3
token, key = await loop.run_in_executor(None, gettoken, udpid, account, password)
File “/usr/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.7/dist-packages/msmart/scanner.py”, line 234, in gettoken
Client.login()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 120, in login
‘password’: self.security.encryptPassword(self.login_id, self.password)
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 86, in api_request
self.handle_api_error(int(response[‘errorCode’]), response[‘msg’])
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 233, in handle_api_error
handler()
File “/usr/local/lib/python3.7/dist-packages/msmart/cloud.py”, line 219, in throw
raise ValueError(error_code, message)
ValueError: (3101, ‘password error,please enter again.’)
root@smarthomefansbox:~#

你的空调不支持本地接入

商店中已经没有该插件了 只有易微连的

我用方法二添加成功了,易微联app也能控制,但是在HA里控制不了,显示错误如图“屏幕截图 2022-06-09 003135 ”,也没有日志信息

你删除这集成,重新添加看看行不行,要确保易微联能控制。

方法二搞定了,集成添加前从易微联APP退出登录,不要选教程里那个Climate via eWeLink(会出现能添加,但不能控制), 要选 Midea A/C via eWeLink 才能控制,这里给各位提个醒,集成登录的账户名一般是手机号前面要填+86才不会报错。

是不是集成改了,后面教程更新一下。

mac-zhou大佬的项目,已经支持v3了,前天刚验证了

v3怎么用啊,一直搞不明白啊

一样的,用midea-discover命令,但是跟作者说的 组件仅支持输出中具有型号0xac(空调)和单词的设备。 supported 这句对不上,起码我的就没有依然能被支持。

我实测是不一定一次输入midea-discover就能生效,但是第二遍就有了一堆输出,

里面有mode 3 字样,然后有tokenkey和这种v3版本需要的信息,但是token和key每次查询都不同,这里issue里有提到,就算不同也没关系,每一个都能用。

接着把v2v3都需要的id和ip填上,就ok了。

然后有个坑,我用作者验证的2021.7.2和我自用的2022.5.4和2022.6.4都测试过,初次增加这个项目的midea的climate代码,hass验证代码一直转圈,也不报错,也不给过验证,前端重启不了,我直接后台重启了容器,没问题,再去检查代码直接过了。

还有就是2022.6.4我看到过log有midea报错,看不懂没管。但是没影响我使用

萝卜大佬,美的微波炉支持接入homeassistant不?微波炉型号是X3-233A,这个微波炉是可以WiFi接入美的美居的,看能不能接入到homeassistant里去


找不到