Websocket Client for Crescience devices
Project description
\n# Crescience Websocket Client
Websocket client for Crescience devices written in python.
Requirements
- python>=3.7
- pip
Installation
You can install the client using pip
:
pip install crescience-websocket-py
Usage
The client provides two different usage cases:
Callback
from crescience_websocket_py import WebsocketClient, Message, ConnectionMessageType
def callback(msg_type: ConnectionMessageType, msg: Message | None, error:ConnectionErrorReason | None) -> None:
if msg_type==ConnectionMessageType.TEXT:
print(f"Received message: {str(msg)}")
elif msg_type==ConnectionMessageType.OPEN:
print("Connection opened")
elif msg_type==ConnectionMessageType.ERROR:
print(f"Connection error: {error}")
elif msg_type==ConnectionMessageType.CLOSE:
print("Connection closed")
client=WebsocketClient(
host="<IP_OR_DOMAIN>",
port=81,
verify_ssl=False,
callback=callback
)
Class inheritance
from crescience_websocket_py import WebsocketClient, Message, ConnectionMessageType
class MyCrescienceClient(WebsocketClient):
def __init__(self, host:str) -> None:
super().__init__(host=host, port=81, verify_ssl=False)
async def received(self, msg: Message) -> None:
print(f"Received message: {str(msg)}")
async def on_open(self) -> None:
print("Connection opened")
async def on_close(self) -> None:
print("Connection closed")
async def on_error(self, error:ConnectionMessageType) -> None:
print(f"Connection error: {error}")
client=MyCrescienceClient("<IP_OR_DOMAIN>")
Check for firmware-updates
You can check if firmware updates are available using the following command:
from crescience_websocket_py import get_latest_version
latest_version = get_latest_version(device_type="crescontrol")
print(latest_version["version"])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for crescience_websocket_py-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2ef94b3b966482e191ba376e4cac4a59e48905d756a2558947f75ded5c57571 |
|
MD5 | 4f3cbfa328ef51ffa4eef4f1bf0d14a8 |
|
BLAKE2b-256 | cddc1a3db5c773c7abb4c74961060860a33edb136b69079f66118702ca746b80 |
Close
Hashes for crescience_websocket_py-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6d639807d209ba138e78f33dc63888cf59d2f11572f789c24f41d91427d7bca |
|
MD5 | 2159b23f70b2ce019319dfa978fdccc4 |
|
BLAKE2b-256 | a4f6cfa0415d47d92793d5ef67a093a0cfa3dc3f6fbd1592bd58402bb8dcc684 |