Skip to content

Commit b28b5c3

Browse files
committed
Siri / Automations charge limit support
1 parent 76ef12e commit b28b5c3

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/siri.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Config, CustomClimateConfig } from 'config'
1+
import { Config, CustomClimateConfig, ChargeLimitConfig } from 'config'
22
import { Logger } from 'lib/logger'
3-
import { Bluelink, ClimateRequest } from 'lib/bluelink-regions/base'
3+
import { Bluelink, ClimateRequest, ChargeLimit } from 'lib/bluelink-regions/base'
44
import { getChargeCompletionString, sleep } from 'lib/util'
55

66
const SIRI_LOG_FILE = 'egmp-bluelink-siri.log'
@@ -19,6 +19,14 @@ export async function processSiriRequest(config: Config, bl: Bluelink, shortcutP
1919
})
2020
}
2121

22+
for (const value of config.chargeLimits) {
23+
commands.push({
24+
words: value.name.split(' ').concat(['charge', 'limit']),
25+
function: setChargeLimit,
26+
data: value,
27+
})
28+
}
29+
2230
for (const commandDetection of commands) {
2331
let found = true
2432
for (const word of commandDetection.words) {
@@ -159,6 +167,19 @@ async function startCharge(bl: Bluelink): Promise<string> {
159167
)
160168
}
161169

170+
async function setChargeLimit(bl: Bluelink, data: ChargeLimitConfig): Promise<string> {
171+
const status = bl.getCachedStatus()
172+
return await blRequest(
173+
bl,
174+
'chargeLimit',
175+
`I've issued a request to set charge limit ${data.name} for ${status.car.nickName || `your ${status.car.modelName}`}.`,
176+
{
177+
acPercent: data.acPercent,
178+
dcPercent: data.dcPercent,
179+
} as ChargeLimit,
180+
)
181+
}
182+
162183
async function stopCharge(bl: Bluelink): Promise<string> {
163184
const status = bl.getCachedStatus()
164185
return await blRequest(

0 commit comments

Comments
 (0)