def main(): path = os.path.dirname(os.path.realpath(__file__)) config = homie.loadConfigFile( "{path}/configs/manage.json".format(path=path)) Homie = homie.Homie(config) m = Manager(None, Homie) m.run()
def main(): d = db() config = homie.loadConfigFile("configs/sonos.json") Homie = homie.Homie(config) sonos = Sonos(d, Homie) Homie.setFirmware("sonos", "1.0.0") Homie.setup() try: while True: sonos.loopHandler() finally: sonos.shutdown()
def main(): d = db() config = homie.loadConfigFile("configs/daapd.json") Homie = homie.Homie(config) daapd = Daapd(d, Homie) Homie.setFirmware("daapd", "1.0.0") Homie.setup() try: while True: daapd.loopHandler() finally: daapd.shutdown()
def main(): args = parse_args() config_dir = args.config_dir or "config" config = homie.loadConfigFile(f"{config_dir}/huebridge.json") Homie = homie.Homie(config) hue = Huebridge(Homie, args, config) Homie.setFirmware("huebridge", "1.0.0") Homie.setup() try: while True: time.sleep(1) finally: hue.shutdown()
#!/usr/bin/env python # -*- coding: UTF-8 -*- import time import homie import logging import random logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) TEMPERATURE_INTERVAL = 3 config = homie.loadConfigFile("homie-python.json") Homie = homie.Homie(config) temperatureNode = Homie.Node("temperature", "temperature") humidityNode = Homie.Node("humidity", "humidity") relayNode = Homie.Node("relay","relay") def main(): Homie.setFirmware("awesome-temperature", "1.0.0") temperatureNode.advertise("value") temperatureNode.advertise("unit") humidityNode.advertise("value") humidityNode.advertise("unit") relayNode.advertise("value") temperatureNode.advertise("unit") Homie.setup()
import logging import os import glob logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) os.system('modprobe w1-gpio') os.system('modprobe w1-therm') base_dir = '/sys/bus/w1/devices/' device_folder = glob.glob(base_dir + '28*')[0] device_file = device_folder + '/w1_slave' TEMPERATURE_INTERVAL = 60 config = homie.loadConfigFile("homie-python.json") Homie = homie.Homie(config) temperatureNode = Homie.Node("temperature", "temperature") def read_temp_raw(): f = open(device_file, 'r') lines = f.readlines() f.close() return lines def read_temp(): lines = read_temp_raw() while lines[0].strip()[-3:] != 'YES': time.sleep(0.2) lines = read_temp_raw() equals_pos = lines[1].find('t=')