Skip to content

Commit 3419035

Browse files
committed
Refactor Xiaomi fan profile to remove fanSpeedPercent and enhance profile detection
- Removed the fanSpeedPercent property from the Xiaomi fan profile for simplification. - Updated profile_builder.lua to check for speed_level support in fan devices, returning the appropriate profile for better compatibility.
1 parent cb2407a commit 3419035

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: xiaomi-fan
2+
components:
3+
- id: main
4+
capabilities:
5+
- id: switch
6+
version: 1
7+
- id: fanSpeed
8+
version: 1
9+
- id: fanSpeedPercent
10+
version: 1
11+
- id: fanOscillationMode
12+
version: 1
13+
- id: dictionaryangel05655.fanMode
14+
version: 1
15+
- id: refresh
16+
version: 1
17+
categories:
18+
- name: Fan
19+
preferences:
20+
- title: "Device Token"
21+
name: token
22+
required: true
23+
preferenceType: string
24+
definition:
25+
stringType: text
26+
default: ""

xiaomi-miot/profiles/xiaomi-fan.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ components:
66
version: 1
77
- id: fanSpeed
88
version: 1
9-
- id: fanSpeedPercent
10-
version: 1
119
- id: fanOscillationMode
1210
version: 1
1311
- id: dictionaryangel05655.fanMode

xiaomi-miot/src/profile_builder.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ function M.get_profile_for_model(model)
4747
if device_type == "air-purifier" and spec.properties and spec.properties.pm25 then
4848
return "xiaomi-air-purifier-pm25"
4949
end
50+
-- For fans, check if speed_level is supported
51+
if device_type == "fan" and spec.properties and spec.properties.speed_level then
52+
return "xiaomi-fan-percent"
53+
end
5054
else
5155
-- Fallback: infer from model name
5256
if model:find("light") or model:find("lamp") or model:find("ceiling") then

0 commit comments

Comments
 (0)