Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crescience_websocket_py-0.0.3.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crescience_websocket_py-0.0.3-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file crescience_websocket_py-0.0.3.tar.gz.

File metadata

  • Download URL: crescience_websocket_py-0.0.3.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for crescience_websocket_py-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b605fcb8fb29f2b6b9d09b92ba777715d5ee1d40bf121bd841a542c58cb01313
MD5 0172d4fa10a3a006651d12ece56d5e93
BLAKE2b-256 02a38ae79cd7213c4c85567996bf0381eb4c5a5de56ac8822ea98946d0501429

See more details on using hashes here.

File details

Details for the file crescience_websocket_py-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for crescience_websocket_py-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f54340ea43a7f4efd31284248fab3b7abfadaa1064cf7cb521acea327b487f3c
MD5 817ad64cf91306d5fb1ae6f8d4c893d8
BLAKE2b-256 8feb7bd7b109f2ca7704ee9d3993ef615eaf9c5669b6f32f2db752f2a3dc036d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page