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 underlyingProperty_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
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
homie-helpers-0.0.2.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for homie_helpers-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 499bc0e328ef168ebbb43cd719bb6103df6d44960917e3c589aaededecbe18c4 |
|
MD5 | 92759096d177991d112f5d59aa3da6b3 |
|
BLAKE2b-256 | ad9409e0d9679ca5e910b55aadb5402d3dc4c9c37275e913e04bc538fa39546c |