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 #2 from andrewsayre/dev
Browse files Browse the repository at this point in the history
Merge to main 0.5.0
  • Loading branch information
andrewsayre committed Feb 5, 2019
2 parents 1ec4a9d + 20f005a commit debe4eb
Show file tree
Hide file tree
Showing 25 changed files with 841 additions and 165 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ language: python
matrix:
fast_finish: true
include:
- python: "3.5"
env: TOXENV=pylint
- python: "3.5"
env: TOXENV=lint
- python: "3.5"
env: TOXENV=cov
after_success: coveralls
- python: "3.5"
env: TOXENV=py35
- python: "3.6"
env: TOXENV=py36
- python: "3.7"
Expand All @@ -27,4 +23,4 @@ deploy:
skip_existing: true
on:
tags: true
condition: $TOXENV = lint
condition: $TOXENV = lint
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ A python library for interacting with the SmartThings cloud API build with [asyn
## Features
The package is still in beta, but the following features are available:
1. Locations: List, Get
2. Devices: List, Get, Command, Status
3. Apps: List, Get, Create, Update, Delete, Settings Get & Update, OAuth: Get & Update
4. InstalledApps: List, Get, Delete
5. Subscriptions: List, Get, Create, Delete, Delete All
6. Scenes: List, Execute
1. Rooms: List, Get, Create, Update, Delete
1. Devices: List, Get, Command, Status
1. Apps: List, Get, Create, Update, Delete, Settings Get & Update, OAuth: Get & Update
1. InstalledApps: List, Get, Delete
1. Subscriptions: List, Get, Create, Delete, Delete All
1. Scenes: List, Execute
## Installation
```commandline
pip install pysmartthings
Expand Down
17 changes: 14 additions & 3 deletions pysmartthings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
APP_TYPE_LAMBDA, APP_TYPE_WEBHOOK, CLASSIFICATION_AUTOMATION, App,
AppEntity, AppOAuth, AppOAuthClient, AppOAuthEntity, AppSettings,
AppSettingsEntity)
from .capability import (
ATTRIBUTES, CAPABILITIES, CAPABILITIES_TO_ATTRIBUTES, Attribute,
Capability)
from .const import __title__, __version__ # noqa
from .device import (
Attribute, Capability, Command, Device, DeviceEntity, DeviceStatus,
DeviceType)
Command, Device, DeviceEntity, DeviceStatus, DeviceStatusBase, DeviceType)
from .errors import APIErrorDetail, APIInvalidGrant, APIResponseError
from .installedapp import (
InstalledApp, InstalledAppEntity, InstalledAppStatus, InstalledAppType)
from .location import Location, LocationEntity
from .room import Room, RoomEntity
from .oauthtoken import OAuthToken
from .scene import Scene, SceneEntity
from .smartthings import SmartThings
Expand All @@ -29,13 +32,18 @@
'AppOAuthEntity',
'AppSettings',
'AppSettingsEntity',
# device
# capability
'ATTRIBUTES',
'CAPABILITIES',
'CAPABILITIES_TO_ATTRIBUTES',
'Attribute',
'Capability',
# device
'Command',
'Device',
'DeviceEntity',
'DeviceStatus',
'DeviceStatusBase',
'DeviceType',
# error
'APIErrorDetail',
Expand All @@ -49,6 +57,9 @@
# location
'Location',
'LocationEntity',
# room
'Room',
'RoomEntity',
# oauthtoken
'OAuthToken',
# scene
Expand Down
52 changes: 49 additions & 3 deletions pysmartthings/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
API_BASE = "https://api.smartthings.com/v1/"
API_LOCATIONS = "locations"
API_LOCATION = API_LOCATIONS + "/{location_id}"
API_ROOMS = "locations/{location_id}/rooms"
API_ROOM = "locations/{location_id}/rooms/{room_id}"
API_DEVICES = "devices"
API_DEVICE = API_DEVICES + "/{device_id}"
API_DEVICE_STATUS = "devices/{device_id}/status"
Expand Down Expand Up @@ -58,6 +60,50 @@ async def get_location(self, location_id: str) -> dict:
"""
return await self.get(API_LOCATION.format(location_id=location_id))

async def get_rooms(self, location_id: str) -> dict:
"""
Get a location's rooms.
This API call is undocumented.
"""
return await self.get_items(API_ROOMS.format(location_id=location_id))

async def get_room(self, location_id: str, room_id: str) -> dict:
"""
Get a specific room within a location.
This API call is undocumented.
"""
return await self.get(
API_ROOM.format(location_id=location_id, room_id=room_id))

async def create_room(self, location_id: str, data: dict):
"""
Create a room.
This API call is undocumented.
"""
return await self.post(
API_ROOMS.format(location_id=location_id), data)

async def update_room(self, location_id: str, room_id: str, data: dict):
"""
Update a room.
This API call is undocumented.
"""
return await self.put(
API_ROOM.format(location_id=location_id, room_id=room_id), data)

async def delete_room(self, location_id: str, room_id: str):
"""
Delete a room.
This API call is undocumented.
"""
return await self.delete(
API_ROOM.format(location_id=location_id, room_id=room_id))

async def get_devices(self, params: Optional = None) -> dict:
"""
Get the device definitions.
Expand All @@ -78,8 +124,8 @@ async def get_device_status(self, device_id: str) -> dict:
"""Get the status of a specific device."""
return await self.get(API_DEVICE_STATUS.format(device_id=device_id))

async def post_device_command(self, device_id, capability, command, args,
component="main") -> object:
async def post_device_command(self, device_id, component_id, capability,
command, args) -> object:
"""
Execute commands on a device.
Expand All @@ -88,7 +134,7 @@ async def post_device_command(self, device_id, capability, command, args,
data = {
"commands": [
{
"component": component,
"component": component_id,
"capability": capability,
"command": command
}
Expand Down

0 comments on commit debe4eb

Please sign in to comment.