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 if config.get('secret').get(API_KEY) is not None: code = config.get('secret').get(API_KEY) if code == "": code = None if hostname is None or code is None: print('No configuration') self.snipshue = SnipsHue(hostname, code) hostname = self.snipshue.hostname code = self.snipshue.username self.update_config(CONFIG_INI, config, hostname, code) self.queue = Queue.Queue() self.thread_handler = ThreadHandler() self.thread_handler.run(target=self.start_blocking) self.thread_handler.start_run_loop()
def __init__(self, cli, dataDir): self.logger = logging.getLogger(APP_LOGGER) self.config = SnipsConfigParser.read_configuration_file(SNIPS_CONF) self.mqttClient = cli self.dataDir = dataDir self.provider = GoogleCalendarProvider(self.config['secret'], self.dataDir)
def __init__(self): config_dict = SnipsConfigParser.read_configuration_file() bridge_ip = config_dict.get(BRIDGE_IP_KEY, None) api_key = config_dict.get(API_KEY_KEY, None) (bridge_ip, api_key, config_changed) = HueSetup.validate_config(bridge_ip, api_key) if config_changed: SnipsConfigParser.write_configuration_file(bridge_ip, api_key) self.snipshue = SnipsHue(bridge_ip, api_key) with Hermes(MQTT_ADDR) as h: h.subscribe_intents(self.callback).start()
def __init__(self): print("[HARMONY] Starting INIT") try: config = SnipsConfigParser.read_configuration_file(CONFIG_INI) except: config = None print("[HARMONY] Config error") # Config variables to fill harmony_ip = None watch_film_activity_id = None # Getting conf if config and config.get('secret', None) is not None: # Get Harmony IP from Config if config.get('secret').get(HARMONY_IP_CONFIG_KEY, None) is not None: harmony_ip = config.get('secret').get(HARMONY_IP_CONFIG_KEY) if harmony_ip == "": harmony_ip = None # Get Activities ID from Config if config.get('secret').get(WATCH_FILM_ACTIVITY_CONFIG_KEY, None) is not None: watch_film_activity_id = config.get('secret').get( WATCH_FILM_ACTIVITY_CONFIG_KEY) if watch_film_activity_id == "": self.WATCH_FILM_ACTIVITY_ID = None else: self.WATCH_FILM_ACTIVITY_ID = watch_film_activity_id if harmony_ip is None or watch_film_activity_id is None: print('No configuration') print("[HARMONY] Creating Harmony Controller") self.harmony_controller = HarmonyController(harmony_ip=harmony_ip) print("[HARMONY] Harmony Controller Ready") self.queue = queue.Queue() self.thread_handler = ThreadHandler() self.thread_handler.run(target=self.start_blocking) self.thread_handler.start_run_loop() print("[HARMONY] Ending INIT")
def __init__(self): config = SnipsConfigParser.read_configuration_file(CONFIG_INI) ip = config.get("secret").get("ip", None) if not ip: print("Could not load [secret][ip] from %s" % CONFIG_INI) sys.exit(1) mac = config.get("secret").get("mac", None) if not mac: print("Could not load [secret][mac] from %s" % CONFIG_INI) sys.exit(1) onkyoip = config.get("secret").get("onkyoip", None) if not onkyoip: print("Could not load [secret][onkyoip] from %s" % CONFIG_INI) sys.exit(1) self.snipslgtv = SnipsLGTV(ip, mac, onkyoip) self.queue = queue.Queue() self.thread_handler = ThreadHandler() self.thread_handler.run(target=self.start_blocking) self.thread_handler.start_run_loop()
port = config.get('global', {"port": "8080"}).get('port', '8080') thermostat = SVT(ip, port) return thermostat def intent_received(hermes, intent_message): intentName = intent_message.intent.intent_name sentence = 'Voila c\'est fait.' print(intentName, sentence) with Hermes(MQTT_ADDR) as h: try: config = SnipsConfigParser.read_configuration_file(CONFIG_INI) except: config = None thermostat = open_thermostat(config) print('Thermostat initialization: OK') try: print("thermostat mode is {}".format(thermostat.mode)) print("thermostat state is {}".format(thermostat.state)) print("thermostat pause is {}".format(thermostat.pause)) # thermostat.mode=10 # print("thermostat mode is {}".format(thermostat.mode)) # print("thermostat state is {}".format(thermostat.state)) # thermostat.state='auto' # thermostat.pause=True
else: sentence = "Je n'ai pas compris s'il fait froid ou s'il fait chaud." else: sentence = "Je ne comprends pas l'action à effectuer avec le thermostat." logger.debug(sentence) hermes.publish_end_session(intent_message.session_id, sentence) return with Hermes(MQTT_ADDR) as h: try: config = SnipsConfigParser.read_configuration_file(configPath) except BaseException: config = None thermostat = None try: thermostat = open_thermostat(config) logger.info('Thermostat initialization: OK') except Exception as e: logger.error('Error Thermostat {}'.format(e)) h.subscribe_intent(THERMOSTATMODE, intent_received)\ .subscribe_intent(THERMOSTATTURNOFF, intent_received)\
def run(self): try: config = SnipsConfigParser.read_configuration_file(configPath) # print configPath, config except: config = None print "Read config.ini error" return start = time.time() zibaseId = config.get('secret').get('zibaseid') tokenId = config.get('secret').get('tokenid') url = 'http://zibase2.net/api/get/ZAPI.php?zibase={}&token={}&service=get&target=home'.format( zibaseId, tokenId) try: resp = requests.get(url) except: print "resp exception when getting {}".format(url) logging.warning('RESP EXCEPTION WHEN GETTING %s' % (threading.current_thread())) resp = None return elapsed = (time.time() - start) * 1000 logging.debug(' RETRIEVE DATA FROM ZIBASE.NET [%d ms]' % (elapsed)) data = json.loads(resp.text) probes = data['body']['probes'] textAnchorY = -25 textYoffset = 32 scope.clear(BLACK) for i, v in enumerate(probes): #print i,v name = v['name'].encode('raw_unicode_escape').decode('utf-8') name = name.upper() id = v['id'] if v['type'] == 'temperature' and id != 'TT13' and id != 'OS439156754' and name != 'FGMS001': #print v timestr = '' temp = '' hum = '' if 'val1' in v: temp = "{:.1f}".format(v['val1']) temp = temp + u'\N{DEGREE SIGN}' + 'C' if 'val2' in v and v['val2'] > 0: hum = str(v['val2']) + '%' if 'time' in v: timestr = str(datetime.fromtimestamp(v['time'])) textAnchorY += textYoffset #print timestr, id, temp, hum, name, textAnchorX, textAnchorY logging.debug(' %s %s %s %s %s ' % (timestr, id, temp, hum, name)) text = zfontSm.render(name + ' ', True, BLACK, LIGHTBLUE) size = zfontSm.size(name) textrect = text.get_rect() textrect.topright = (170, textAnchorY + 8) lcd.blit(logoLightBlue, (170 - size[0] - 20, textAnchorY + 8)) lcd.blit(text, textrect) # textAnchorY+=textYoffset text = zfontTemp.render(temp, True, WHITE) textrect = text.get_rect() textrect.topright = (300, textAnchorY) lcd.blit(text, textrect) pygame.display.update()