Skip to content

Commit

Permalink
chore: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bj00rn committed Dec 11, 2023
1 parent 9ac4d69 commit a8d740d
Showing 1 changed file with 20 additions and 32 deletions.
52 changes: 20 additions & 32 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ pysaleryd

Python library for controlling Saleryd HRV system using the built in websocket server used by Saleryd HRV Homeassistant integration https://github.com/bj00rn/ha-saleryd-ftx

Maintains a reconnecting websocket to the system.

Supported devices
==================

LOKE1/Loke Basic/LS-01 using control system 4.1.1
LOKE1/Loke Basic/LS-01 using control system 4.1.5

Usage with asyncio as library
=============================
Expand All @@ -38,28 +39,34 @@ Read data
.. code-block:: python3
import asyncio
import aiohttp
from pysaleryd.client import Client
async with Client(WEBSOCKET_URL, WEBSOCKET_PORT) as hrv_client:
await asyncio.sleep(2) # wait a bit for some data
print(client.data)
async with aiohttp.ClientSession() as session:
async with Client(WEBSOCKET_URL, WEBSOCKET_PORT, session) as hrv_client:
await asyncio.sleep(2) # wait a bit for some data
print(client.data)
Read data using callback
------------------------

.. code-block:: python3
import asyncio
import aiohttp
from pysaleryd.client import Client
def handle_messge(raw_message: str):
print(msg)
def handle_message(data: dict):
print(data)
async with Client(WEBSOCKET_URL, WEBSOCKET_PORT) as hrv_client:
hrv_client.add_handler(handle_message)
await asyncio.sleep(3) # wait around a bit for data
update_interval = 10 # call handle_message every 30 seconds
async with aiohttp.ClientSession() as session:
async with Client(WEBSOCKET_URL, WEBSOCKET_PORT, session, update_interval) as hrv_client:
hrv_client.add_handler(handle_message)
await asyncio.sleep(update_interval +1 ) # wait around a bit for data
Send control command
--------------------
Expand All @@ -68,32 +75,13 @@ Command syntax can be found by dissecting websocket messages in the built in web
.. code-block:: python3
import asyncio
import aiohttp
from pysaleryd.client import Client
async with Client(WEBSOCKET_URL, WEBSOCKET_PORT) as hrv_client:
await hrv_client.send_command("MF", 0) # send command to set fan mode
CLI usage
=========

List command line usage

.. code-block:: shell
$ pysaleryd -h
Connect to system and capture websocket data to stdout

.. code-block:: shell
$ pysaleryd --host WEBSOCKET_URL --port WEBSOCKET_PORT --listen [-t TIMEOUT]
Send command to system

.. code-block:: shell
$ pysaleryd --host WEBSOCKET_URL --port WEBSOCKET_PORT --send --key MF --data 0
async with aiohttp.ClientSession() as session:
async with Client(WEBSOCKET_URL, WEBSOCKET_PORT, session) as hrv_client:
await hrv_client.send_command("XX", 1)
Troubleshooting
===============
Expand Down

0 comments on commit a8d740d

Please sign in to comment.