Skip to content

Commit

Permalink
Tidy CI pipelines and publoish on tag
Browse files Browse the repository at this point in the history
  • Loading branch information
inverse committed Nov 1, 2023
1 parent 90bd777 commit 068185c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
${{ runner.os }}-poetry-
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Install poetry
uses: abatilo/[email protected]
with:
poetry-version: '1.3.2'
poetry-version: '1.6.1'
- name: Install pip dependencies
run: poetry install
- name: pre-commit
Expand All @@ -34,7 +34,7 @@ jobs:
strategy:
matrix:
python-version: ['3.11', '3.10', '3.9', '3.8', '3.7']
poetry-version: ['1.3.2']
poetry-version: ['1.6.1']
runs-on: ubuntu-20.04
env:
IS_COVERAGE_ALLOWED: ${{ secrets.CODECOV_TOKEN != '' }}
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ jobs:
- uses: actions/checkout@master
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Install poetry
uses: abatilo/[email protected]
with:
poetry-version: '1.3.2'
poetry-version: '1.6.1'
- name: Install pip dependencies
run: poetry install
- name: Package
run: poetry build
run: |
poetry version ${{ github.event.release.tag_name }}
poetry build
- name: Publish to PyPI
uses: pypa/[email protected]
with:
Expand Down
50 changes: 42 additions & 8 deletions iolite_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from base64 import b64encode
from collections import defaultdict
from dataclasses import dataclass
from typing import Dict, List, Optional, Union
from typing import Dict, List, Optional, Union, Callable

import websockets

Expand Down Expand Up @@ -144,6 +144,47 @@ def __init__(self, sid: str, username: str, password: str):
self.sid = sid
self.username = username
self.password = password
self.messages = []

async def _consumer_handler(self, websocket):
async for message in websocket:

# TODO: Build up discovered

# TODO: add handlers to getting updates

await consumer(message)

async def _producer_handler(self, websocket):
while True:
if len(self.messages) == 0:
# TODO: potentially send key alive each 5 seconds
await asyncio.sleep(1)
continue

message = self.messages.pop()
await self.__send_request(message, websocket)


async def _handler(self, websocket):
await asyncio.gather(
self._consumer_handler(websocket),
self._producer_handler(websocket),
)


async def start(self):
self.messages.append(self.request_handler.get_subscribe_request("places"))
self.messages.append(self.request_handler.get_subscribe_request("devices"))
self.messages.append(self.request_handler.get_query_request("situationProfileModel"))

uri = f"{self.BASE_URL}/bus/websocket/application/json?SID={self.sid}"
async with websockets.connect(uri, extra_headers=self._get_default_headers()) as websocket:
self._handler(websocket)

async def async_set_temp(self, device_id: str, temp: float):
self.messages.append(self.request_handler.get_action_request(device_id, temp))


@staticmethod
async def __send_request(request: Union[str, dict], websocket):
Expand Down Expand Up @@ -303,10 +344,3 @@ async def async_discover(self):
def discover(self):
"""Discovers the entities registered within the heating system."""
asyncio.run(self.async_discover())

async def async_set_temp(self, device, temp: float):
request = self.request_handler.get_action_request(device, temp)
await asyncio.create_task(self._fetch_application([request]))

def set_temp(self, device, temp: float):
asyncio.run(self.async_set_temp(device, temp))
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "iolite-client"
version = "0.6.0"
version = "0.0.0"
description = "API client for interacting with IOLite's remote API"
authors = ["Malachi Soord <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 068185c

Please sign in to comment.