Skip to content

Commit

Permalink
add firmware property + convert device list to dict (#719)
Browse files Browse the repository at this point in the history
* add firmware property

* convert devices list to dict
  • Loading branch information
starkillerOG authored Jun 7, 2020
1 parent f92e80f commit 5dd8f31
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions miio/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def __init__(
self._radio = GatewayRadio(parent=self)
self._zigbee = GatewayZigbee(parent=self)
self._light = GatewayLight(parent=self)
self._devices = []
self._devices = {}

@property
def alarm(self) -> "GatewayAlarm":
Expand All @@ -151,7 +151,7 @@ def light(self) -> "GatewayLight":

@property
def devices(self):
"""Return a list of the already discovered devices."""
"""Return a dict of the already discovered devices."""
return self._devices

@command()
Expand All @@ -172,7 +172,7 @@ def discover_devices(self):
DeviceType.AqaraWallOutlet: AqaraWallOutlet,
}
devices_raw = self.get_prop("device_list")
self._devices = []
self._devices = {}

for x in range(0, len(devices_raw), 5):
# Extract discovered information
Expand Down Expand Up @@ -203,7 +203,7 @@ def discover_devices(self):

# Initialize and save the subdevice, ignoring the gateway itself
if device_type != DeviceType.Gateway:
self._devices.append(subdevice_cls(self, dev_info))
self._devices[dev_info.sid] = subdevice_cls(self, dev_info)

return self._devices

Expand Down Expand Up @@ -639,6 +639,11 @@ def device_type(self):
"""Return the device type name."""
return self.type.name

@property
def firmware_version(self):
"""Return the firmware version."""
return self._fw_ver

@property
def battery(self):
"""Return the battery level."""
Expand Down

0 comments on commit 5dd8f31

Please sign in to comment.