#487 - Integrating location microservice with mycroft core
parent
878b05298d
commit
540cd893c2
|
@ -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):
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue