Skip to content

Commit

Permalink
Merge pull request #318 from georgezhao2010/dev
Browse files Browse the repository at this point in the history
Dev PR
  • Loading branch information
georgezhao2010 authored Sep 20, 2023
2 parents 60b987f + a0f35cf commit f06b9fc
Show file tree
Hide file tree
Showing 74 changed files with 1,783 additions and 663 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
sensitive/

#exclude
custom_components/midea_ac_lan/midea/devices/bc/
custom_components/midea_ac_lan/midea/devices/b2/
custom_components/midea_ac_lan/midea/devices/b4/
custom_components/midea_ac_lan/midea/devices/b9/
Wcustom_components/midea_ac_lan/midea/devices/b7/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ And more.
| AC | Air Conditioner | [AC.md](doc/AC.md) |
| B0 | Microwave Oven | [B0.md](doc/B0.md) |
| B1 | Electric Oven | [B1.md](doc/B1.md) |
| B3 | Dish Sterilizer | [B3.md](doc/B3.md) |
| B4 | Toaster | [B4.md](doc/B4.md) |
| B6 | Range Hood | [B6.md](doc/B6.md) |
| BF | Microwave Steam Oven | [BF.md](doc/BF.md) |
| C2 | Toilet | [C2.md](doc/C2.md) |
Expand All @@ -53,6 +55,7 @@ And more.
| E2 | Electric Water Heater | [E2.md](doc/E2.md) |
| E3 | Gas Water Heater | [E3.md](doc/E3.md) |
| E6 | Gas Stove | [E6.md](doc/E6.md) |
| E8 | Electric Slow Cooker | [E8.md](doc/E8.md) |
| EA | Electric Rice Cooker | [EA.md](doc/EA.md) |
| EC | Electric Pressure Cooker | [EC.md](doc/EC.md) |
| ED | Water Drinking Appliance | [ED.md](doc/ED.md) |
Expand All @@ -73,6 +76,8 @@ After installation, search and add component Midea AC LAN in Home Assistant inte

Or click [![Configuration](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start?domain=midea_ac_lan)

***Note: During the configuration process, you may be asked to enter your Midea account and password. It's necessary to retrieve appliance information (Token and Key) from Midea cloud server. After all appliances configured, you can remove the Midea account configuration without affecting the use of the appliance.***

## Automatically
This component could auto-discover and list Midea M-Smart appliances in network, select one and add it in. You could repeat the above action to add multiple devices.

Expand Down
5 changes: 5 additions & 0 deletions README_hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
| AC | 空调器 | [AC_hans.md](doc/AC_hans.md) |
| B0 | 微波炉 | [B0_hans.md](doc/B0_hans.md) |
| B1 | 电烤箱 | [B1_hans.md](doc/B1_hans.md) |
| B3 | 消毒碗柜 | [B3_hans.md](doc/B3_hans.md) |
| B4 | 小烤箱 | [B4_hans.md](doc/B4_hans.md) |
| B6 | 油烟机 | [B6_hans.md](doc/B6_hans.md) |
| BF | 微蒸烤一体机 | [BF_hans.md](doc/BF_hans.md) |
| C2 | 智能马桶 | [C2_hans.md](doc/C2_hans.md) |
Expand All @@ -53,6 +55,7 @@
| E2 | 电热水器 | [E2_hans.md](doc/E2_hans.md) |
| E3 | 燃气热水器 | [E3_hans.md](doc/E3_hans.md) |
| E6 | 壁挂炉 | [E6_hans.md](doc/E6_hans.md) |
| E8 | 慢炖锅 | [E8_hans.md](doc/E8_hans.md) |
| EA | 电饭煲 | [EA_hans.md](doc/EA_hans.md) |
| EC | 电压力锅 | [EC_hans.md](doc/EC_hans.md) |
| ED | 饮用水设备 | [ED_hans.md](doc/ED_hans.md) |
Expand All @@ -73,6 +76,8 @@

或者直接点击 [![Configuration](https://my.home-assistant.io/badges/config_flow_start.svg)](https://my.home-assistant.io/redirect/config_flow_start?domain=midea_ac_lan)

***注意: 配置过程中,可能会要求输入你的美的账号及密码,这是因为需要去美的云服务器获取设备的信息 (Token and Key)。在完成所有设备配置后,可以删除美的账户配置,不影响设备的使用***

## 自动
自动配置会自动搜索网络上的美的M-Smart设备,并将搜索到的设备列出,选择一个设备执行添加。多台设备执行多次添加即可。

Expand Down
27 changes: 4 additions & 23 deletions custom_components/midea_ac_lan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import homeassistant.helpers.config_validation as cv
from .const import (
DOMAIN,
CONF_ACCOUNT,
CONF_KEY,
CONF_MODEL,
CONF_REFRESH_INTERVAL,
Expand Down Expand Up @@ -63,15 +64,6 @@ async def async_setup(hass: HomeAssistant, hass_config: dict):
if attribute.get("type") in EXTRA_SWITCH and attribute_name.value not in attributes:
attributes.append(attribute_name.value)

def service_set_ac_fan_speed(service):
device_id = service.data.get("device_id")
fan_speed = service.data.get("fan_speed")
if fan_speed == "auto":
fan_speed = 102
dev = hass.data[DOMAIN][DEVICES].get(device_id)
if dev and dev.device_type == 0xac:
dev.set_attribute(attr="fan_speed", value=fan_speed)

def service_set_attribute(service):
device_id = service.data.get("device_id")
attr = service.data.get("attribute")
Expand Down Expand Up @@ -100,19 +92,6 @@ def service_send_command(service):
if dev:
dev.send_command(cmd_type, cmd_body)

hass.services.async_register(
DOMAIN,
"set_ac_fan_speed",
service_set_ac_fan_speed,
schema=vol.Schema(
{
vol.Required("device_id"): vol.Coerce(int),
vol.Required("fan_speed"): vol.Any(vol.All(vol.Coerce(int), vol.Range(min=1, max=100)),
vol.All(str, vol.In(["auto"])))
}
)
)

hass.services.async_register(
DOMAIN,
"set_attribute",
Expand Down Expand Up @@ -142,11 +121,13 @@ def service_send_command(service):


async def async_setup_entry(hass: HomeAssistant, config_entry):
device_type = config_entry.data.get(CONF_TYPE)
if device_type == CONF_ACCOUNT:
return True
name = config_entry.data.get(CONF_NAME)
device_id = config_entry.data.get(CONF_DEVICE_ID)
if name is None:
name = f"{device_id}"
device_type = config_entry.data.get(CONF_TYPE)
if device_type is None:
device_type = 0xac
token = config_entry.data.get(CONF_TOKEN)
Expand Down
Loading

0 comments on commit f06b9fc

Please sign in to comment.