Example #1
0
def main():
    homie = HomieDevice(settings)
    homie.add_node(DHT22(pin=4))

    homie.publish_properties()

    homie.start()
Example #2
0
def main():
    # Homie device setup
    homie_device = HomieDevice(settings)

    # Adds a simple test node
    n = SimpleHomieNode(node_type=b'dummy', node_property=b'value',
                        interval=5)
    homie_device.add_node(n)

    # Push information about the device to MQTT
    homie_device.publish_properties()

    while True:
        # Update the data of the simple note for demonstration purpose
        n.value = utime.time()
        print("UPDATED: ".format(n))

        # Push the new data to MQTT
        homie_device.publish_data()

        # Sleep a little bit
        utime.sleep(1)
Example #3
0
import utime
import settings

from homie.node.simple import SimpleHomieNode
from homie import HomieDevice

# Homie device setup
homie_device = HomieDevice(settings)

# Adds a simple test node
n = SimpleHomieNode(node_type=b'dummy', node_property=b'value', interval=5)
homie_device.add_node(n)

# Push information about the device to MQTT
homie_device.publish_properties()

while True:
    # Update the data of the simple note for demonstration purpose
    n.value = utime.time()
    print("UPDATED: ".format(n))

    # Push the new data to MQTT
    homie_device.publish_data()

    # Sleep a little bit
    utime.sleep(1)
Example #4
0
from homie.node.led import LED
from homie import HomieDevice

CONFIG = {
    'mqtt': {
        'broker': 'localhost',
        'base_topic': b'uhomie'
    },
    'device': {
        'id': b'esp8266',
    }
}

homie = HomieDevice(CONFIG)

# Add LED node to device
homie.add_node(LED(pin=2))

# publish device and node properties
homie.publish_properties()

while True:

    # publish device data
    homie.publish_data()

    # check for new mqtt messages
    homie.mqtt.check_msg()

    utime.sleep(1)
Example #5
0
import utime
import settings

from homie.node.simple import SimpleHomieNode
from homie import HomieDevice

homie = HomieDevice(settings)

node = SimpleHomieNode("nodetype", "node_property")

homie.add_node(node)

# publish device and node properties
homie.publish_properties()

while True:

    # publish device data
    homie.publish_data()

    node.value = utime.time()

    utime.sleep(1)
Example #6
0
import utime
import settings

from homie.node.error import Error
from homie import HomieDevice
from machine import WDT


wdt = WDT(timeout=3000)

homie = HomieDevice(settings)

homie.add_node(Error())

# publish device and node properties
homie.publish_properties()

while True:
    # reset the errors
    homie.errors = 0

    # publish device data
    homie.publish_data()

    # feed wdt if we have no errors
    if not homie.errors:
        wdt.feed()

    utime.sleep(1)
Example #7
0
"""Example main.py for a Microhomie device with dht22 node"""

import utime
import settings

from homie.node.dht22 import DHT22
from homie import HomieDevice


homie = HomieDevice(settings)
homie.add_node(DHT22(pin=4))

homie.publish_properties()

while True:
    homie.publish_data()
    utime.sleep(1)
Example #8
0
    def get_data(self):
        raise Exception('ErrorNode Test Exception - get_data')

    def update_data(self):
        raise Exception('ErrorNode Test Exception - update_data')

    def callback(self, topic, payload):
        raise Exception('ErrorNode Test Exception - callback')

    def broadcast_callback(self, payload):
        raise Exception('ErrorNode Test Exception - broadcast_callback')

    def get_node_id(self):
        raise Exception('ErrorNode Test Exception - get_node_id')


homie_device = HomieDevice(settings)

n = SimpleHomieNode(node_type=b'dummy', node_property=b'value', interval=5)
n.value = 17

homie_device.add_node(n)
homie_device.add_node(Error())
homie_device.publish_properties()

while True:
    homie_device.publish_data()
    n.value = utime.time()
    print('INFO: {}'.format(n))
    utime.sleep(1)