Skip to main content

LINE Works SDK for Python

Project description

line-works-sdk

LINE Works SDK for Python

Requirements

Python 3.11+

Installation

$ pip install line-works-sdk

dev version

https://pypi.org/project/line-works-sdk/#history

$ pip install line-works-sdk==x.x.devyyyymmddHHMM

Usage

from line_works.client import LineWorks
from line_works.mqtt.enums.packet_type import PacketType
from line_works.mqtt.models.packet import MQTTPacket
from line_works.mqtt.models.payload.message import MessagePayload
from line_works.tracer import LineWorksTracer


def receive_publish_packet(w: LineWorks, p: MQTTPacket) -> None:
    payload = p.payload

    if not isinstance(payload, MessagePayload):
        return

    if not payload.channel_no:
        return

    print(f"{payload!r}")

    if payload.loc_args1 == "test":
        w.send_message(payload.channel_no, "ok")

    elif payload.loc_args1 == "/msg":
        w.send_message(payload.channel_no, f"{payload!r}")


WORKS_ID = "YOUR WORKS ID"
PASSWORD = "YOUR WORKS PASSWORD"

works = LineWorks(works_id=WORKS_ID, password=PASSWORD)

my_info = works.get_my_info()
print(f"{my_info=}")

tracer = LineWorksTracer(works=works)
tracer.add_trace_func(PacketType.PUBLISH, receive_publish_packet)
tracer.trace()

sample_usage

Contributors

GitHub Actions

The following linter results are detected by GitHub Actions.

  • ruff
  • mypy

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

line_works_sdk-2.0.dev202501071912.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

line_works_sdk-2.0.dev202501071912-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

Details for the file line_works_sdk-2.0.dev202501071912.tar.gz.

File metadata

File hashes

Hashes for line_works_sdk-2.0.dev202501071912.tar.gz
Algorithm Hash digest
SHA256 b810c5f2f6c75d283f0150fb18261f8e26310f0452a5952cd2ac772f02c51aa4
MD5 590d3bc5da1a06947bfa3dc86375f113
BLAKE2b-256 e035072884fb09e954f7b23118ef1f19b7c5fae51068875b738997b830ea8a2c

See more details on using hashes here.

File details

Details for the file line_works_sdk-2.0.dev202501071912-py3-none-any.whl.

File metadata

File hashes

Hashes for line_works_sdk-2.0.dev202501071912-py3-none-any.whl
Algorithm Hash digest
SHA256 838508b6cb457f69245048b778c976b346f3ef840c324d048c9fd2a06eef0b81
MD5 1fc0e33ff2d3f0bed212250c422497a7
BLAKE2b-256 540a5604fad2651d74c097d7b6263672249508cf9b12c6900bd19967219c3537

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