from hermes_python.hermes import Hermes MQTT_IP_ADDR = "localhost" MQTT_PORT = 1883 MQTT_ADDR = "{}:{}".format(MQTT_IP_ADDR, str(MQTT_PORT)) lang = "EN" def setAlarm(hermes, intent_message): every = Extract.value(intent_message.slots.recurrence, None) is not None day = Extract.value(intent_message.slots.weekday) time = Extract.timeSlot(intent_message.slots.time) siteId = intent_message.site_id room = Extract.value(intent_message.slots.timer_room, "bedRoom") hermes.alarm.add(every, time, day, siteId, room) def stopTimer(hermes, intent_message): current_session_id = intent_message.session_id tag = Extract.values(intent_message.slots.tag) hermes.alarm.remove(tag) if __name__ == "__main__": lang = Concierge.getLang() c = Concierge(MQTT_IP_ADDR) a = Alarm(c) with Hermes(MQTT_ADDR) as h: h.alarm = a h.subscribe_intent("snips-labs:SetAlarm_" + lang, setAlarm) \ .subscribe_intent("snips-labs:StopTimer_" + lang, stopTimer) \ .loop_forever()
from snipshue.snipshue import SnipsHue from snipshelpers.thread_handler import ThreadHandler from snipshelpers.config_parser import SnipsConfigParser import Queue CONFIGURATION_ENCODING_FORMAT = "utf-8" CONFIG_INI = expanduser("~/.hue/config.ini") CONFIG_INI_DIR = expanduser("~/.hue/") MQTT_IP_ADDR = "localhost" MQTT_PORT = 1883 MQTT_ADDR = "{}:{}".format(MQTT_IP_ADDR, str(MQTT_PORT)) API_KEY = "api_key" _id = "snips-skill-hue" c = Concierge(MQTT_IP_ADDR) class Skill: def __init__(self): try: config = SnipsConfigParser.read_configuration_file(CONFIG_INI) except: config = None hostname = None code = None if config and config.get('secret') is not None: if config.get('secret').get('hostname') is not None: hostname = config.get('secret').get('hostname') if hostname == "": hostname = None
import signal import sys from concierge_python.concierge import Concierge from conciergeMatrix import ConciergeMatrix from remote import Remote if __name__ == "__main__": def sig_handler(sig, frame): c.disconnect() m.stop() if r: r.stop() sys.exit(0) site_id = 'default' site_id = 'remote' MQTT_IP_ADDR = "raspi-mika.local" signal.signal(signal.SIGINT, sig_handler) c = Concierge(MQTT_IP_ADDR, site_id, False) m = ConciergeMatrix(site_id, c) r = None try: r = Remote(site_id, c) r.start() except: print("error occured") pass c.loop_forever()
if (not self.bPressed and self.rotarySet <= 0): self.haveBeenMoved = Remote.MOVE_COUNTER print("haveBeenMoved") def on_lup(self): print("lup") def on_ldown(self): print("ldown") def on_near(self): print("near") def on_far(self): print("far") if __name__ == "__main__": def sig_handler(sig, frame): c.disconnect() a.stop() sys.exit(0) MQTT_IP_ADDR = "raspi-mika.local" signal.signal(signal.SIGINT, sig_handler) c = Concierge(MQTT_IP_ADDR, "default", False) a = Remote("default", c) a.start() c.loop_forever()