Skip to content

Commit d7ffd3e

Browse files
authored
Merge pull request #32 from andrewsayre/dev
Release 0.7.2
2 parents 6a14dd6 + d1016ff commit d7ffd3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+7339
-6340
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![image](https://img.shields.io/pypi/l/pysmartthings.svg)](https://pypi.org/project/pysmartthings/)
77
[![image](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
88

9-
A python library for interacting with the SmartThings cloud API build with [asyncio](https://docs.python.org/3/library/asyncio.html) and [aiohttp](https://aiohttp.readthedocs.io/en/stable/).
9+
A python library for interacting with the SmartThings cloud API build with [asyncio](https://docs.python.org/3/library/asyncio.html) and [aiohttp](https://aiohttp.readthedocs.io/en/stable/).
1010
## Features
1111
The package is still in beta, but the following features are available:
1212
1. Locations: List, Get
@@ -43,10 +43,10 @@ A list of locations in SmartThings can be retrieved by invoking the coroutine `l
4343
```pythonstub
4444
locations = await api.locations()
4545
print(len(locations))
46-
46+
4747
location = locations[0]
4848
print(location.name)
49-
print(location.location_id)
49+
print(location.location_id)
5050
```
5151
Outputs:
5252
```pythonstub
@@ -55,11 +55,11 @@ Outputs:
5555
'5c03e518-118a-44cb-85ad-7877d0b302e4'
5656
```
5757
### Devices
58-
A list of devices can be retrieved by invoking the coroutine `devices(location_ids=None, capabilities=None, device_ids=None)`. The optional parameters allow filtering the returned list.
58+
A list of devices can be retrieved by invoking the coroutine `devices(location_ids=None, capabilities=None, device_ids=None)`. The optional parameters allow filtering the returned list.
5959
```pythonstub
6060
devices = await api.devices()
6161
print(len(devices))
62-
62+
6363
device = devices[0]
6464
print(device.device_id)
6565
print(device.name)
@@ -76,7 +76,7 @@ Outputs:
7676
```
7777
The current status of the device is populated when the coroutine `status.refresh()` is called. The DeviceStatus class represents the current values of the capabilities and provides several normalized property accessors.
7878
```pythonstub
79-
await device.status.refresh()
79+
await device.status.refresh()
8080
print(device.status.values)
8181
print(device.status.switch)
8282
print(device.status.level)
@@ -88,19 +88,19 @@ True
8888
100
8989
```
9090
#### Device Commands
91-
You can execute a command on a device by calling the coroutine `command(capability, command, args=None)` function. The `capability` parameter corresponds to one of the capabilities detected and `command` is one of the define commands. `args` is an array of parameters to pass to the command (optional). See the [SmartThings Capability Reference](https://smartthings.developer.samsung.com/develop/api-ref/capabilities.html) for more information.
91+
You can execute a command on a device by calling the coroutine `command(component_id, capability, command, args=None)` function. The `component_id` parameter is the identifier of the component within the device (`main` is the device itself); `capability` is the name of the capability implemented by the device; and `command` is one of the defined operations within the capability. `args` is an array of parameters to pass to the command when it accepts parameters (optional). See the [SmartThings Capability Reference](https://smartthings.developer.samsung.com/develop/api-ref/capabilities.html) for more information.
9292
```pythonstub
93-
result = await device.command("switch", "on")
93+
result = await device.command("main", "switch", "on")
9494
assert result == True
95-
96-
result = await device.command("switchLevel", "setLevel", [75, 2])
95+
96+
result = await device.command("main", "switchLevel", "setLevel", [75, 2])
9797
assert result == True
9898
```
9999
Devices with the `switch` capability have the following coroutines:
100100
```pythonstub
101101
result = await device.switch_on()
102102
assert result == True
103-
103+
104104
result = await device.switch_off()
105105
assert result == True
106106
```

lint.cmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@echo off
2-
pip install isort --quiet --upgrade
32
isort tests pysmartthings --recursive
4-
pip install -r test-requirements.txt --quiet
3+
black tests pysmartthings
54
pylint tests pysmartthings
65
flake8 tests pysmartthings
76
pydocstyle tests pysmartthings

pysmartthings/__init__.py

Lines changed: 126 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,126 @@
1-
"""A python library for interacting with the SmartThings cloud API."""
2-
3-
from .app import (
4-
APP_TYPE_LAMBDA,
5-
APP_TYPE_WEBHOOK,
6-
CLASSIFICATION_AUTOMATION,
7-
App,
8-
AppEntity,
9-
AppOAuth,
10-
AppOAuthClient,
11-
AppOAuthClientEntity,
12-
AppOAuthEntity,
13-
AppSettings,
14-
AppSettingsEntity,
15-
)
16-
from .capability import (
17-
ATTRIBUTES,
18-
CAPABILITIES,
19-
CAPABILITIES_TO_ATTRIBUTES,
20-
Attribute,
21-
Capability,
22-
)
23-
from .const import __title__, __version__ # noqa
24-
from .device import (
25-
DEVICE_TYPE_DTH,
26-
DEVICE_TYPE_ENDPOINT_APP,
27-
DEVICE_TYPE_OCF,
28-
DEVICE_TYPE_UNKNOWN,
29-
DEVICE_TYPE_VIPER,
30-
Command,
31-
Device,
32-
DeviceEntity,
33-
DeviceStatus,
34-
DeviceStatusBase,
35-
)
36-
from .errors import APIErrorDetail, APIInvalidGrant, APIResponseError
37-
from .installedapp import (
38-
InstalledApp,
39-
InstalledAppEntity,
40-
InstalledAppStatus,
41-
InstalledAppType,
42-
)
43-
from .location import Location, LocationEntity
44-
from .oauthtoken import OAuthToken
45-
from .room import Room, RoomEntity
46-
from .scene import Scene, SceneEntity
47-
from .smartthings import SmartThings
48-
from .subscription import SourceType, Subscription, SubscriptionEntity
49-
50-
__all__ = [
51-
# app
52-
"APP_TYPE_LAMBDA",
53-
"APP_TYPE_WEBHOOK",
54-
"CLASSIFICATION_AUTOMATION",
55-
"App",
56-
"AppEntity",
57-
"AppOAuth",
58-
"AppOAuthClient",
59-
"AppOAuthClientEntity",
60-
"AppOAuthEntity",
61-
"AppSettings",
62-
"AppSettingsEntity",
63-
# capability
64-
"ATTRIBUTES",
65-
"CAPABILITIES",
66-
"CAPABILITIES_TO_ATTRIBUTES",
67-
"Attribute",
68-
"Capability",
69-
# device
70-
"DEVICE_TYPE_DTH",
71-
"DEVICE_TYPE_ENDPOINT_APP",
72-
"DEVICE_TYPE_OCF",
73-
"DEVICE_TYPE_UNKNOWN",
74-
"DEVICE_TYPE_VIPER",
75-
"Command",
76-
"Device",
77-
"DeviceEntity",
78-
"DeviceStatus",
79-
"DeviceStatusBase",
80-
# error
81-
"APIErrorDetail",
82-
"APIInvalidGrant",
83-
"APIResponseError",
84-
# installed app
85-
"InstalledApp",
86-
"InstalledAppEntity",
87-
"InstalledAppStatus",
88-
"InstalledAppType",
89-
# location
90-
"Location",
91-
"LocationEntity",
92-
# room
93-
"Room",
94-
"RoomEntity",
95-
# oauthtoken
96-
"OAuthToken",
97-
# scene
98-
"Scene",
99-
"SceneEntity",
100-
# smartthings
101-
"SmartThings",
102-
# subscription
103-
"SourceType",
104-
"Subscription",
105-
"SubscriptionEntity",
106-
]
1+
"""A python library for interacting with the SmartThings cloud API."""
2+
3+
from .app import (
4+
APP_TYPE_LAMBDA,
5+
APP_TYPE_WEBHOOK,
6+
CLASSIFICATION_AUTOMATION,
7+
App,
8+
AppEntity,
9+
AppOAuth,
10+
AppOAuthClient,
11+
AppOAuthClientEntity,
12+
AppOAuthEntity,
13+
AppSettings,
14+
AppSettingsEntity,
15+
)
16+
from .capability import (
17+
ATTRIBUTES,
18+
CAPABILITIES,
19+
CAPABILITIES_TO_ATTRIBUTES,
20+
Attribute,
21+
Capability,
22+
)
23+
from .const import ( # noqa
24+
__title__,
25+
__version__,
26+
)
27+
from .device import (
28+
DEVICE_TYPE_DTH,
29+
DEVICE_TYPE_ENDPOINT_APP,
30+
DEVICE_TYPE_OCF,
31+
DEVICE_TYPE_UNKNOWN,
32+
DEVICE_TYPE_VIPER,
33+
Command,
34+
Device,
35+
DeviceEntity,
36+
DeviceStatus,
37+
DeviceStatusBase,
38+
)
39+
from .errors import (
40+
APIErrorDetail,
41+
APIInvalidGrant,
42+
APIResponseError,
43+
)
44+
from .installedapp import (
45+
InstalledApp,
46+
InstalledAppEntity,
47+
InstalledAppStatus,
48+
InstalledAppType,
49+
)
50+
from .location import (
51+
Location,
52+
LocationEntity,
53+
)
54+
from .oauthtoken import OAuthToken
55+
from .room import (
56+
Room,
57+
RoomEntity,
58+
)
59+
from .scene import (
60+
Scene,
61+
SceneEntity,
62+
)
63+
from .smartthings import SmartThings
64+
from .subscription import (
65+
SourceType,
66+
Subscription,
67+
SubscriptionEntity,
68+
)
69+
70+
__all__ = [
71+
# app
72+
"APP_TYPE_LAMBDA",
73+
"APP_TYPE_WEBHOOK",
74+
"CLASSIFICATION_AUTOMATION",
75+
"App",
76+
"AppEntity",
77+
"AppOAuth",
78+
"AppOAuthClient",
79+
"AppOAuthClientEntity",
80+
"AppOAuthEntity",
81+
"AppSettings",
82+
"AppSettingsEntity",
83+
# capability
84+
"ATTRIBUTES",
85+
"CAPABILITIES",
86+
"CAPABILITIES_TO_ATTRIBUTES",
87+
"Attribute",
88+
"Capability",
89+
# device
90+
"DEVICE_TYPE_DTH",
91+
"DEVICE_TYPE_ENDPOINT_APP",
92+
"DEVICE_TYPE_OCF",
93+
"DEVICE_TYPE_UNKNOWN",
94+
"DEVICE_TYPE_VIPER",
95+
"Command",
96+
"Device",
97+
"DeviceEntity",
98+
"DeviceStatus",
99+
"DeviceStatusBase",
100+
# error
101+
"APIErrorDetail",
102+
"APIInvalidGrant",
103+
"APIResponseError",
104+
# installed app
105+
"InstalledApp",
106+
"InstalledAppEntity",
107+
"InstalledAppStatus",
108+
"InstalledAppType",
109+
# location
110+
"Location",
111+
"LocationEntity",
112+
# room
113+
"Room",
114+
"RoomEntity",
115+
# oauthtoken
116+
"OAuthToken",
117+
# scene
118+
"Scene",
119+
"SceneEntity",
120+
# smartthings
121+
"SmartThings",
122+
# subscription
123+
"SourceType",
124+
"Subscription",
125+
"SubscriptionEntity",
126+
]

0 commit comments

Comments
 (0)