From 1f87ced31bb90cc320850e9e5714ea96a7cd6495 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Mon, 21 Dec 2020 22:29:23 +0530 Subject: [PATCH] Add car-weather-skill --- car-weather-skill/.gitignore | 4 +++ car-weather-skill/README.md | 17 +++++++++ car-weather-skill/__init__.py | 35 +++++++++++++++++++ .../locale/en-us/weather.car.dialog | 1 + .../locale/en-us/weather.car.intent | 9 +++++ car-weather-skill/settingsmeta.yaml | 14 ++++++++ 6 files changed, 80 insertions(+) create mode 100644 car-weather-skill/.gitignore create mode 100644 car-weather-skill/README.md create mode 100644 car-weather-skill/__init__.py create mode 100644 car-weather-skill/locale/en-us/weather.car.dialog create mode 100644 car-weather-skill/locale/en-us/weather.car.intent create mode 100644 car-weather-skill/settingsmeta.yaml diff --git a/car-weather-skill/.gitignore b/car-weather-skill/.gitignore new file mode 100644 index 0000000..4eb3651 --- /dev/null +++ b/car-weather-skill/.gitignore @@ -0,0 +1,4 @@ +__pycache__/ +*.qmlc +settings.json + diff --git a/car-weather-skill/README.md b/car-weather-skill/README.md new file mode 100644 index 0000000..ad7d18a --- /dev/null +++ b/car-weather-skill/README.md @@ -0,0 +1,17 @@ +# Car Weather +Provides temperature outside the car + +## About +Provides temperature outside the car + +## Examples +* "What is the weather outside the car" + +## Credits +Firewalkers + +## Category +**Information** + +## Tags + diff --git a/car-weather-skill/__init__.py b/car-weather-skill/__init__.py new file mode 100644 index 0000000..b940c49 --- /dev/null +++ b/car-weather-skill/__init__.py @@ -0,0 +1,35 @@ +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() diff --git a/car-weather-skill/locale/en-us/weather.car.dialog b/car-weather-skill/locale/en-us/weather.car.dialog new file mode 100644 index 0000000..eeab1ba --- /dev/null +++ b/car-weather-skill/locale/en-us/weather.car.dialog @@ -0,0 +1 @@ +The weather outside is {{temp}} degrees celsius diff --git a/car-weather-skill/locale/en-us/weather.car.intent b/car-weather-skill/locale/en-us/weather.car.intent new file mode 100644 index 0000000..712f1f2 --- /dev/null +++ b/car-weather-skill/locale/en-us/weather.car.intent @@ -0,0 +1,9 @@ +What is the weather outside the car +What is the temperature outside the car +What is the temperature outside +What is the weather outside +How is the weather outside +How is the weather +How is the weather outside the car +How is the temperature outside the car +How is the temperature outside diff --git a/car-weather-skill/settingsmeta.yaml b/car-weather-skill/settingsmeta.yaml new file mode 100644 index 0000000..f96b220 --- /dev/null +++ b/car-weather-skill/settingsmeta.yaml @@ -0,0 +1,14 @@ +skillMetadata: + sections: + - name: API Paths + fields: + - name: OSD_API + type: text + label: OSD API URL + value: "http://localhost:5050/send" + placeholder: "http://localhost:5050/send" + - name: CAR_API + type: text + label: Car API URL + value: "http://localhost:5000" + placeholder: "http://localhost:5000"