Skip to content

Commit ff03bdc

Browse files
committed
Kia US fix for widget timeout + Kia US potential fix for odometer invalid readings.
1 parent 1535fd5 commit ff03bdc

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/lib/bluelink-regions/usa-kia.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export class BluelinkUSAKia extends Bluelink {
222222
dtc: '1',
223223
enrollment: '0',
224224
functionalCards: '0',
225-
location: '1',
225+
location: location ? '1' : '0',
226226
vehicleStatus: '1',
227227
weather: '0',
228228
},
@@ -237,7 +237,7 @@ export class BluelinkUSAKia extends Bluelink {
237237

238238
if (this.requestResponseValid(resp.resp, resp.json).valid) {
239239
let locationStatus = undefined
240-
if (resp.json.payload.vehicleInfoList[0].lastVehicleInfo.location) {
240+
if (location && resp.json.payload.vehicleInfoList[0].lastVehicleInfo.location) {
241241
locationStatus = {
242242
latitude: resp.json.payload.vehicleInfoList[0].lastVehicleInfo.location.coord.lat,
243243
longitude: resp.json.payload.vehicleInfoList[0].lastVehicleInfo.location.coord.lon,
@@ -271,7 +271,7 @@ export class BluelinkUSAKia extends Bluelink {
271271
if (this.requestResponseValid(resp.resp, resp.json).valid) {
272272
// only cached data contains latest location so return cached API after remote command
273273
return location
274-
? await this.getCarStatus(_id, false)
274+
? await this.getCarStatus(_id, false, true)
275275
: this.returnCarStatus(resp.json.payload.vehicleStatusRpt.vehicleStatus)
276276
}
277277

src/version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version":"v1.2.0"
2+
"version":"v1.2.1"
33
}

src/widget.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ async function refreshDataForWidget(bl: Bluelink, config: Config): Promise<Widge
141141
} else if (currentTimestamp > status.status.lastStatusCheck + MIN_API_REFRESH_TIME) {
142142
if (config.debugLogging) logger.log('Doing API Refresh')
143143
status = await bl.getStatus(false, true)
144+
if (config.debugLogging) logger.log('Completed API Refresh')
144145
}
145146
} catch (_error) {
146147
// ignore any API errors and just displayed last cached values in widget
@@ -222,7 +223,12 @@ export async function createMediumWidget(config: Config, bl: Bluelink) {
222223
const batteryPercent = status.status.soc
223224
const remainingChargingTime = status.status.remainingChargeTimeMins
224225
const chargingKw = status.status.chargingPower > 0 ? `${status.status.chargingPower.toFixed(1).toString()} kW` : '-'
225-
const odometer = status.status.odometer > 0 ? status.status.odometer : status.car.odometer ? status.car.odometer : 0
226+
const odometer =
227+
status.car.odometer === undefined
228+
? status.status.odometer
229+
: status.status.odometer >= status.car.odometer
230+
? status.status.odometer
231+
: status.car.odometer
226232
const lastSeen = new Date(status.status.lastRemoteStatusCheck)
227233

228234
// Battery Percent Value

0 commit comments

Comments
 (0)