Ejemplo n.º 1
0
            weekday_list = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag']
            result_sentence = "Heute haben wir {weekday}.".format(weekday=weekday_list[weekday - 1])
        elif datetype == 'year':
            year = datetime.datetime.now().year
            result_sentence = "Wir sind im Jahr {year}".format(year=year)
        elif datetype == 'weeknumber' or 'kw' in datetype:
            weeknumber = datetime.datetime.now().isocalendar()[1]
            result_sentence = "Wir haben gerade die Kalenderwoche {weeknumber}".format(weeknumber=weeknumber)
        elif datetype == 'minute':
            minutes = datetime.datetime.now().minute
            result_sentence = "Wir haben die Minute {minutes}".format(minutes=minutes)
        elif datetype == 'hour':
            hours = datetime.datetime.now().hour
            result_sentence = "Wir haben gerade die Stunde {hours}".format(hours=hours)
        current_session_id = intent_message.session_id
        hermes.publish_end_session(current_session_id, result_sentence)


if __name__ == "__main__":
    snips_config = toml.load('/etc/snips.toml')
    if 'mqtt' in snips_config['snips-common'].keys():
        MQTT_BROKER_ADDRESS = snips_config['snips-common']['mqtt']
    if 'mqtt_username' in snips_config['snips-common'].keys():
        MQTT_USERNAME = snips_config['snips-common']['mqtt_username']
    if 'mqtt_password' in snips_config['snips-common'].keys():
        MQTT_PASSWORD = snips_config['snips-common']['mqtt_password']

    mqtt_opts = MqttOptions(username=MQTT_USERNAME, password=MQTT_PASSWORD, broker_address=MQTT_BROKER_ADDRESS)
    with Hermes(mqtt_options=mqtt_opts) as h:
        h.subscribe_intents(subscribe_intent_callback).start()
Ejemplo n.º 2
0
def snips_say(message):
    with Hermes(mqtt_options=MqttOptions()) as h:
        h.publish_start_session_notification(None, message, None)
        print("Snips TTS:", message)
Ejemplo n.º 3
0
def snips_sayx(message, x):
    with Hermes(mqtt_options=MqttOptions()) as h2:
        message += str(x)
        h2.publish_start_session_notification(None, message, None)
Ejemplo n.º 4
0
PROGRAM_KEY_MAP['ntv'] = [4, 1]
PROGRAM_KEY_MAP['radio1'] = [6, 5]
PROGRAM_KEY_MAP['cosmo'] = [1, 0, 7]
PROGRAM_KEY_MAP['jamfm'] = [1, 2, 0]
PROGRAM_KEY_MAP['fluxfm'] = [1, 2, 1]
PROGRAM_KEY_MAP['paradiso'] = [1, 2, 2]


def subscribe_intent_callback(hermes, intent_message):
    intentname = intent_message.intent.intent_name

    mqttc = mqtt.Client()
    mqttc.connect('localhost', 1883)

    if intentname == "sbogun:TV_on":
        mqttc.publish(MQTT_TOPIC, payload=MQTT_MSG['power_on_AMP'])

    elif intentname == "sbogun:TV_program":
        station_name = intent_message.slots.station_name.first()
        if station_name in PROGRAM_KEY_MAP.keys():
            for i in PROGRAM_KEY_MAP[station_name]:
                mqttc.publish(MQTT_TOPIC, payload=MQTT_MSG[str(i)])

    mqttc.disconnect()


if __name__ == "__main__":
    mqtt_opts = MqttOptions(broker_address=MQTT_BROKER_ADDRESS)
    with Hermes(mqtt_options=mqtt_opts) as h:
        h.subscribe_intents(subscribe_intent_callback).start()
        with io.open(configuration_file,
                     encoding=CONFIGURATION_ENCODING_FORMAT) as f:
            conf_parser = SnipsConfigParser()
            conf_parser.readfp(f)
            return conf_parser.to_dict()
    except (IOError, ConfigParser.Error) as e:
        return dict()


def subscribe_intent_callback(hermes, intentMessage):
    conf = read_configuration_file(CONFIG_INI)
    hermes.publish_end_session(intentMessage.session_id,
                               weather.forecast_condition(intentMessage))


if __name__ == "__main__":
    conf = read_configuration_file(CONFIG_INI)
    weather = Weather(conf)
    config = toml.load('/etc/snips.toml')

    broker_address = config['snips-common']['mqtt']
    mqtt_username = config['snips-common']['mqtt_username']
    mqtt_password = config['snips-common']['mqtt_password']

    mqtt_opts = MqttOptions(username=mqtt_username,
                            password=mqtt_password,
                            broker_address=broker_address)
    with Hermes(mqtt_options=mqtt_opts) as h:
        h.subscribe_intent("domi:searchWeatherForecastCondition",
                           subscribe_intent_callback).start()
Ejemplo n.º 6
0
from hermes_python.hermes import Hermes, MqttOptions

MQTT_ADDR = " localhost:1883"
with Hermes(mqtt_options=MqttOptions()) as h:
    h.publish_start_session_notification(None, "Super hacker pro", None)