Skip to content

Commit

Permalink
Rebrand to OverKiz (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl committed Dec 21, 2021
1 parent 42596d5 commit bb3456f
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.8
3.8.12
43 changes: 26 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
# Deprecation Notice
**`pyhoma` is deprecated. Please use `pyoverkiz` 1.0 which is backwards compatible. See https://github.com/iMicknl/python-overkiz-api.**


# Somfy TaHoma / OverKiz
# Python client for OverKiz API

<p align=center>
<a href="https://github.com/iMicknl/python-tahoma-api/actions"><img src="https://github.com/iMicknl/python-tahoma-api/workflows/CI/badge.svg"/></a>
<a href="https://github.com/iMicknl/python-overkiz-api/actions"><img src="https://github.com/iMicknl/python-overkiz-api/workflows/CI/badge.svg"/></a>
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" /></a>
</p>

An updated and async version of the original [tahoma-api](https://github.com/philklei/tahoma-api) by [@philklei](https://github.com/philklei). The aim of this wrapper is to offer an easy to consume Python wrapper for the internal API's used by tahomalink.com, or other vendors which use the OverKiz platform.
A fully async and easy to use API client for the (internal) OverKiz API. You can use this client to interact with smart devices connected to the OverKiz platform, used by various vendors like Somfy TaHoma and Atlantic Cozytouch.

This package is written for the Home Assistant [ha-tahoma](https://github.com/iMicknl/ha-tahoma) integration, but could be used by any Python project interacting with OverKiz hubs.

> Somfy TaHoma has an official API, which can be consumed via the [somfy-open-api](https://github.com/tetienne/somfy-open-api). Unfortunately only a few device classes are supported via the official API, thus the need for this API client.

Somfy TaHoma has an official API, which can be consumed via the [Somfy-open-api](https://github.com/tetienne/somfy-open-api). Unfortunately only a few device classes are supported via the official API, thus the need for this wrapper.
## Supported hubs

This package is written for the Home Assistant [ha-tahoma](https://github.com/iMicknl/ha-tahoma) integration, but could be used by any Python project interacting with Somfy TaHoma devices.
- Atlantic Cozytouch
- Hitachi Hi Kumo
- Nexity Eugénie
- Rexel Energeasy Connect
- Somfy Connexoon IO
- Somfy Connexoon RTS
- Somfy TaHoma
- Somfy TaHoma Switch
- Thermor Cozytouch

## Installation

```bash
pip install pyhoma
pip install pyoverkiz
```

## Getting started
Expand All @@ -27,14 +36,14 @@ pip install pyhoma
import asyncio
import time

from pyhoma.const import SUPPORTED_SERVERS
from pyhoma.client import TahomaClient
from pyoverkiz.const import SUPPORTED_SERVERS
from pyoverkiz.client import OverkizClient

USERNAME = ""
PASSWORD = ""

async def main() -> None:
async with TahomaClient(USERNAME, PASSWORD, server=SUPPORTED_SERVERS["somfy_europe"]) as client:
async with OverkizClient(USERNAME, PASSWORD, server=SUPPORTED_SERVERS["somfy_europe"]) as client:
try:
await client.login()
except Exception as exception: # pylint: disable=broad-except
Expand Down Expand Up @@ -71,9 +80,9 @@ asyncio.run(main())
- Install [poetry](https://python-poetry.org): `curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python`

- Clone this repository
- `cd python-tahoma-api`
- `cd python-overkiz-api`
- Install the required Python version: `pyenv install`
- Init the project: `poetry install`
- Init the project: `poetry install`
- Run `poetry run pre-commit install`

## PyCharm
Expand All @@ -84,6 +93,6 @@ Using snap, run `snap install pycharm --classic` to install it.

For MacOS, run `brew cask install pycharm-ce`

Once launched, don't create a new project, but open an existing one and select the **python-tahoma-api** folder.
Once launched, don't create a new project, but open an existing one and select the **python-overkiz-api** folder.

Go to _File | Settings | Project: nre-tag | Project Interpreter_. Your interpreter must look like `<whatever>/python-tahoma-api/.venv/bin/python`
Go to _File | Settings | Project: nre-tag | Project Interpreter_. Your interpreter must look like `<whatever>/python-overkiz-api/.venv/bin/python`
File renamed without changes.
28 changes: 14 additions & 14 deletions pyhoma/client.py → pyoverkiz/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Python wrapper for the Tahoma API """
""" Python wrapper for the OverKiz API """
from __future__ import annotations

import asyncio
Expand All @@ -14,7 +14,7 @@
from botocore.config import Config
from warrant.aws_srp import AWSSRP

from pyhoma.const import (
from pyoverkiz.const import (
COZYTOUCH_ATLANTIC_API,
COZYTOUCH_CLIENT_ID,
NEXITY_API,
Expand All @@ -23,7 +23,7 @@
NEXITY_COGNITO_USER_POOL,
SUPPORTED_SERVERS,
)
from pyhoma.exceptions import (
from pyoverkiz.exceptions import (
BadCredentialsException,
CozyTouchBadCredentialsException,
CozyTouchServiceException,
Expand All @@ -37,7 +37,7 @@
TooManyExecutionsException,
TooManyRequestsException,
)
from pyhoma.models import (
from pyoverkiz.models import (
Command,
Device,
Event,
Expand Down Expand Up @@ -65,7 +65,7 @@ async def refresh_listener(invocation: dict[str, Any]) -> None:
# pylint: disable=too-many-instance-attributes


class TahomaClient:
class OverkizClient:
"""Interface class for the Overkiz API"""

def __init__(
Expand All @@ -78,8 +78,8 @@ def __init__(
"""
Constructor
:param username: the username for Tahomalink.com
:param password: the password for Tahomalink.com
:param username: the username
:param password: the password
:param server: OverkizServer
:param session: optional ClientSession
"""
Expand All @@ -95,7 +95,7 @@ def __init__(

self.session = session if session else ClientSession()

async def __aenter__(self) -> TahomaClient:
async def __aenter__(self) -> OverkizClient:
return self

async def __aexit__(
Expand Down Expand Up @@ -436,7 +436,7 @@ async def execute_command(
self,
device_url: str,
command: Command | str,
label: str | None = "python-tahoma-api",
label: str | None = "python-overkiz-api",
) -> str:
"""Send a command"""
if isinstance(command, str):
Expand All @@ -457,7 +457,7 @@ async def execute_commands(
self,
device_url: str,
commands: list[Command],
label: str | None = "python-tahoma-api",
label: str | None = "python-overkiz-api",
) -> str:
"""Send several commands in one call"""
payload = {
Expand Down Expand Up @@ -499,15 +499,15 @@ async def execute_scenario(self, oid: str) -> str:
return response["execId"]

async def __get(self, path: str) -> Any:
"""Make a GET request to the TaHoma API"""
"""Make a GET request to the OverKiz API"""
async with self.session.get(f"{self.server.endpoint}{path}") as response:
await self.check_response(response)
return await response.json()

async def __post(
self, path: str, payload: JSON | None = None, data: JSON | None = None
) -> Any:
"""Make a POST request to the TaHoma API"""
"""Make a POST request to the OverKiz API"""
async with self.session.post(
f"{self.server.endpoint}{path}",
data=data,
Expand All @@ -517,13 +517,13 @@ async def __post(
return await response.json()

async def __delete(self, path: str) -> None:
"""Make a DELETE request to the TaHoma API"""
"""Make a DELETE request to the OverKiz API"""
async with self.session.delete(f"{self.server.endpoint}{path}") as response:
await self.check_response(response)

@staticmethod
async def check_response(response: ClientResponse) -> None:
"""Check the response returned by the TaHoma API"""
"""Check the response returned by the OverKiz API"""
if response.status in [200, 204]:
return

Expand Down
2 changes: 1 addition & 1 deletion pyhoma/const.py → pyoverkiz/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pyhoma.models import OverkizServer
from pyoverkiz.models import OverkizServer

COZYTOUCH_ATLANTIC_API = "https://api.groupe-atlantic.com"
COZYTOUCH_CLIENT_ID = (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pyhoma/models.py → pyoverkiz/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import attr

from pyhoma.enums import (
from pyoverkiz.enums import (
DataType,
EventName,
ExecutionState,
Expand Down Expand Up @@ -308,7 +308,7 @@ def __len__(self) -> int:


class Command(dict): # type: ignore
"""Represents an TaHoma Command."""
"""Represents an OverKiz Command."""

def __init__(self, name: str, parameters: list[str] | None = None, **_: Any):
self.name = name
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[tool.poetry]
name = "pyhoma"
version = "0.7.4"
description = "(deprecated, use pyoverkiz instead). Async Python wrapper to interact with internal Somfy TaHoma API, or other OverKiz API's."
name = "pyoverkiz"
version = "1.0.0"
description = "Async Python client to interact with internal OverKiz API (e.g. used by Somfy TaHoma)."
authors = ["Mick Vleeshouwer", "Vincent Le Bourlot", "Thibaut Etienne"]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/iMicknl/python-tahoma-api"
repository = "https://github.com/iMicknl/python-tahoma-api"
homepage = "https://github.com/iMicknl/python-overkiz-api"
repository = "https://github.com/iMicknl/python-overkiz-api"
packages = [
{ include = "pyhoma" }
{ include = "pyoverkiz" }
]

[tool.poetry.dependencies]
Expand Down
8 changes: 4 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import pytest
from pytest import fixture

from pyhoma.client import TahomaClient
from pyhoma.const import SUPPORTED_SERVERS
from pyoverkiz.client import OverkizClient
from pyoverkiz.const import SUPPORTED_SERVERS

CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))


class TestTahomaClient:
class TestOverkizClient:
@fixture
def client(self):
return TahomaClient("username", "password", SUPPORTED_SERVERS["somfy_europe"])
return OverkizClient("username", "password", SUPPORTED_SERVERS["somfy_europe"])

@pytest.mark.asyncio
async def test_get_devices_basic(self, client):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_enums.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pyhoma.enums import EventName, FailureType, GatewaySubType, GatewayType
from pyoverkiz.enums import EventName, FailureType, GatewaySubType, GatewayType


class TestGatewayType:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import humps

from pyhoma.enums import DataType
from pyhoma.models import Device, States
from pyoverkiz.enums import DataType
from pyoverkiz.models import Device, States

RAW_STATES = [
{"name": "core:NameState", "type": 3, "value": "alarm name"},
Expand Down

0 comments on commit bb3456f

Please sign in to comment.