Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #37 from andrewsayre/dev
Browse files Browse the repository at this point in the history
Do not require any device attributes and version bump
  • Loading branch information
andrewsayre committed Aug 10, 2020
2 parents d7ffd3e + 2fca0d8 commit 0c76c4f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pysmartthings/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Define consts for the pysmartthings package."""

__title__ = "pysmartthings"
__version__ = "0.7.2"
__version__ = "0.7.3"
37 changes: 21 additions & 16 deletions pysmartthings/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,31 @@ def __init__(self):

def apply_data(self, data: dict):
"""Apply the given data dictionary."""
self._device_id = data["deviceId"]
self._name = data["name"]
self._label = data["label"]
self._location_id = data["locationId"]
self._device_id = data.get("deviceId")
self._name = data.get("name")
self._label = data.get("label")
self._location_id = data.get("locationId")
self._room_id = data.get("roomId")
self._type = data["type"]
self._type = data.get("type")
self._components.clear()
self._capabilities.clear()
for component in data["components"]:
capabilities = [c["id"] for c in component["capabilities"]]
component_id = component["id"]
if component_id == "main":
self._capabilities.extend(capabilities)
else:
self._components[component_id] = capabilities

components = data.get("components")
if components:
for component in components:
capabilities = [c["id"] for c in component["capabilities"]]
component_id = component["id"]
if component_id == "main":
self._capabilities.extend(capabilities)
else:
self._components[component_id] = capabilities

if self._type == DEVICE_TYPE_DTH:
dth = data["dth"]
self._device_type_id = dth["deviceTypeId"]
self._device_type_name = dth["deviceTypeName"]
self._device_type_network = dth["deviceNetworkType"]
dth = data.get("dth")
if dth:
self._device_type_id = dth.get("deviceTypeId")
self._device_type_name = dth.get("deviceTypeName")
self._device_type_network = dth.get("deviceNetworkType")

def get_capability(self, *capabilities) -> Optional[str]:
"""Return the first capability held by the device."""
Expand Down

0 comments on commit 0c76c4f

Please sign in to comment.