Skip to main content

A set of helpers for implementing Homie IoT Convention

Project description

homie-helpers

Yet another python implementation of Homie Convection

In fact, it's a wrapper around another library Homie4 - just with changed API

Quick start

There are two possible approaches - choose one that suits you more!

Approach 1: setting properties using device object

# Let's create settings first...
SETTINGS = HomieSettings('mqtt.eclipseprojects.io', port=1883, username='...' password='...')

# Callback for 'ison' property
def set_enabled(value):
    print('Turning %s' % ('on' if value else 'off'))

# Create Homie object
# At this moment the MQTT messages will be sent!
homie = Homie(SETTINGS, "my-thermometer", nodes=[
    Node("status", properties=[
        FloatProperty("temperature", unit="C"),             # client cannot modify this property
        BooleanProperty('ison', set_handler=set_enabled)    # client CAN modify this property - will call callback
    ])
])

homie['temperature'] = 20.0

Approach 2: setting properties using property objects

# Let's create settings first...
SETTINGS = HomieSettings('mqtt.eclipseprojects.io', port=1883, username='...' password='...')

# Callback for 'ison' property
def set_enabled(value):
    print('Turning %s' % ('on' if value else 'off'))

property_temperature = FloatProperty("temperature", unit="C"),      # client cannot modify this property
property_ison = BooleanProperty('ison', set_handler=set_enabled)    # client CAN modify this property - will call callback 
    
# Create Homie object
# At this moment the MQTT messages will be sent!
homie = Homie(SETTINGS, "my-thermometer", nodes=[
    Node("status", properties=[property_temperature, property_ison])

property_temperature.value = 20.0

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.7.dev1677103136.tar.gz (7.7 kB view details)

Uploaded Source

File details

Details for the file homie-helpers-0.0.7.dev1677103136.tar.gz.

File metadata

File hashes

Hashes for homie-helpers-0.0.7.dev1677103136.tar.gz
Algorithm Hash digest
SHA256 0ae18af73c3f9da63836b39c1a390bdbf2f467c45e577a8e09707307dc343be7
MD5 5af17ce30dd9402a040afac73f8565dc
BLAKE2b-256 4c4a3c38e1e2315b14f5266c5d0e18798aab091ae76f3ec335de145260d5916e

See more details on using hashes here.

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