Skip to content

Commit 1b4b744

Browse files
authored
Merge pull request #19 from andrewsayre/dev
v0.7.0
2 parents 20bc61d + 631c4a4 commit 1b4b744

File tree

9 files changed

+39
-34
lines changed

9 files changed

+39
-34
lines changed

.vscode/settings.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
2-
"python.pythonPath": ".venv\\Scripts\\python.exe",
2+
"python.pythonPath": "/Users/andrewsayre/repos/pysmartthings/.venv/bin/python3",
33
"[python]": {
4-
"editor.rulers": [79]
4+
"editor.rulers": [
5+
79
6+
]
57
}
68
}

pysmartthings/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
Capability)
1010
from .const import __title__, __version__ # noqa
1111
from .device import (
12-
Command, Device, DeviceEntity, DeviceStatus, DeviceStatusBase, DeviceType)
12+
DEVICE_TYPE_DTH, DEVICE_TYPE_ENDPOINT_APP, DEVICE_TYPE_OCF,
13+
DEVICE_TYPE_UNKNOWN, DEVICE_TYPE_VIPER, Command, Device, DeviceEntity,
14+
DeviceStatus, DeviceStatusBase)
1315
from .errors import APIErrorDetail, APIInvalidGrant, APIResponseError
1416
from .installedapp import (
1517
InstalledApp, InstalledAppEntity, InstalledAppStatus, InstalledAppType)
@@ -40,12 +42,16 @@
4042
'Attribute',
4143
'Capability',
4244
# device
45+
'DEVICE_TYPE_DTH',
46+
'DEVICE_TYPE_ENDPOINT_APP',
47+
'DEVICE_TYPE_OCF',
48+
'DEVICE_TYPE_UNKNOWN',
49+
'DEVICE_TYPE_VIPER',
4350
'Command',
4451
'Device',
4552
'DeviceEntity',
4653
'DeviceStatus',
4754
'DeviceStatusBase',
48-
'DeviceType',
4955
# error
5056
'APIErrorDetail',
5157
'APIInvalidGrant',

pysmartthings/capability.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
'waterSensor': ['water'],
9999
'windowShade': ['windowShade']
100100
}
101-
CAPABILITIES = [c for c in CAPABILITIES_TO_ATTRIBUTES]
101+
CAPABILITIES = list(CAPABILITIES_TO_ATTRIBUTES)
102102
ATTRIBUTES = {attrib
103103
for attributes in CAPABILITIES_TO_ATTRIBUTES.values()
104104
for attrib in attributes}

pysmartthings/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""Define consts for the pysmartthings package."""
22

33
__title__ = "pysmartthings"
4-
__version__ = "0.6.9"
4+
__version__ = "0.7.0"

pysmartthings/device.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
"""Defines a SmartThings device."""
22
from collections import defaultdict, namedtuple
33
import colorsys
4-
from enum import Enum
54
import re
65
from typing import Any, Dict, Mapping, Optional, Sequence, Tuple
76

87
from .api import Api
98
from .capability import ATTRIBUTE_ON_VALUES, Attribute, Capability
109
from .entity import Entity
1110

11+
DEVICE_TYPE_OCF = 'OCF'
12+
DEVICE_TYPE_DTH = 'DTH'
13+
DEVICE_TYPE_UNKNOWN = 'UNKNOWN'
14+
DEVICE_TYPE_ENDPOINT_APP = 'ENDPOINT_APP'
15+
DEVICE_TYPE_VIPER = 'VIPER'
16+
1217
COLOR_HEX_MATCHER = re.compile('^#[A-Fa-f0-9]{6}$')
1318
Status = namedtuple('status', 'value unit data')
1419
STATUS_NONE = Status(None, None, None)
@@ -58,15 +63,6 @@ class Command:
5863
unlock = 'unlock'
5964

6065

61-
class DeviceType(Enum):
62-
"""Define the device type."""
63-
64-
UNKNOWN = 'UNKNOWN'
65-
DTH = 'DTH'
66-
ENDPOINT_APP = 'ENDPOINT_APP'
67-
VIPER = 'VIPER'
68-
69-
7066
class Device:
7167
"""Represents a SmartThings device."""
7268

@@ -77,7 +73,7 @@ def __init__(self):
7773
self._label = None
7874
self._location_id = None
7975
self._room_id = None
80-
self._type = DeviceType.UNKNOWN
76+
self._type = DEVICE_TYPE_UNKNOWN
8177
self._device_type_id = None
8278
self._device_type_name = None
8379
self._device_type_network = None
@@ -91,7 +87,7 @@ def apply_data(self, data: dict):
9187
self._label = data['label']
9288
self._location_id = data['locationId']
9389
self._room_id = data.get('roomId')
94-
self._type = DeviceType(data['type'])
90+
self._type = data['type']
9591
self._components.clear()
9692
self._capabilities.clear()
9793
for component in data['components']:
@@ -101,7 +97,7 @@ def apply_data(self, data: dict):
10197
self._capabilities.extend(capabilities)
10298
else:
10399
self._components[component_id] = capabilities
104-
if self._type is DeviceType.DTH:
100+
if self._type == DEVICE_TYPE_DTH:
105101
dth = data['dth']
106102
self._device_type_id = dth["deviceTypeId"]
107103
self._device_type_name = dth["deviceTypeName"]
@@ -140,7 +136,7 @@ def room_id(self):
140136
return self._room_id
141137

142138
@property
143-
def type(self) -> DeviceType:
139+
def type(self) -> str:
144140
"""Get the SmartThings device type."""
145141
return self._type
146142

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
aiohttp==3.5.4
1+
aiohttp==3.6.2

test-requirements.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
coveralls==1.7.0
2-
flake8==3.7.7
3-
flake8-docstrings==1.3.0
4-
pydocstyle==3.0.0
5-
pylint==2.3.1
6-
pytest==4.4.1
1+
coveralls==1.9.2
2+
flake8==3.7.9
3+
flake8-docstrings==1.5.0
4+
pydocstyle==5.0.1
5+
pylint==2.4.4
6+
pytest==5.3.2
77
pytest-asyncio==0.10.0
8-
pytest-cov==2.7.1
8+
pytest-cov==2.8.1
99
pytest-timeout==1.3.3
10-
yarl==1.3.0
10+
yarl==1.4.2

tests/test_device.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
from pysmartthings.capability import Attribute, Capability
66
from pysmartthings.device import (
7-
Device, DeviceEntity, DeviceStatus, DeviceType, Status)
7+
DEVICE_TYPE_DTH, DEVICE_TYPE_UNKNOWN, Device, DeviceEntity, DeviceStatus,
8+
Status)
89

910
from .conftest import DEVICE_ID, LOCATION_ID, ROOM_ID
1011
from .utilities import get_json
@@ -19,7 +20,7 @@ def test_init():
1920
# Arrange/Act
2021
device = Device()
2122
# Assert
22-
assert device.type == DeviceType.UNKNOWN
23+
assert device.type == DEVICE_TYPE_UNKNOWN
2324
assert device.capabilities == []
2425
assert device.components == {}
2526

@@ -37,7 +38,7 @@ def test_apply_data():
3738
assert device.label == 'Front Porch Lights'
3839
assert device.location_id == LOCATION_ID
3940
assert device.room_id == ROOM_ID
40-
assert device.type is DeviceType.DTH
41+
assert device.type == DEVICE_TYPE_DTH
4142
assert device.device_type_id == '8a9d4b1e3b9b1fe3013b9b206a7f000d'
4243
assert device.device_type_name == 'Dimmer Switch'
4344
assert device.device_type_network == 'ZWAVE'

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ setenv =
99
deps =
1010
-r{toxinidir}/test-requirements.txt
1111
commands =
12-
pytest tests --timeout=30 --duration=10 {posargs}
12+
pytest tests --timeout=30 {posargs}
1313

1414
[testenv:lint]
1515
setenv =
@@ -29,4 +29,4 @@ setenv =
2929
deps =
3030
-r{toxinidir}/test-requirements.txt
3131
commands =
32-
pytest tests --timeout=30 --duration=10 --cov {posargs}
32+
pytest tests --timeout=30 --cov {posargs}

0 commit comments

Comments
 (0)