Skip to main content

homie-spec

PyPI pyversions GitHub license PyPI version shields.io

Maintenance Coverage Build Status

homie-spec is a Python library that models the v4 Homie Convention.

This package has no dependencies other than Python >=3.6. Since it doesn't implement MQTT this also means it's fairly useless on it's own, as it has no ability to interact with any MQTT broker on it's own.

The goal of this package is to provide a data-driven library to easily create devices, nodes and properties. These can also be published to be used by anyone. Another package (WIP), will bridge the MQTT protocol and homie-spec.

Relevant external links:

Installation

Use the package manager pip to install homie-spec.

pip install homie-spec

Usage

from homie_spec import Device, Node, Property
from homie_spec.properties import Datatype


localtime = Node(
    name="Local time",
    typeOf="clock",
    properties={
        "color-repr": Property(
            name="Color representation", datatype=Datatype.COLOR, get=lambda: "233,102,23"
        ),
        "time": Property(
            name="HH:MM representation", datatype=Datatype.STRING, get=lambda: "20:20"
        ),
    },
)

desktop = Device(id="desktop", name="Desktop Computer", nodes={"local-time": localtime})

for msg in desktop.messages():
    print(msg.attrs)
print(desktop.getter_message('local-time/time').attrs)
print(desktop.getter_message('local-time/color-repr').attrs)

"""
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/$state',                          'payload': 'init'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/$name',                           'payload': 'Desktop Computer'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/$homie',                          'payload': '4.0.0'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/$implementation',                 'payload': 'homie-spec'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/$nodes',                          'payload': 'local-time'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/local-time/$name',                'payload': 'Local time'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/local-time/$type',                'payload': 'clock'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/local-time/$properties',          'payload': 'color-repr,time'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/local-time/color-repr/$name',     'payload': 'Color representation'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/local-time/color-repr/$datatype', 'payload': 'color'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/local-time/time/$name',           'payload': 'HH:MM representation'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/local-time/time/$datatype',       'payload': 'string'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/$state',                          'payload': 'ready'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/local-time/time',                 'payload': '20:20'}
{'retained': True, 'qos': 1, 'topic': 'homie/desktop/local-time/color-repr',           'payload': '233,102,23'}
"""

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Metadata

Release files for homie-spec 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for homie-spec 0.5.0
File Size Uploaded Provenance Actions
homie-spec-0.5.0.tar.gz 9.2 kB Without provenance Details for homie-spec-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for homie-spec 0.5.0
File Interpreter ABI Platform Actions
homie_spec-0.5.0-py3-none-any.whl Python 3 none any Details for homie_spec-0.5.0-py3-none-any.whl

Total release size: 18.8 kB

Release files / homie-spec-0.5.0.tar.gz

Download URL homie-spec-0.5.0.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
abe90f3d2f67b91cec87e9db45e0c3d584e89bb22932d82ddc0281051df2fd95
BLAKE2b-256 checksum
How to use checksums
fe297129d1332ec15214605820028bbf3257150d2155714f3418d6fa9a2d481c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.2 Linux/5.13.0-1029-azure

Release files / homie_spec-0.5.0-py3-none-any.whl

Download URL homie_spec-0.5.0-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
197b40090b474c5a033dafb61763ef4b96ca9f0b78e6743837e3dd270ee25987
BLAKE2b-256 checksum
How to use checksums
2b5150c53d8eee9e21d7ee12079028deba830e8c9ac4753cfb9008516635b43c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.2 Linux/5.13.0-1029-azure

Security for homie-spec 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page