36 lines
962 B
Python
36 lines
962 B
Python
from mycroft import MycroftSkill, intent_file_handler
|
|
import requests
|
|
|
|
|
|
def emit(osd_url, event, data):
|
|
json = {
|
|
"event": event,
|
|
"data": data
|
|
}
|
|
print(json)
|
|
return requests.post(osd_url, json=json)
|
|
|
|
|
|
class CarWeather(MycroftSkill):
|
|
def __init__(self):
|
|
MycroftSkill.__init__(self)
|
|
|
|
@intent_file_handler('weather.car.intent')
|
|
def handle_weather_car(self, message):
|
|
osd_url = self.settings.get("OSD_API", "http://localhost:5050/send")
|
|
car_url = self.settings.get("CAR_API", "http://localhost:5000")
|
|
temp = requests.get(f"{car_url}/data/OutsideTemperature").json()["value"]
|
|
emission = {
|
|
"plugin": "temperature",
|
|
"data": {
|
|
"temperature": temp
|
|
},
|
|
"time": 5000
|
|
}
|
|
emit(osd_url, "switchPlugin", emission)
|
|
self.speak_dialog('weather.car', {"temp": temp})
|
|
|
|
|
|
def create_skill():
|
|
return CarWeather()
|