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

    homie.publish_properties()

    homie.start()
Beispiel #2
0
    def init_homie_device(self):
        homie_device = HomieDevice("spotibridge", self.mqttc)
        homie_device.name = "Spotibridge"
        homie_device.implementation = "SpotiBridge"
        homie_device.version = Version("4.0.0")
        homie_device.extensions = set()

        node = HomieNode("player", homie_device, True)
        node.name = "Player"
        node.type = "player"

        is_playing_property = HomieProperty("is-playing", node, True)
        is_playing_property.name = "Is Playing"
        is_playing_property.datatype = HomieDataType.BOOLEAN
        is_playing_property.value = False

        current_track_property = HomieProperty("track", node, True)
        current_track_property.name = "Track"
        current_track_property.datatype = HomieDataType.STRING
        current_track_property.value = ""

        dominant_album_color_property = HomieProperty("dominant-album-color",
                                                      node, True)
        dominant_album_color_property.name = "Dominant album color"
        dominant_album_color_property.datatype = HomieDataType.COLOR
        dominant_album_color_property.format = "rgb"
        dominant_album_color_property.value = (0, 0, 0)

        album_cover_palette_property = HomieProperty("album-cover-palette",
                                                     node, True)
        album_cover_palette_property.name = "Album cover color palette"
        album_cover_palette_property.datatype = HomieDataType.STRING
        album_cover_palette_property.value = "[]"

        self.homie_device = homie_device
Beispiel #3
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)
Beispiel #4
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)
Beispiel #5
0
import utime

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()
Beispiel #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)
Beispiel #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)
Beispiel #8
0
The onboard led status is reversed to the pin status. On start the onboard
LED is on. To turn it off send 'on' or 'toggle' via mqtt:

$ mosquitto_pub -t 'uhomie/esp8266/led/power/set' -m on
$ mosquitto_pub -t 'uhomie/esp8266/led/power/set' -m off
$ mosquitto_pub -t 'uhomie/esp8266/led/power/set' -m toggle
"""

import utime
import settings

from homie.node.led import LED
from homie import HomieDevice

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()
import utime

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

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

homie = HomieDevice(CONFIG)

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