#487 - Integrating location microservice with mycroft core

pull/446/merge
Augusto Monteiro 2017-01-31 17:11:06 -03:00
parent 878b05298d
commit 540cd893c2
3 changed files with 13 additions and 0 deletions

View File

@ -138,6 +138,11 @@ class DeviceApi(Api):
"path": "/" + self.identity.uuid + "/setting"
})
def find_location(self):
return self.request({
"path": "/" + self.identity.uuid + "/location"
})
class STTApi(Api):
def __init__(self):

View File

@ -111,6 +111,10 @@ class RemoteConfiguration(object):
try:
from mycroft.api import DeviceApi
setting = DeviceApi().find_setting()
location = DeviceApi().find_location()
if location:
city = location.get("city")
config["location"] = city["name"] + ", " + city["state"]["name"] + ", " + city["state"]["country"]["name"]
RemoteConfiguration.__load(config, setting)
except Exception as e:
LOG.warn("Failed to fetch remote configuration: %s" % repr(e))

View File

@ -60,6 +60,10 @@ class ConfigurationSkill(ScheduledSkill):
def update(self):
config = self.api.find_setting()
location = DeviceApi().find_location()
if location:
city = location.get("city")
config["location"] = city["name"] + ", " + city["state"]["name"] + ", " + city["state"]["country"]["name"]
self.emitter.emit(Message("configuration.updated", config))
def __api_error(self, e):