Skip to content

Commit 821269c

Browse files
committed
code to deal with lack of evStatus in status response
1 parent 67f28e5 commit 821269c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/lib/bluelink-regions/canada.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,25 @@ export class BluelinkCanada extends Bluelink {
133133
df.dateFormat = 'yyyyMMddHHmmssZ'
134134
const lastRemoteCheck = df.date(lastRemoteCheckString)
135135

136+
// For whatever reason sometimes the status will not have the evStatus object
137+
// deal with that with either cached or zero values
138+
if (!status.evStatus) {
139+
return {
140+
lastStatusCheck: Date.now(),
141+
lastRemoteStatusCheck: forceUpdate ? Date.now() : lastRemoteCheck.getTime(),
142+
isCharging: this.cache ? this.cache.status.isCharging : false,
143+
isPluggedIn: this.cache ? this.cache.status.isCharging : false,
144+
chargingPower: this.cache ? this.cache.status.chargingPower : 0,
145+
remainingChargeTimeMins: this.cache ? this.cache.status.remainingChargeTimeMins : 0,
146+
range: this.cache ? this.cache.status.range : 0,
147+
soc: this.cache ? this.cache.status.soc : 0,
148+
locked: status.doorLock,
149+
climate: status.airCtrlOn,
150+
twelveSoc: status.battery.batSoc,
151+
odometer: odometer ? odometer : this.cache ? this.cache.status.odometer : 0,
152+
}
153+
}
154+
136155
return {
137156
lastStatusCheck: Date.now(),
138157
lastRemoteStatusCheck: forceUpdate ? Date.now() : lastRemoteCheck.getTime(),

0 commit comments

Comments
 (0)