示例#1
0
def main():
    # Initialize the Homie device
    device = HomieDevice(settings)

    # Initialize the Homie node for the onboard LED
    led_node = HomieNode(
        id="led",
        name="Onboard LED",
        type="LED",
    )

    # Initialize the Homie property to power on/off the led
    led_power = HomieProperty(
        id="power",
        name="Power",
        settable=True,
        datatype=BOOLEAN,
        default=FALSE,
        on_message=toggle_led,
    )

    # Add the power property to the node
    led_node.add_property(led_power)

    # Add the led node to the device
    device.add_node(led_node)

    # Run
    device.run_forever()
示例#2
0
def main():
    # Homie device setup
    homie = HomieDevice(settings)

    # Add dht22 node
    homie.add_node(DHT22(pin=4))

    # run forever
    homie.run_forever()
示例#3
0
def main():
    # Homie device setup
    homie = HomieDevice(settings)

    # Add PIR node to device
    homie.add_node(PIR())

    # run forever
    homie.run_forever()
示例#4
0
def main():
    homie = HomieDevice(settings)

    homie.add_node(
        AmbientLight(
            pin=4,
            leds=3
        )
    )

    homie.run_forever()
示例#5
0
def main():
    relay1 = ShellyRelay("relay1",
                         rpin=4,
                         swpin=5,
                         name="Light Switch 1",
                         type="Shelly 2.5")
    relay2 = ShellyRelay("relay2",
                         rpin=15,
                         swpin=13,
                         name="Light Switch 2",
                         type="Shelly 2.5")

    homie = HomieDevice(settings)
    homie.add_node(relay1)
    homie.add_node(relay2)

    homie.run_forever()
示例#6
0
def main():
    i2c = I2C(scl=Pin(16), sda=Pin(17))

    bmp280 = bme280.BME280(i2c=i2c)

    bmp280Node = BMP280Node(id="bmp280",
                            name="Enviroment-Sensor",
                            bmp280=bmp280)

    leds = neopixel.NeoPixel(Pin(23, Pin.OUT), 28)

    controlNode = LEDControlNode(id="leds1",
                                 name="LEDs",
                                 pin_up=Pin(18),
                                 pin_down=Pin(5),
                                 leds=leds)

    # Homie device setup
    homie = HomieDevice(settings)
    homie.add_node(bmp280Node)
    homie.add_node(controlNode)

    # run forever
    homie.run_forever()
示例#7
0
def main():
    homie = HomieDevice(settings)
    homie.add_node(SmartSocket())
    homie.run_forever()
示例#8
0
def main():
    homie = HomieDevice(settings)
    homie.add_node(HTTP(url="http://10.0.0.1/status.html"))
    homie.run_forever()
示例#9
0
def main():
    homie = HomieDevice(settings)
    homie.add_node(DS18B20())
    homie.run_forever()
示例#10
0
def main():
    # homie
    homie = HomieDevice(settings)
    homie.add_node(K30(device=homie))
    homie.run_forever()
def main():
    # homie
    print("homie main")
    homie = HomieDevice(settings)
    homie.add_node(WeatherSensor(device=homie))
    homie.run_forever()