38 lines
1.2 KiB
Python
38 lines
1.2 KiB
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 CarModeSwitches(MycroftSkill):
|
|
def __init__(self):
|
|
MycroftSkill.__init__(self)
|
|
|
|
@intent_file_handler('switches.mode.pet.intent')
|
|
def pet_mode(self, message):
|
|
url = self.settings.get("OSD_API", "http://localhost:5050/send")
|
|
emit(url, "switchPlugin", {"plugin": "petMode"})
|
|
self.speak_dialog('switches.mode.pet')
|
|
|
|
@intent_file_handler('switches.mode.smart_home.intent')
|
|
def smart_home(self, message):
|
|
url = self.settings.get("OSD_API", "http://localhost:5050/send")
|
|
emit(url, "switchPlugin", {"plugin": "smartHome"})
|
|
self.speak_dialog('switches.mode.smart_home')
|
|
|
|
@intent_file_handler('switches.mode.maps.intent')
|
|
def maps(self, message):
|
|
url = self.settings.get("OSD_API", "http://localhost:5050/send")
|
|
emit(url, "switchPlugin", {"plugin": "maps"})
|
|
self.speak_dialog('switches.mode.maps')
|
|
|
|
|
|
def create_skill():
|
|
return CarModeSwitches()
|