def main():
    wdt = WDT(timeout=3000)

    homie = HomieDevice(settings)

    homie.add_node(Error())

    # publish device and node properties
    homie.publish_properties()

    # subsribe to topics
    homie.subscribe_topics()

    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)
Exemple #2
0
def main():
    homie = HomieDevice(settings)

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

    homie.add_node(n)
    homie.publish_properties()

    while True:
        homie.publish_data()
        n.value = utime.time()
        print(n)
        utime.sleep(1)
Exemple #3
0
def main():
    homie = HomieDevice(settings)

    # 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)