Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Xiaomi Smart Tower Fan #225

Merged
merged 4 commits into from
Jul 20, 2023

Conversation

paranerd
Copy link
Contributor

@paranerd paranerd commented Jul 19, 2023

Added support for Xiaomi Smart Tower Fan (dmaker.fan.p39)

For reference:
API overview: https://home.miot-spec.com/spec/dmaker.fan.p39
Spec: https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p39:1

Fixes #213
Fixes #223

@syssi
Copy link
Owner

syssi commented Jul 20, 2023

Could you use black to format your changes? Thanks in advance!

@paranerd
Copy link
Contributor Author

@syssi
Copy link
Owner

syssi commented Jul 20, 2023

I don't know the VSCode extension. You could install the pypi package called black:

pip3 install black

And execute the tool at the custom component folder once:

cd custom_components/xiaomi_miio_fan
black *.py
diff --git a/custom_components/xiaomi_miio_fan/fan.py b/custom_components/xiaomi_miio_fan/fan.py
index 559480b..e31b8af 100644
--- a/custom_components/xiaomi_miio_fan/fan.py
+++ b/custom_components/xiaomi_miio_fan/fan.py
@@ -78,7 +78,7 @@ MODEL_FAN_P11 = "dmaker.fan.p11"  # Mijia Pedestal Fan
 MODEL_FAN_P15 = "dmaker.fan.p15"  # Pedestal Fan Fan P15
 MODEL_FAN_P18 = "dmaker.fan.p18"  # Mi Smart Standing Fan 2
 MODEL_FAN_P33 = "dmaker.fan.p33"  # Mi Smart Standing Fan Pro 2
-MODEL_FAN_P39 = "dmaker.fan.p39" # Smart Tower Fan
+MODEL_FAN_P39 = "dmaker.fan.p39"  # Smart Tower Fan
 MODEL_FAN_LESHOW_SS4 = "leshow.fan.ss4"
 MODEL_FAN_1C = "dmaker.fan.1c"  # Pedestal Fan Fan 1C
 
@@ -362,9 +362,7 @@ FEATURE_FLAGS_FAN_P33 = (
 )
 
 FEATURE_FLAGS_FAN_P39 = (
-    FEATURE_SET_CHILD_LOCK
-    | FEATURE_SET_OSCILLATION_ANGLE
-    | FEATURE_SET_NATURAL_MODE
+    FEATURE_SET_CHILD_LOCK | FEATURE_SET_OSCILLATION_ANGLE | FEATURE_SET_NATURAL_MODE
 )
 
 SERVICE_SET_BUZZER_ON = "fan_set_buzzer_on"
@@ -2025,6 +2023,7 @@ class FanStatusP33(DeviceStatus):
     def angle(self) -> int:
         return self.data["angle"]
 
+
 class FanP33(MiotDevice):
     mapping = {
         # https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p33:1
@@ -2134,6 +2133,7 @@ class FanP33(MiotDevice):
             value = 2
         return self.set_property("motor_control", value)
 
+
 class XiaomiFanP39(XiaomiFanMiot):
     """Representation of a Xiaomi Fan P39."""
 
@@ -2300,7 +2300,8 @@ class FanStatusP39(DeviceStatus):
     @property
     def angle(self) -> int:
         return self.data["angle"]
-    
+
+
 class FanP39(MiotDevice):
     mapping = {
         # https://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-p39:1

Copy link
Owner

@syssi syssi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@syssi syssi merged commit 1f2977f into syssi:develop Jul 20, 2023
1 check passed
@syssi
Copy link
Owner

syssi commented Jul 20, 2023

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add dmaker.fan.p39 (Tower Fan) support Unsupported device: dmaker.fan.p39
2 participants