Skip to content

Commit 8b44455

Browse files
authored
Decamelize objects (#4)
1 parent bd0e8f9 commit 8b44455

5 files changed

Lines changed: 153 additions & 8 deletions

File tree

poetry.lock

Lines changed: 123 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
[tool.poetry]
2-
name = "pymfy"
2+
name = "python-tahoma-api"
33
version = "0.1.0"
44
description = "Python wrapper to interact with internal Somfy TaHoma API"
55
authors = ["Mick Vleeshouwer", "Vincent Le Bourlot", "Thibaut Etienne"]
6-
license = "GPL-3.0-only"
6+
license = "MIT"
77
readme = "README.md"
88
homepage = "https://github.com/iMicknl/python-tahoma-api"
99
repository = "https://github.com/iMicknl/python-tahoma-api"
1010

1111
[tool.poetry.dependencies]
1212
python = ">=3.6"
1313
aiohttp = "^3.6.2"
14+
pyhumps = "^1.3.1"
1415

1516
[tool.poetry.dev-dependencies]
1617
tox = ">=3.0"
1718
pytest = ">=4.1"
1819
pytest-cov = ">=2.8.1"
1920
pre-commit = ">=1.10"
21+
black = {version = "^19.10b0", allow-prereleases = true}
2022

2123
[build-system]
2224
requires = ["poetry>=0.12"]

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ select = C,E,F,W,B,B950
44
ignore = E501
55

66
[isort]
7-
known_third_party = aiohttp
7+
known_third_party = aiohttp,humps
88
multi_line_output=3
99
include_trailing_comma=true
1010
force_grid_wrap=0

tahoma_api/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Any, List, Optional
33

44
import aiohttp
5+
import humps
56

67
from tahoma_api.models import Device
78

@@ -155,6 +156,9 @@ async def __make_http_request(
155156
) as response:
156157
result = await response.json()
157158

159+
# TODO replace by our own library
160+
result = humps.decamelize(result)
161+
158162
if response.status == 200:
159163
return result
160164

tahoma_api/models.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Device:
99
"creation_time",
1010
"last_update_time",
1111
"label",
12-
"device_url",
12+
"deviceurl",
1313
"shortcut",
1414
"controllable_name",
1515
"definition",
@@ -28,7 +28,7 @@ def __init__(
2828
self,
2929
*,
3030
label: str,
31-
device_url: str,
31+
deviceurl: str,
3232
controllable_name: str,
3333
# definition: Dict[List[Any]],
3434
states: List[Dict[str, Any]],
@@ -39,8 +39,8 @@ def __init__(
3939
type: str,
4040
**_: Any
4141
) -> None:
42-
self.id = device_url
43-
self.device_url = device_url
42+
self.id = deviceurl
43+
self.deviceurl = deviceurl
4444
self.label = label
4545
self.controllable_name = controllable_name
4646
self.states = [State(**s) for s in states]
@@ -84,3 +84,20 @@ def __init__(self, name: str, value: str, type: str, **_: Any):
8484
self.name = name
8585
self.value = value
8686
self.type = type
87+
88+
89+
class Command:
90+
"""Represents an TaHoma Command."""
91+
92+
__slots__ = (
93+
"type",
94+
"name",
95+
"parameters",
96+
"sensitive_parameters_indexes",
97+
"authentication",
98+
"delay",
99+
)
100+
101+
def __init__(self, name: str, parameters: str, **_: Any):
102+
self.name = name
103+
self.parameters = parameters

0 commit comments

Comments
 (0)