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

Chuang Mi Plug V1: Property "temperature" added & discovery fixed #109

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions miio/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"chuangmi-plug-m1": Plug,
"chuangmi-plug-v2": Plug,
"chuangmi-plug-v1": PlugV1,
"chuangmi-plug_": PlugV1,
"qmi-powerstrip-v1": PowerStrip,
"zimi-powerstrip-v2": PowerStrip,
"zhimi-airpurifier-m1": AirPurifier,
Expand Down
11 changes: 8 additions & 3 deletions miio/plug_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ def is_on(self) -> bool:
def usb_power(self) -> bool:
return self.data["usb_on"]

@property
def temperature(self) -> float:
return self.data["temperature"]

def __str__(self) -> str:
s = "<PlugV1Status power=%s, usb_power=%s>" % \
s = "<PlugV1Status power=%s, usb_power=%s, temperature=%s>" % \
(self.power,
self.usb_power)
self.usb_power,
self.temperature)
return s


Expand All @@ -36,7 +41,7 @@ class PlugV1(Device):

def status(self) -> PlugV1Status:
"""Retrieve properties."""
properties = ['on', 'usb_on']
properties = ['on', 'usb_on', 'temperature']
values = self.send(
"get_prop",
properties
Expand Down