Skip to main content

A set of helpers for implementing Homie IoT Convention

Project description

homie-helpers

Set of helpers for making https://github.com/mjcumming/Homie4 more developer-friendly.

Example

from homie.device_base import Device_Base
from homie_helpers import add_property_int, add_property_boolean, add_property_string


class SonyBravia(Device_Base):
    def __init__(self, device_id, mqtt_settings):
        super().__init__(device_id=device_id, name="Sony Bravia Android TV", mqtt_settings=mqtt_settings)

        self.property_volume = add_property_int(self, "volume-level",
                                                parent_node_id='volume',
                                                min_value=0,
                                                max_value=80,
                                                set_handler=self.set_volume)

        add_property_boolean(self, "reboot", parent_node_id='power', retained=False, set_handler=self.reboot)

        self.property_player_app = add_property_string(self, "player-app", parent_node_id="player")

Available helpers

def add_property_int(device: Device_Base,
                     property_id: str,
                     property_name: str = None,
                     parent_node_id: str = "status",
                     parent_node_name: str = None,
                     set_handler=None,
                     unit=None,
                     min_value: int = None,
                     max_value: int = None,
                     meta: dict = {}) -> Property
def add_property_float(device: Device_Base,
                       property_id: str,
                       property_name: str = None,
                       parent_node_id: str = "status",
                       parent_node_name: str = None,
                       set_handler=None,
                       unit=None,
                       min_value: int = None,
                       max_value: int = None,
                       meta: dict = {}) -> Property
def add_property_boolean(device: Device_Base,
                         property_id: str,
                         property_name: str = None,
                         parent_node_id: str = "status",
                         parent_node_name: str = None,
                         set_handler=None,
                         retained: bool = True,
                         unit=None,
                         meta: dict = {}) -> Property
def add_property_enum(device: Device_Base,
                      property_id: str,
                      property_name: str = None,
                      parent_node_id: str = "status",
                      parent_node_name: str = None,
                      set_handler=None,
                      unit=None,
                      values: list = [],
                      meta: dict = {}) -> Property
def add_property_string(device: Device_Base,
                        property_id: str,
                        property_name: str = None,
                        parent_node_id: str = "status",
                        parent_node_name: str = None,
                        retained: bool = True,
                        unit: str = None,
                        data_format: str = None,
                        set_handler=None,
                        meta: dict = {}) -> Property

All of these helpers return an object of class Property, which is a wrapper around Property_Base from Homie4. Property has the following members:

  • property value - the value of property
  • property meta - the metadata in a simple key-value dict format
  • method raw_property() - returns the underlying Property_Base object

All of these helpers accept meta as dict (a simple key-value dict). It will be automatically converted to required format.

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

homie-helpers-0.0.2.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

homie_helpers-0.0.2-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

Supported by

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