AlexxIT / XiaomiGateway3

Home Assistant custom component for control Xiaomi Multimode Gateway (aka Gateway 3), Xiaomi Multimode Gateway 2, Aqara Hub E1 on default firmwares over LAN
https://github.com/AlexxIT/Blog
MIT License
2.42k stars 340 forks source link

Add support VRF Air Conditioning #113

Open a007007007csy opened 3 years ago

a007007007csy commented 3 years ago

After I turned the [Xiaomi Gateway 3 Firmware Lock] switch on, the gateway seems disconnected from the Internet. No matter how I change the Firmware Lock status or restart the gateway, it's always offline in the Mi Home app. So I couldn't connect to any of BLE devices without the Internet right now.

a007007007csy commented 3 years ago

Devices:

  1. ZNDMWG03LM (Chinese version, US plug): v1.4.4_0003 factory firmware -- Cannot work in MiHome App while controlled by HA
  2. WXKG01LM -- Working fine
  3. Xiaomi TH Sensor 2 (LYWSD03MMC) -- Not working
2020-11-20 00:18:46 ERROR (MainThread) [custom_components.xiaomi_gateway3.core.xiaomi_cloud] Can't load devices list
Traceback (most recent call last):
  File "/config/custom_components/xiaomi_gateway3/core/xiaomi_cloud.py", line 145, in get_devices
    assert resp['code'] == 0, resp
AssertionError: {'code': 4, 'message': 'auth err'}
2020-11-20 00:18:47 ERROR (MainThread) [custom_components.xiaomi_gateway3.core.xiaomi_cloud] Can't load devices list
Traceback (most recent call last):
  File "/config/custom_components/xiaomi_gateway3/core/xiaomi_cloud.py", line 145, in get_devices
    assert resp['code'] == 0, resp
AssertionError: {'code': 4, 'message': 'auth err'}
2020-11-20 00:18:47 ERROR (MainThread) [custom_components.xiaomi_gateway3] Can't load devices from MiCloud
AlexxIT commented 3 years ago
  1. You have some problems with Xiaomi cloud.
  2. Maybe 1.4.4_0003 have some problems, I don't know. Update to new supported version. Check list in readme.
  3. BLE don't work without connection to cloud on original firmware
a007007007csy commented 3 years ago
  1. You have some problems with Xiaomi cloud.
  2. Maybe 1.4.4_0003 have some problems, I don't know. Update to new supported version. Check list in readme.
  3. BLE don't work without connection to cloud on original firmware

@AlexxIT Thank you for your useful advice. By testing, my Xiaomi_gateway3, Zigbee devices, and BLE devices are all successfully connected to HA, the gateway could working with HA and MiHome APP simultaneously! Now my gateway's firmware is v1.4.5_0016, This can be confirmed that v1.4.4_0003 was not well supported, you could inform guys on the readme page.

a007007007csy commented 3 years ago

Here's a VRF air condition controller that supports connecting to MI Home App with Zigbee protocol. Now the device can be recognized in HA, I'm still in testing.

Xiaomi Gateway 3
New device:
did: lumi.<>
mac: <>
model: lumi.airrtc.vrfegl01
version: 1
zb_ver: 1.2
superwangmeng commented 2 years ago

@a007007007csy is it support VRF now?

AlexxIT commented 2 years ago

@superwangmeng No. If you have it - enable logs in integration options. Control device in different ways and send this logs to me.

xrh0905 commented 2 years ago

@superwangmeng No. If you have it - enable logs in integration options. Control device in different ways and send this logs to me.

2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | zigbee/recv b'{"cmd":"write","did":"lumi.158d000798399c","id":9,"params":[{"res_name":"14.1.85","value":2103876}],"source":"","time":1640664454916}'
2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | gw/B4E3F9FFFEB6CEF8/commands b'{"commands":[{"commandcli":"zcl mfg-code 0x115f"},{"commandcli":"zcl global write 0x0000 0xfff0 0x41 {aa800cca47218527441a200001010000}"},{"commandcli":"send 0xb496 1 1","postDelayMs":0}]}'
2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | gw/B4E3F9FFFEB6CEF8/executed b'{"command":"zcl mfg-code 0x115f"}'
2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | log/z3 b'Msg: clus 0x0000, cmd 0x02, len 25\r'
2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | log/z3 b'buffer: 14 5F 11 08 02 F0 FF 41 10 AA 80 0C CA 47 21 85 27 44 1A 20 00 01 01 00 00 \r'
2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | zigbee/send b'{"cmd":"write_rsp","id":9,"time":1640664454934,"did":"lumi.158d000798399c","zseq":248,"results":[{"res_name":"14.1.85","value":2103876,"error_code":0}]}'
2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | gw/B4E3F9FFFEB6CEF8/executed b'{"command":"zcl global write 0x0000 0xfff0 0x41 {aa800cca47218527441a200001010000}"}'
2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | gw/B4E3F9FFFEB6CEF8/MessagePreSentCallback b'{"eui64":"0x00158D000798399C","destinationEndpoint":"0x01","clusterId":"0x0000","profileId":"0x0104","sourceEndpoint":"0x01","APSCounter":"0x76","APSPlayload":"0x145F110802F0FF4110AA800CCA47218527441A200001010000"}'
2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | gw/B4E3F9FFFEB6CEF8/executed b'{"command":"send 0xb496 1 1"}'
2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | gw/B4E3F9FFFEB6CEF8/MessageReceived b'{"sourceAddress":"0xB496","eui64":"0x00158D000798399C","destinationEndpoint":"0x01","clusterId":"0x0000","profileId":"0x0104","sourceEndpoint":"0x01","APSCounter":"0x71","APSPlayload":"0x1C5F11080400","rssi":-15,"linkQuality":255}'
2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | zigbee/send b'{"cmd":"write_ack","id":9,"did":"lumi.158d000798399c","dev_src":"0","time":1640664455035,"rssi":-15,"zseq":8,"params":[{"res_name":"14.1.85","value":2103876},{"res_name":"13.1.85","value":1}]}'
2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | gw/B4E3F9FFFEB6CEF8/MessageReceived b'{"sourceAddress":"0xB496","eui64":"0x00158D000798399C","destinationEndpoint":"0x01","clusterId":"0x0000","profileId":"0x0104","sourceEndpoint":"0x01","APSCounter":"0x72","APSPlayload":"0x1C5F11F90AF0FF4110AA800CCA871D8527441A2000010A0000","rssi":-15,"linkQuality":255}'
2021-12-28 12:07:36  DEBUG    gateway3      192.168.2.66 | MQTT | zigbee/send b'{"cmd":"report","id":9,"did":"lumi.158d000798399c","time":1640664455073,"rssi":-15,"zseq":249,"params":[{"res_name":"14.1.85","value":2103876},{"res_name":"13.1.85","value":10}],"dev_src":"0"}'
2021-12-28 12:07:40  DEBUG    gateway3      192.168.2.66 | MQTT | gw/B4E3F9FFFEB6CEF8/MessageReceived b'{"sourceAddress":"0xB496","eui64":"0x00158D000798399C","destinationEndpoint":"0x01","clusterId":"0x0000","profileId":"0x0104","sourceEndpoint":"0x01","APSCounter":"0x73","APSPlayload":"0x1C5F11FA0AF0FF4110AA800CCA871D8527441A2000010A0000","rssi":-15,"linkQuality":255}'
2021-12-28 12:07:40  DEBUG    gateway3      192.168.2.66 | MQTT | zigbee/send b'{"cmd":"report","id":9,"did":"lumi.158d000798399c","time":1640664459073,"rssi":-15,"zseq":250,"params":[{"res_name":"14.1.85","value":2103876},{"res_name":"13.1.85","value":10}],"dev_src":"0"}'

Turn Off AC at Address 1-0 Temperature Set at 26 Fanspeed High Mode Heating

xrh0905 commented 2 years ago

@AlexxIT

vincenthsing commented 1 year ago

全网都没有适配这个设备的插件,homekit controller也只能控制关闭空调,打开完全没反应~

uavana commented 1 year ago

I got my VRF air conditioning controlled by AlexxIT gateway3 module first get devices count from 13.1.85 then control AC by 14.[1-count].85

eg: my 13.1.85=7 so i have
14.1.85 14.2.85 14.3.85 14.4.85 14.5.85 14.6.85 14.7.85 i can read write my 7 AC by these mi spec

hvac and fan enum vaules: hvac = {HVAC_MODE_HEAT: 0, HVAC_MODE_COOL: 1, HVAC_MODE_DRY: 3, HVAC_MODE_FAN_ONLY: 4} fan = {FAN_LOW: 0, FAN_MEDIUM: 1, FAN_HIGH: 2, FAN_AUTO: 3}

first read: _raw = self._raw = data["_raw"] self._enabled = True if _raw >> 28 == 1 else False self._attr_fan_mode = list(self.fan.keys())[list(self.fan.values()).index(_raw >> 20 & 0xF)] self._mode = list(self.hvac.keys())[list(self.hvac.values()).index(_raw >> 24 & 0xF)] self._attr_target_temperature = _raw >> 8 & 0xFFF

then write: _raw = self._raw power_val = _raw >> 28 hvac_val = _raw >> 24 & 0xF fan_val = _raw >> 20 & 0xF temp_val = _raw >> 8 & 0xFFF extra_val = _raw & 0xFF

if "climate" in value: power_val = (1 if value["climate"] else 0) elif "hvac_mode" in value: power_val = 1 hvac_val = self.hvac[value["hvac_mode"]] elif "fan_mode" in value: fan_val = self.fan[value["fan_mode"]] elif "target_temp" in value: temp_val = int(value["target_temp"]) _raw = power_val << 28 ^ hvac_val << 24 ^ fan_val << 20 ^ temp_val << 8 ^ extra_val

then we can read write power & hvac mode & target temperature & fan mode last 8bit maybe it's swing mode, i will figure it out later

dengke80622 commented 9 months ago

actually, this device can also use http get to obtain status and send commands. This method has limitations because there's not lan port aside rs485 panel, I use a network bridge to connect vrf controller into home network. Finally I use nodered to send/obtain commands. The powerline networking adapter maybe another choice.