forked from rytilahti/python-miio
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for the Xiaomi Mi WiFi Repeater 2 added (Closes: rytilahti#275)
- Loading branch information
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import logging | ||
from .device import Device | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class WifiRepeaterStatus: | ||
def __init__(self, data): | ||
""" | ||
Response of a xiaomi.repeater.v2: | ||
{ | ||
'sta': {'count': 2, 'access_policy': 0}, | ||
'mat': [ | ||
{'mac': 'aa:aa:aa:aa:aa:aa', 'ip': '192.168.1.133', 'last_time': 54371873}, | ||
{'mac': 'bb:bb:bb:bb:bb:bb', 'ip': '192.168.1.156', 'last_time': 54371496} | ||
], | ||
'access_list': {'mac': ''} | ||
} | ||
""" | ||
self.data = data | ||
|
||
@property | ||
def access_policy(self) -> int: | ||
"""Access policy of the associated stations.""" | ||
return self.data['sta']['access_policy'] | ||
|
||
@property | ||
def associated_stations(self) -> dict: | ||
"""List of associated stations.""" | ||
return self.data['mat'] | ||
|
||
|
||
class WifiRepeaterConfiguration: | ||
def __init__(self, data): | ||
""" | ||
Response of a xiaomi.repeater.v2: | ||
{'ssid': 'SSID', 'pwd': 'PWD', 'hidden': 0} | ||
""" | ||
self.data = data | ||
|
||
@property | ||
def ssid(self) -> str: | ||
return self.data['ssid'] | ||
|
||
@property | ||
def password(self) -> str: | ||
return self.data['pwd'] | ||
|
||
@property | ||
def ssid_hidden(self) -> bool: | ||
return self.data['hidden'] == 1 | ||
|
||
|
||
class WifiRepeater(Device): | ||
"""Device class for Xiaomi Mi WiFi Repeater 2.""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
def status(self) -> WifiRepeaterStatus: | ||
"""Return the associated stations.""" | ||
return WifiRepeaterStatus(self.send("miIO.get_repeater_sta_info", [])) | ||
|
||
def configuration(self) -> WifiRepeaterConfiguration: | ||
"""Return the configuration of the accesspoint.""" | ||
return WifiRepeaterConfiguration( | ||
self.send("miIO.get_repeater_ap_info", [])) | ||
|
||
def switch_wifi_explorer(self): | ||
"""Parameters unknown.""" | ||
return self.send("miIO.switch_wifi_explorer", []) | ||
|
||
def switch_wifi_ssid(self): | ||
"""Parameters unknown.""" | ||
return self.send("miIO.switch_wifi_ssid", []) |