Skip to content
This repository was archived by the owner on Nov 18, 2024. It is now read-only.

Commit 450b2f5

Browse files
builderjerjbrodie
and
jbrodie
authored
Fix weather one call from remote device (#41)
* fix typos * fix typos * fix folder creation Co-authored-by: jbrodie <jbrodie@ziggy.ziggyhome>
1 parent 7fce0bb commit 450b2f5

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

ovos_local_backend/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from ovos_local_backend.backend import start_backend
22
from ovos_local_backend.configuration import CONFIGURATION
33

4-
54
def main():
65
import argparse
76

ovos_local_backend/backend/external_apis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def _get_latlon():
4141
def get_services_routes(app):
4242

4343
apis = ExternalApiManager()
44-
4544
@app.route("/" + API_VERSION + '/geolocation', methods=['GET'])
4645
@noindex
4746
@check_selene_pairing

ovos_local_backend/utils/__init__.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import random
1515

1616
from flask import make_response
17+
from ovos_utils.log import LOG
1718
from ovos_utils.ovos_service_api import OvosWolframAlpha, OvosWeather
1819
from ovos_backend_client.api import GeolocationApi, WolframAlphaApi, OpenWeatherMapApi
1920

@@ -60,7 +61,7 @@ def dict_to_camel_case(data):
6061

6162

6263
class ExternalApiManager:
63-
def __int__(self):
64+
def __init__(self):
6465
self.config = CONFIGURATION.get("microservices", {})
6566
self.units = CONFIGURATION["system_unit"]
6667

@@ -69,7 +70,11 @@ def __int__(self):
6970

7071
self.ovos_wolfram = OvosWolframAlpha()
7172
self.ovos_owm = OvosWeather()
72-
73+
if not self.ovos_owm.uuid:
74+
try:
75+
self.ovos_owm.api.register_device()
76+
except Exception as e:
77+
LOG.debug(f"Error registering device {e}")
7378
self.geo = Geocoder()
7479

7580
self.selene_owm = None
@@ -183,7 +188,7 @@ def wolfram_xml(self, query, units=None, lat_lon=None):
183188
q = {"input": query, "units": units, "output": "xml"}
184189
return self._wolfram.get_wolfram_full(q)
185190

186-
def own_current(self, lat, lon, units, lang="en-us"):
191+
def owm_current(self, lat, lon, units, lang="en-us"):
187192
if isinstance(self._owm, LocalWeather): # local
188193
return self._owm.current(lat, lon, units, lang)
189194
if isinstance(self._owm, OvosWeather): # ovos
@@ -201,7 +206,7 @@ def owm_onecall(self, lat, lon, units, lang="en-us"):
201206
if isinstance(self._owm, OpenWeatherMapApi): # selene
202207
return self._owm.get_weather((lat, lon), lang, units)
203208

204-
def own_hourly(self, lat, lon, units, lang="en-us"):
209+
def owm_hourly(self, lat, lon, units, lang="en-us"):
205210
if isinstance(self._owm, LocalWeather): # local
206211
return self._owm.hourly(lat, lon, units, lang)
207212
if isinstance(self._owm, OvosWeather): # ovos
@@ -210,7 +215,7 @@ def own_hourly(self, lat, lon, units, lang="en-us"):
210215
if isinstance(self._owm, OpenWeatherMapApi): # selene
211216
return self._owm.get_hourly((lat, lon), lang, units)
212217

213-
def own_daily(self, lat, lon, units, lang="en-us"):
218+
def owm_daily(self, lat, lon, units, lang="en-us"):
214219
if isinstance(self._owm, LocalWeather): # local
215220
return self._owm.daily(lat, lon, units, lang)
216221
if isinstance(self._owm, OvosWeather): # ovos
@@ -221,7 +226,7 @@ def own_daily(self, lat, lon, units, lang="en-us"):
221226

222227

223228
class LocalWeather:
224-
def __int__(self, key):
229+
def __init__(self, key):
225230
self.key = key
226231

227232
def current(self, lat, lon, units, lang):
@@ -266,7 +271,7 @@ def onecall(self, lat, lon, units, lang):
266271

267272

268273
class LocalWolfram:
269-
def __int__(self, key):
274+
def __init__(self, key):
270275
self.key = key
271276

272277
def spoken(self, query, units):

0 commit comments

Comments
 (0)