Generalize the manual system onto a json file
This commit is contained in:
parent
1f87ced31b
commit
2c682eac44
|
@ -1,4 +1,4 @@
|
|||
__pycache__/
|
||||
*.qmlc
|
||||
settings.json
|
||||
|
||||
locale/en-us
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from mycroft import MycroftSkill, intent_file_handler
|
||||
import requests
|
||||
|
||||
|
@ -13,18 +16,42 @@ def emit(osd_url, event, data):
|
|||
class CarManual(MycroftSkill):
|
||||
def __init__(self):
|
||||
MycroftSkill.__init__(self)
|
||||
# Generate the files
|
||||
root_path = str(Path(__file__).absolute().parent)
|
||||
root_locale_path = root_path + "/locale/en-us"
|
||||
with open(root_path + "/questions.json") as questions_file:
|
||||
questions = json.load(questions_file)
|
||||
self.questions = questions
|
||||
|
||||
@intent_file_handler('manual.car.childlock.intent')
|
||||
def handle_manual_car(self, message):
|
||||
dialog = self.dialog_renderer.render("manual.car.childlock", {})
|
||||
for qid, question in questions.items():
|
||||
with open(f"{root_locale_path}/{qid}.intent", "w") as intent_file:
|
||||
for intent in question["questions"]:
|
||||
intent_file.write(intent)
|
||||
intent_file.write("\n")
|
||||
|
||||
with open(f"{root_locale_path}/{qid}.dialog", "w") as dialog_file:
|
||||
for dialog in question["answers"]:
|
||||
dialog_file.write(dialog)
|
||||
dialog_file.write("\n")
|
||||
|
||||
def initialize(self):
|
||||
for key in self.questions:
|
||||
self.register_intent(
|
||||
f"{key}.intent",
|
||||
lambda y: self.generic_handler(key, y)
|
||||
)
|
||||
|
||||
def generic_handler(self, intent_id, message):
|
||||
title = self.questions[intent_id]["title"]
|
||||
dialog = self.dialog_renderer.render(intent_id, {})
|
||||
url = self.settings.get("OSD_API", "http://localhost:5050/send")
|
||||
emission = {
|
||||
"plugin": "manual",
|
||||
"data": {
|
||||
"title": "Child Lock",
|
||||
"title": title,
|
||||
"description": dialog
|
||||
},
|
||||
"time": 5000
|
||||
"time": 10000
|
||||
}
|
||||
emit(url, "switchPlugin", emission)
|
||||
self.speak(dialog)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
To enable child lock, slide the lock along the edge of the door.
|
|
@ -1 +0,0 @@
|
|||
How to enable child lock
|
|
@ -0,0 +1,84 @@
|
|||
{
|
||||
"hazard.warning.button": {
|
||||
"title": "Hazard Warning Button",
|
||||
"questions": [
|
||||
"What is the Hazard Warning button",
|
||||
"What happens when I press the warning button"
|
||||
|
||||
],
|
||||
"answers": [
|
||||
"Hazard Warning button will activate the Hazard lights"
|
||||
]
|
||||
},
|
||||
"rear.defogger": {
|
||||
"title": "Rear Defogger",
|
||||
"questions": [
|
||||
"What is the rear defogger",
|
||||
"How do I defog the rear window and mirror"
|
||||
],
|
||||
"answers": [
|
||||
"It will defog the rear windows and mirrors",
|
||||
"Press the rear defogger and heated door mirror button to defog the rear window and mirrors when the ignition switch is in on"
|
||||
]
|
||||
},
|
||||
"heating.system": {
|
||||
"title": "Heating System",
|
||||
"questions": [
|
||||
"How does the automatic heating system work",
|
||||
"How do I manage the car temperature"
|
||||
],
|
||||
"answers": [
|
||||
"The automatic heating system maintains the interior temperature you select. The system also selects the proper mix of heated or cooled air that raises or lowers the interior temperature to your preference as quickly as possible.",
|
||||
"Press the Auto button and Adjust the temperature control dial for managing the interior temperature to your preference"
|
||||
]
|
||||
},
|
||||
"lane.watch": {
|
||||
"title": "Lane Watch",
|
||||
"questions": [
|
||||
"What is Lane Watch",
|
||||
"Which button do I use for watching the lanes",
|
||||
"Is it safe to rely on Lane Watch while driving the car"
|
||||
],
|
||||
"answers": [
|
||||
"LaneWatch is an assistance system that allows you to check the passenger side rear areas displayed on the audio/information screen when the turn signal is activated to the passenger’s side. A camera in the passenger side door mirror monitors these areas and allows you to check for vehicles, in addition to your visual check and use of the passenger door mirror. You can also keep the system on for your convenience while driving",
|
||||
"On moving the signal lever to the passenger side there is the button for lane watch at the end of the lever",
|
||||
"Like all assistance systems, LaneWatch has limitations. Over reliance on LaneWatch may result in a collision. The LaneWatch function can be affected by weather, lighting (including headlights and low sun angle), ambient darkness, camera condition, and loading."
|
||||
]
|
||||
|
||||
},
|
||||
"parking.break": {
|
||||
"title": "Parking Break",
|
||||
"questions": [
|
||||
"What is the use of Parking Break",
|
||||
"Where can I find the parking break"
|
||||
],
|
||||
"answers": [
|
||||
"This button is used to keep vehicle stationary when it is parked. It can be applied manually or automatically release it",
|
||||
"You can find it in the compartment between the seat on the front"
|
||||
]
|
||||
},
|
||||
"speed.manual.shift.mode": {
|
||||
"title": "7 speed manual shift mode",
|
||||
"questions": [
|
||||
"How do I operate the manual shift mode",
|
||||
"How do I operate the shift lever D",
|
||||
"How do I operare teh shift lever S"
|
||||
],
|
||||
"answers": [
|
||||
"Use the paddle shifters to change between 1st and 7th speeds without releasing your hands from the steering wheel. The transmission switches to the 7-speed manual shift mode when you pull a paddle shifter while driving.",
|
||||
"The shift mode goes into the 7-speed manual shift mode temporarily, and the number is displayed in the shift indicator. The 7-speed manual shift mode is canceled automatically if you drive at constant speed or accelerate, and the number in the shift indicator goes off.",
|
||||
"The shift mode goes into the 7-speed manual shift mode. The M indicator and the speed number are displayed in the shift indicator. As the vehicle speed slows down, the transmission automatically shifts down accordingly. When the vehicle comes to a stop, it automatically shifts down into 1st. If the vehicle speed increases and the engine speed reaches near the tachometer’s red zone, the transmission automatically shifts up."
|
||||
]
|
||||
},
|
||||
"automatic.climate.control": {
|
||||
"title": "Automatic Climate Control",
|
||||
"questions": [
|
||||
"Where is the automatic climate control",
|
||||
"How do I manage the automatic climate control system"
|
||||
],
|
||||
"answers": [
|
||||
"You can find the climate control system below the display console",
|
||||
"The automatic climate control system maintains the interior temperature you select. The system also selects the proper mix of heated or cooled air that raises or lowers the interior temperature to your preference as quickly as possible."
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue