Giter Club home page Giter Club logo

midea-ac-py's Introduction

English Version | 中文版

This is a custom component for Home Assistant to integrate the Midea Air Conditioners via the Local area network.

Tested with hass version 0.110.2

Installation

Install from HACS

Type hacs_badge

Search the HACS Store for midea_ac

Install manually

  1. Clone this repo
  2. Place the custom_components/midea_ac folder into your custom_components folder

Configuration

Configuration variables:

key description example
platform (Required) The platform name. midea_ac
host (Required) Midea AC Device's IP Address. 192.168.1.100
id (Required) Midea AC Device's applianceId. 123456789012345
use_fan_only_workaround (Optional) Set this to true if you need to turn off device updates because they turn device on and to fan_only true

How to Get applianceId:

  • you can use command midea-discover to discover midea devices on the host in the same Local area network. Note: This component only supports devices with model 0xac (air conditioner) and words supported in the output.
pip3 install msmart
midea-discover
  • if you use Midea Air app outside China, there is a easy way to get your deviceid.
  1. open Midea Air app, and share the device, you will get a QR Code.
  2. save the QR Code
  3. upload QR Code Sreenshort to https://zxing.org/w/decode.jspx or decode QR code use other tool.
  4. you will get the data like MADEVICESHARE:<base64_string>
  5. decode base64 string online https://www.base64decode.org/ or use other tool
  6. you will get the device id
  • if you use android, you can use adb,filter from log:
adb logcat | grep -i deviceid
  • if you use iPhone,iPhone connects to macOS with a data cable and filters the applianceId from the console log

  • If you do not have the above environment and conditions, you need to capture the air conditioner and save the files, after can be used pcap-decrypt.py to Get. Remember to use the number, not hex string.

Example configuration.yaml:

  • Single device
climate:
  - platform: midea_ac
    host: 192.168.1.100
    id: 123456789012345
  • Multiple device
climate:
  - platform: midea_ac
    host: 192.168.1.100
    id: 123456789012345
  - platform: midea_ac
    host: 192.168.1.200
    id: 543210987654321

Buy me a cup of coffee to help maintain this project further?

Your donation will make me work better for this project.

midea-ac-py's People

Contributors

aa755 avatar andersonshatch avatar j0nathan33 avatar jchasey avatar jyz0501 avatar mac-zhou avatar neoacheron avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

midea-ac-py's Issues

Error while setting up midea_ac

I have such a problem. Anyone can help?

2021-07-14 00:12:01 ERROR (MainThread) [homeassistant.components.climate] Error while setting up midea_ac platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 250, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/midea_ac/climate.py", line 75, in async_setup_platform
    device = ac(device_ip, int(device_id))
TypeError: __init__() missing 1 required positional argument: 'device_port'

Problems with fake cloud script.

Hi
I am not sure that this is a bug.
I am using a Midea AC Mobile 35C with Home Assistant 2024.4.2 and the HACS integration midea_ac_lan.
I didn't know that cloud access is still needed, but there's your fake cloud script.
As per the instructions, I have set up the redirection on my OpenWRT router and tested it with nslookup, resulting in:

Server:  openwrt
Address:  192.168.11.254

Name:    module.appsmb.com
Address:  192.168.11.2

I downloaded the Python script and set it up as a service, on my Home assistant server with Debian 12 resulting in:

$ sudo systemctl status fake-cloud
● fake-cloud.service - Fake Cloud Server for Midea AC
     Loaded: loaded (/etc/systemd/system/fake-cloud.service; enabled; preset: enabled)
     Active: active (running) since Sun 2024-06-09 15:07:06 CEST; 1 day 4h ago
   Main PID: 470 (python3)
      Tasks: 1 (limit: 8186)
     Memory: 9.8M
        CPU: 67ms
     CGroup: /system.slice/fake-cloud.service
             └─470 /usr/bin/python3 /usr/local/sbin/fake-cloud-wmp.py

I can see that my AC is connecting to the fake cloud server:

sudo netstat -anp | grep :443
tcp 0 0 192.168.11.2:443 0.0.0.0:* LISTEN 9826/python3
tcp 13 0 192.168.11.2:443 192.168.11.229:40003 VERBUNDEN 9826/python3

But a couple of minutes later, it becomes unavailable. Am I doing something wrong?
Or is my Midea not supported?

best
NihilUnum

Climate is "Unavailable"

While starting HA I sometimes see:

Aug 18 00:23:01 a2khome python3.7[1250]: 2020-08-18 00:23:01 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.midea_ac_20890720943210 fails
Aug 18 00:23:01 a2khome python3.7[1250]: Traceback (most recent call last):
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/homeassistant/helpers/entity.py", line 263, in async_update_ha_state
Aug 18 00:23:01 a2khome python3.7[1250]:     await self.async_device_update()
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/homeassistant/helpers/entity.py", line 454, in async_device_update
Aug 18 00:23:01 a2khome python3.7[1250]:     await self.async_update()  # type: ignore
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/homeassistant-config/custom_components/midea/climate.py", line 129, in async_update
Aug 18 00:23:01 a2khome python3.7[1250]:     await self.hass.async_add_executor_job(self._device.refresh)
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
Aug 18 00:23:01 a2khome python3.7[1250]:     result = self.fn(*self.args, **self.kwargs)
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/device.py", line 174, in refresh
Aug 18 00:23:01 a2khome python3.7[1250]:     self._send_cmd(cmd)
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/device.py", line 181, in _send_cmd
Aug 18 00:23:01 a2khome python3.7[1250]:     responses = self._lan_service.appliance_transparent_send_8370(data)
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/lan.py", line 84, in appliance_transparent_send_8370
Aug 18 00:23:01 a2khome python3.7[1250]:     self._authenticate()
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/lan.py", line 80, in _authenticate
Aug 18 00:23:01 a2khome python3.7[1250]:     raise error
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/lan.py", line 76, in _authenticate
Aug 18 00:23:01 a2khome python3.7[1250]:     tcp_key = self.security.tcp_key(response, self._key)
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/security.py", line 92, in tcp_key
Aug 18 00:23:01 a2khome python3.7[1250]:     raise Exception('unexpected data length')
Aug 18 00:23:01 a2khome python3.7[1250]: Exception: unexpected data length

When this happens the climate in HA is stuck in "Unavailable" state.
It seems that an error on integration start is not recoverable, so one needs to restart HA

TypeError: __init__() missing 1 required positional argument: 'device_port'

Describe the bug (描述一下问题)
I have installed today (07/23), cloning this repository and I am receiving the following message when hassio starts:

2021-07-23 12:57:16 ERROR (MainThread) [homeassistant.components.climate] Error while setting up midea_ac platform for climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/midea_ac/climate.py", line 73, in async_setup_platform
    device = ac(device_ip, int(device_id))
TypeError: __init__() missing 1 required positional argument: 'device_port'

Versions (版本信息)

  • Home Assistant version: core-2021.1.5
  • Midea msmart version:
    {
    "domain": "midea_ac",
    "name": "Midea Smart Aircon",
    "version": "0.0.0",
    "documentation": "",
    "requirements": ["git+https://github.com/kueblc/midea-msmart.git@support-8370#msmart", "pycryptodome", "midea"],
    "dependencies": [],
    "codeowners": ["@mac-zhou"]
    }

homeassistant Exception: authentication failed

homeassistant Error

Logger: homeassistant.components.climate
Source: custom_components/midea_ac/climate.py:73
Integration: 空调 (documentation, issues)
First occurred: 下午8:20:14 (1 occurrences)
Last logged: 下午8:20:14

Error while setting up midea_ac platform for climate
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 198, in _async_setup_platform
    await asyncio.shield(task)
  File "/home/luhaiyong/.homeassistant/custom_components/midea_ac/climate.py", line 73, in async_setup_platform
    device.authenticate(device_8370_only_ac_mac, device_8370_only_wifi_ssid, device_8370_only_wifi_pw)
  File "/usr/local/lib/python3.9/site-packages/msmart/device.py", line 43, in authenticate
    self._authenticate()
  File "/usr/local/lib/python3.9/site-packages/msmart/device.py", line 46, in _authenticate
    self._lan_service.authenticate(self._mac, self._wifi_ssid, self._wifi_pw)
  File "/usr/local/lib/python3.9/site-packages/msmart/lan.py", line 68, in authenticate
    self._authenticate()
  File "/usr/local/lib/python3.9/site-packages/msmart/lan.py", line 80, in _authenticate
    raise error
  File "/usr/local/lib/python3.9/site-packages/msmart/lan.py", line 76, in _authenticate
    tcp_key = self.security.tcp_key(response, self._key)
  File "/usr/local/lib/python3.9/site-packages/msmart/security.py", line 90, in tcp_key
    raise Exception('authentication failed')
Exception: authentication failed

MyConfig
————————————————————————————
climate:

  • platform: midea_ac
    host: 192.168.8.219
    id: 162727722342346
    8370_only_ac_mac: A0681C272AA7
    8370_only_wifi_ssid: iK
    8370_only_wifi_pw: Lhy19941011.
    ————————————————————————————

Versions (版本信息)

  • Home Assistant version: Home Assistant 2021.2.3
  • Midea msmart version: 0.1.20

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.