Skip to content

Commit 66c5ee1

Browse files
committed
Add config-ui-x support
1 parent 946faab commit 66c5ee1

File tree

2 files changed

+172
-0
lines changed

2 files changed

+172
-0
lines changed

config.schema.json

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
{
2+
"pluginAlias": "Volvo",
3+
"pluginType": "accessory",
4+
"singular": false,
5+
"schema": {
6+
"name": {
7+
"title": "Name",
8+
"type": "string",
9+
"default": "Volvo",
10+
11+
"required": true,
12+
"description": "Name of the accessory. Siri uses this parameter for identifying your car."
13+
},
14+
"email": {
15+
"title": "Email",
16+
"type": "string",
17+
"pattern": "^\\S+@\\S+$",
18+
"required": true,
19+
"description": "Volvo On Call account email."
20+
},
21+
"password": {
22+
"title": "Password",
23+
"type": "string",
24+
"required": true,
25+
"description": "Volvo On Call account password."
26+
},
27+
"region": {
28+
"title": "Region",
29+
"type": "string",
30+
"required": true,
31+
"oneOf": [
32+
{ "title": "Europe", "enum": ["eu"] },
33+
{ "title": "North-America", "enum": ["na"] },
34+
{ "title": "China", "enum": ["cn"] }
35+
],
36+
"description": "Volvo On Call region."
37+
},
38+
"VIN": {
39+
"title": "Vehicle Identification Number (VIN)",
40+
"type": "string",
41+
"placeholder": "YV1AX8850J3766769",
42+
"description": "VIN of your Volvo vehicle. Only required if you have multiple vehicles associated with your account."
43+
},
44+
"updateInterval": {
45+
"title": "Update interval to VOC API",
46+
"type": "integer",
47+
"placeholder": 5,
48+
"minimum": 3,
49+
"required": false,
50+
"description": "Interval (in seconds) between GET status updates to the Volvo On Call API. Setting this number too low will result in DOS."
51+
},
52+
"engineStartDuration": {
53+
"title": "Engine start duration",
54+
"type": "integer",
55+
"placeholder": 5,
56+
"minimum": 1,
57+
"maximum": 15,
58+
"description": "Duration of engine remote start. Only applicable if feature is supported by your car."
59+
},
60+
"batteryLowThreshold": {
61+
"title": "EV Battery threshold",
62+
"type": "integer",
63+
"placeholder": 20,
64+
"minimum": 1,
65+
"maximum": 99,
66+
"description": "Threshold (percentage) for battery low status in HomeKit. Only applicable for EV or plugin hybrids."
67+
},
68+
"enabledFeatures": {
69+
"type": "object",
70+
"properties": {
71+
"carLocatorSupported": {
72+
"type": "boolean",
73+
"default": true
74+
},
75+
"honkAndOrBlink": {
76+
"type": "boolean",
77+
"default": true
78+
},
79+
"honkAndBlink": {
80+
"type": "boolean",
81+
"default": true
82+
},
83+
"remoteHeaterSupported": {
84+
"type": "boolean",
85+
"default": true
86+
},
87+
"unlockSupported": {
88+
"type": "boolean",
89+
"default": true
90+
},
91+
"lockSupported": {
92+
"type": "boolean",
93+
"default": true
94+
},
95+
"preclimatizationSupported": {
96+
"type": "boolean",
97+
"default": true
98+
},
99+
"engineStartSupported": {
100+
"type": "boolean",
101+
"default": true
102+
},
103+
"highVoltageBatterySupported": {
104+
"type": "boolean",
105+
"default": true
106+
}
107+
}
108+
}
109+
},
110+
"layout": [
111+
"name",
112+
{
113+
"key": "email",
114+
"type": "email",
115+
"validationMessages": {
116+
"pattern": "Not a valid email address."
117+
}
118+
},
119+
{
120+
"key": "password",
121+
"type": "password"
122+
},
123+
"region",
124+
"VIN",
125+
{
126+
"type": "section",
127+
"title": "Features",
128+
"expanded": false,
129+
"expandable": true,
130+
"key": "enabledFeatures",
131+
"description": "Manually enable or disable features. Homebridge-volvo will automatically detect the features available on your car. This is only useful for disableling features for security reasons, such as lock/unlock. Properties:",
132+
"required": false,
133+
"items": [
134+
"enabledFeatures.carLocatorSupported",
135+
"enabledFeatures.honkAndOrBlink",
136+
"enabledFeatures.honkAndBlink",
137+
"enabledFeatures.remoteHeaterSupported",
138+
"enabledFeatures.unlockSupported",
139+
"enabledFeatures.lockSupported",
140+
"enabledFeatures.preclimatizationSupported",
141+
"enabledFeatures.engineStartSupported",
142+
"enabledFeatures.highVoltageBatterySupported"
143+
]
144+
},
145+
{
146+
"type": "section",
147+
"title": "Advanced features",
148+
"expanded": false,
149+
"expandable": true,
150+
"items": [
151+
"updateInterval",
152+
{
153+
"key": "engineStartDuration",
154+
"type": "number"
155+
},
156+
{
157+
"key": "batteryLowThreshold",
158+
"type": "number"
159+
}
160+
]
161+
}
162+
],
163+
"form": null,
164+
"display": null
165+
}

src/helpers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ export const getConfig = ({
3333
if (typeof region !== "string") {
3434
throw new Error("Region is not defined in config.");
3535
}
36+
37+
if (region === "eu") {
38+
// Angular JSON schema form evaluates empty string to false, thus selecting Europe in the dropdown would not work.
39+
// Simple cirumvention.
40+
region = "";
41+
}
42+
3643
updateInterval = updateInterval > 5 ? updateInterval : DEFAULT_INTERVAL;
3744
engineStartDuration = 1 <= engineStartDuration && engineStartDuration <= 15 ? engineStartDuration : DEFAULT_START_DURATION;
3845
batteryLowThreshold = 1 <= batteryLowThreshold && batteryLowThreshold <= 99 ? batteryLowThreshold : DEFAULT_BATTERY_THRESHOLD;

0 commit comments

Comments
 (0)