1
- import { Config , CustomClimateConfig } from 'config'
1
+ import { Config , CustomClimateConfig , ChargeLimitConfig } from 'config'
2
2
import { Logger } from 'lib/logger'
3
- import { Bluelink , ClimateRequest } from 'lib/bluelink-regions/base'
3
+ import { Bluelink , ClimateRequest , ChargeLimit } from 'lib/bluelink-regions/base'
4
4
import { getChargeCompletionString , sleep } from 'lib/util'
5
5
6
6
const SIRI_LOG_FILE = 'egmp-bluelink-siri.log'
@@ -19,6 +19,14 @@ export async function processSiriRequest(config: Config, bl: Bluelink, shortcutP
19
19
} )
20
20
}
21
21
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
+
22
30
for ( const commandDetection of commands ) {
23
31
let found = true
24
32
for ( const word of commandDetection . words ) {
@@ -159,6 +167,19 @@ async function startCharge(bl: Bluelink): Promise<string> {
159
167
)
160
168
}
161
169
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
+
162
183
async function stopCharge ( bl : Bluelink ) : Promise < string > {
163
184
const status = bl . getCachedStatus ( )
164
185
return await blRequest (
0 commit comments