Beispiel #1
0
def initialize(language=None):
    global LANGUAGE
    if language is None:
        LANGUAGE = Language(DEFAULT_LANGUAGE)
    else:
        try:
            LANGUAGE = Language(language)
        except ValueError:
            LANGUAGE = Language(DEFAULT_LANGUAGE)
    mqtt_handler.subscribe(LANGUAGE_TOPIC, handle_message)
    logger.debug(LANGUAGE_TOPIC)
def initialize(language=None):
    global LANGUAGE
    if language is None:
        LANGUAGE = DEFAULT_LANGUAGE
    else:
        try:
            LANGUAGE = Language(language)
        except ValueError:
            LANGUAGE = DEFAULT_LANGUAGE
    mqtt_handler.subscribe(LANGUAGE_SET_TOPIC, handle_message)
    logger.debug("Subscribed to topic: {}".format(LANGUAGE_SET_TOPIC))
Beispiel #3
0
 def __init__(self, prefix="mayordomo", device_name="", device_location="", owner="", description=""):
     if not device_name:
         raise ValueError
     self.device_name = device_name
     self.device_location = device_location
     self.device_owner = owner
     self.device_description = description
     self.mayordomo_prefix = prefix
     self.register_topic = "{}/devices/register".format(self.mayordomo_prefix)
     self.answer_topic = "{}/devices/{}/answer".format(self.mayordomo_prefix, self.device_name)
     self.question_counter = 0
     mqtt_handler.subscribe(self.answer_topic, self.answer_handler)
     self.advertise_device()
Beispiel #4
0
 def __init__(self,
              name=None,
              description="",
              owner="unknown",
              location="unknown"):
     if not name:
         raise ValueError
     self.name = name
     self.description = description
     self.owner = owner
     self.location = location
     self.online = 0
     self.device_topic = "mayordomo/devices/{}".format(self.name)
     self.answer_topic = "{}/answer".format(self.device_topic)
     self.online_topic = "{}/$online".format(self.device_topic)
     mqtt_handler.subscribe(self.online_topic, self.online_handler)
def initialize():
    mqtt_handler.subscribe(TTS_TOPIC, message_handler)
    import threading
    threading.Thread(target=initialization).start()
    logger.debug("Subscribed to topic: {}".format(TTS_TOPIC))
Beispiel #6
0
def initialize():
    mqtt_handler.subscribe(REGISTER_TOPIC, handle_message)
    logger.debug("Subscribed to topic: {}".format(REGISTER_TOPIC))
Beispiel #7
0
def __get_audio(text=""):
    tmp_topic = "{}/{}".format(GET_AUDIO_TOPIC, str(uuid.uuid4()))
    payload = json.dumps({"topic": tmp_topic,
                          "audio_info": {"text": text, "language": LANGUAGE, "gender": GENDER}})
    mqtt_handler.subscribe(tmp_topic, __get_audio_response)
    mqtt_handler.publish(GET_AUDIO_TOPIC, payload, 1)
Beispiel #8
0
 def __init__(self, device_name=""):
     self.device_name = device_name
     self.device_location = self.device_name.split("_")[1]
     self.answer_topic = "mayordomo/{}/+".format(self.device_name)
     mqtt_handler.subscribe(self.answer_topic, self.__on_answer)
def initialize():
    session_handler.initialize()
    mqtt_handler.subscribe(INPUT_MESSAGE_TOPIC, handle_message)
    logger.debug("Subscribed to topic: {}".format(INPUT_MESSAGE_TOPIC))