trympet / homebridge-volvo

Volvo plugin for Homebridge
https://npm.im/homebridge-volvo
Apache License 2.0
26 stars 6 forks source link

Battery Level #5

Closed DJay-X closed 4 years ago

DJay-X commented 4 years ago

Unfortunately at the moment I can't test. But the next weekend is coming. :)

However, I noticed that the battery level is showing a warning all over. My V90 is not electro or hybrid 🙈🙉🙊 - it's sad I know - Can the fuel level also be reflected in the battery level or disabled? Fuel level of course would be a dream.

And by the way, regardless if the plugin will work for me 100% or not, @trympet you should have a PayPal or Buy Me A Coffee Button here. I'm happy to spend you a drink or two for your work and great support. 🤗

Napkin 14 07 20, 6 10 28 PM

trympet commented 4 years ago

Hi, thanks for the positive feedback!

I think the plugin wrongfully detected that you have an EV when it shouldn't.

If you turn on debug mode in Homebridge, which in config-ui-x is done by clicking in the top right -> Homebridge settings -> enable Homebridge Debug Mode -D -> restart, it will print the response from the VOC API when the plugin is loaded (if you have v1.0.2). This response contains information about your vehicle and the features available, and is what is used for determining the features available on your vehicle.

Would you be willing to paste the responses as a reply so I can check for deviations? Here is the response from my vehicle: [7/15/2020, 4:28:29 PM] [Volvo] Vehicle attributes:

{
  "engineCode": "2421CF13",
  "exteriorCode": "2421110Q",
  "interiorCode": "24211052",
  "tyreDimensionCode": "2421R514",
  "tyreInflationPressureLightCode": null,
  "tyreInflationPressureHeavyCode": null,
  "gearboxCode": "2421DB01",
  "fuelType": "HEV",
  "fuelTankVolume": 70,
  "grossWeight": 2660,
  "modelYear": 2020,
  "vehicleType": "XC60",
  "vehicleTypeCode": "2421AA05",
  "numberOfDoors": 5,
  "country": {
    "iso2": "NO"
  },
  "carLocatorDistance": 1000,
  "honkAndBlinkDistance": 500,
  "bCallAssistanceNumber": "+4722670377",
  "carLocatorSupported": true,
  "honkAndBlinkSupported": true,
  "honkAndBlinkVersionsSupported": [
    "honkAndOrBlink",
    "honkAndBlink"
  ],
  "remoteHeaterSupported": false,
  "unlockSupported": true,
  "lockSupported": true,
  "journalLogSupported": true,
  "assistanceCallSupported": true,
  "unlockTimeFrame": 120,
  "verificationTimeFrame": 120,
  "timeFullyAccessible": 7200,
  "timePartiallyAccessible": 31680,
  "subscriptionType": "PREMIUM_2013",
  "subscriptionStartDate": "2019-08-13T00:00:00+0000",
  "subscriptionEndDate": "2022-08-13T00:00:00+0000",
  "serverVersion": "20.4.8-voc-deployable",
  "journalLogEnabled": true,
  "highVoltageBatterySupported": true,
  "maxActiveDelayChargingLocations": 7,
  "preclimatizationSupported": true,
  "sendPOIToVehicleVersionsSupported": [
    "sendSinglePOIToVehicle"
  ],
  "climatizationCalendarVersionsSupported": [
    "climatizationCalendarV1"
  ],
  "climatizationCalendarMaxTimers": 8,
  "vehiclePlatform": "2421",
  "overrideDelayChargingSupported": true,
  "engineStartSupported": true,
  "status.parkedIndoor.supported": false,
  "vin": "***REDACTED***",
  "VIN": "***REDACTED***",
  "registrationNumber": "***REDACTED***"
}

[7/15/2020, 4:28:29 PM] [Volvo] Vehicle state:

{
  "ERS": {
    "status": "off",
    "timestamp": "2020-07-14T13:27:51+0000",
    "engineStartWarning": "Other",
    "engineStartWarningTimestamp": "2020-07-14T13:27:51+0000"
  },
  "averageFuelConsumption": 63,
  "averageFuelConsumptionTimestamp": "2020-07-15T14:27:48+0000",
  "averageSpeed": 46,
  "averageSpeedTimestamp": "2020-07-15T14:27:48+0000",
  "brakeFluid": "Normal",
  "brakeFluidTimestamp": "2020-07-15T14:27:48+0000",
  "bulbFailures": [],
  "bulbFailuresTimestamp": "2020-07-15T14:27:48+0000",
  "carLocked": false,
  "carLockedTimestamp": "2020-07-15T14:27:48+0000",
  "connectionStatus": "ConnectedWithPower",
  "connectionStatusTimestamp": "2020-07-15T14:27:55+0000",
  "distanceToEmpty": 380,
  "distanceToEmptyTimestamp": "2020-07-15T14:27:48+0000",
  "doors": {
    "tailgateOpen": true,
    "rearRightDoorOpen": false,
    "rearLeftDoorOpen": false,
    "frontRightDoorOpen": false,
    "frontLeftDoorOpen": false,
    "hoodOpen": false,
    "timestamp": "2020-07-15T14:27:48+0000"
  },
  "engineRunning": false,
  "engineRunningTimestamp": "2020-07-15T14:27:48+0000",
  "fuelAmount": 38,
  "fuelAmountLevel": 54,
  "fuelAmountLevelTimestamp": "2020-07-15T14:27:48+0000",
  "fuelAmountTimestamp": "2020-07-15T14:27:48+0000",
  "heater": {
    "seatSelection": {
      "frontDriverSide": false,
      "frontPassengerSide": false,
      "rearDriverSide": false,
      "rearPassengerSide": false,
      "rearMid": false
    },
    "status": "off",
    "timer1": {
      "time": null,
      "state": null
    },
    "timer2": {
      "time": null,
      "state": null
    },
    "timestamp": "2020-07-14T13:09:58+0000"
  },
  "hvBattery": {
    "hvBatteryChargeStatusDerived": "CablePluggedInCar_FullyCharged",
    "hvBatteryChargeStatusDerivedTimestamp": "2020-07-15T14:27:55+0000",
    "hvBatteryChargeModeStatus": null,
    "hvBatteryChargeModeStatusTimestamp": null,
    "hvBatteryChargeStatus": "ChargeEnd",
    "hvBatteryChargeStatusTimestamp": "2020-07-14T14:42:28+0000",
    "hvBatteryLevel": 100,
    "hvBatteryLevelTimestamp": "2020-07-15T10:18:05+0000",
    "distanceToHVBatteryEmpty": 34,
    "distanceToHVBatteryEmptyTimestamp": "2020-07-15T10:18:05+0000",
    "hvBatteryChargeWarning": "UnexpectedPowerloss",
    "hvBatteryChargeWarningTimestamp": "2020-07-13T19:10:53+0000",
    "timeToHVBatteryFullyCharged": 360,
    "timeToHVBatteryFullyChargedTimestamp": "2020-07-15T14:27:55+0000"
  },
  "odometer": 21563637,
  "odometerTimestamp": "2020-07-15T14:27:48+0000",
  "privacyPolicyEnabled": false,
  "privacyPolicyEnabledTimestamp": "2019-08-13T06:49:33+0000",
  "remoteClimatizationStatus": "CableConnectedWithPower",
  "remoteClimatizationStatusTimestamp": "2020-07-15T14:27:55+0000",
  "serviceWarningStatus": "AlmostTimeForService",
  "serviceWarningStatusTimestamp": "2020-07-15T14:27:48+0000",
  "timeFullyAccessibleUntil": "2020-07-19T12:49:09+0000",
  "timePartiallyAccessibleUntil": "2020-08-05T12:49:09+0000",
  "tripMeter1": 6245100,
  "tripMeter1Timestamp": "2020-07-15T14:27:48+0000",
  "tripMeter2": 0,
  "tripMeter2Timestamp": "2020-07-15T14:27:48+0000",
  "tyrePressure": {
    "frontLeftTyrePressure": "Normal",
    "frontRightTyrePressure": "Normal",
    "rearLeftTyrePressure": "Normal",
    "rearRightTyrePressure": "Normal",
    "timestamp": "2020-07-15T14:27:48+0000"
  },
  "washerFluidLevel": "Normal",
  "washerFluidLevelTimestamp": "2020-07-15T14:27:48+0000",
  "windows": {
    "frontLeftWindowOpen": false,
    "frontRightWindowOpen": false,
    "timestamp": "2020-07-15T14:27:48+0000",
    "rearLeftWindowOpen": false,
    "rearRightWindowOpen": false
  },
  "theftAlarm": "***REDACTED***"
}
DJay-X commented 4 years ago

Thanks again.

Unfortunately I don't have this settings in config-ui-x Im running the plugin on a 2nd-Instance and don't know how to get the debug mode with an instance. Never needed it. 😅 A other plugin has an option in .json that can be set "debug": true, Sorry. 🤷🏼‍♂️

Bildschirmfoto 2020-07-15 um 18 53 16

And this setting switched on in the config, is not showing anything like above in the log.

Bildschirmfoto 2020-07-15 um 18 49 29

DJay-X commented 4 years ago

Besides this problem for me, I had a crash this evening of homebridge because of the plugin. Hope this helps to investigate. Probably shouldn't crash the whole homebridge?

Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]: FetchError: invalid json response body at https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/xxxxx/status reason: Unexpected end of JSON input
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]:     at /usr/local/lib/node_modules/homebridge-volvo/node_modules/node-fetch/lib/index.js:272:32
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]:     at runMicrotasks (<anonymous>)
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]:     at processTicksAndRejections (internal/process/task_queues.js:97:5)
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]:     at Vehicle.GetUpdate (/usr/local/lib/node_modules/homebridge-volvo/src/util/vehicleApi.ts:97:12)
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]:     at Vehicle.Update (/usr/local/lib/node_modules/homebridge-volvo/src/util/vehicle.ts:318:22) {
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]:   type: 'invalid-json'
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]: }
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]: FetchError: invalid json response body at https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/xxxxx/status reason: Unexpected end of JSON input
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]:     at /usr/local/lib/node_modules/homebridge-volvo/node_modules/node-fetch/lib/index.js:272:32
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]:     at runMicrotasks (<anonymous>)
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]:     at processTicksAndRejections (internal/process/task_queues.js:97:5)
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]:     at Vehicle.GetUpdate (/usr/local/lib/node_modules/homebridge-volvo/src/util/vehicleApi.ts:97:12)
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]:     at Vehicle.Update (/usr/local/lib/node_modules/homebridge-volvo/src/util/vehicle.ts:318:22) {
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]:   type: 'invalid-json'
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]: }
Jul 15 20:01:13 raspberrypi-3BPlus homebridge[5163]: [2020-7-15 20:01:13] Got SIGTERM, shutting down Homebridge...
trympet commented 4 years ago

Ah okay, no worries.

On the second issue: yes, you are right. Plugins should not crash the entire Homebridge instance. I'll hopefully have it fixed by the end of the week. I presume the issue is related to rate limit perhaps. Should be simple fix :)

DJay-X commented 4 years ago

Thanks for trying to help with the battery issue showing up empty, and also with the crash/shutdown problem.

I was facing it again just a few minutes ago.

Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]: FetchError: invalid json response body at https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/xxxxx/status reason: Unexpected end of JSON input
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]:     at /usr/local/lib/node_modules/homebridge-volvo/node_modules/node-fetch/lib/index.js:272:32
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]:     at runMicrotasks (<anonymous>)
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]:     at processTicksAndRejections (internal/process/task_queues.js:97:5)
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]:     at Vehicle.GetUpdate (/usr/local/lib/node_modules/homebridge-volvo/src/util/vehicleApi.ts:97:12)
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]:     at Vehicle.Update (/usr/local/lib/node_modules/homebridge-volvo/src/util/vehicle.ts:318:22) {
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]:   type: 'invalid-json'
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]: }
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]: FetchError: invalid json response body at https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/xxxxx/status reason: Unexpected end of JSON input
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]:     at /usr/local/lib/node_modules/homebridge-volvo/node_modules/node-fetch/lib/index.js:272:32
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]:     at runMicrotasks (<anonymous>)
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]:     at processTicksAndRejections (internal/process/task_queues.js:97:5)
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]:     at Vehicle.GetUpdate (/usr/local/lib/node_modules/homebridge-volvo/src/util/vehicleApi.ts:97:12)
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]:     at Vehicle.Update (/usr/local/lib/node_modules/homebridge-volvo/src/util/vehicle.ts:318:22) {
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]:   type: 'invalid-json'
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]: }
Jul 18 12:50:47 raspberrypi-3BPlus homebridge[448]: [2020-7-18 12:50:47] Got SIGTERM, shutting down Homebridge...
trympet commented 4 years ago

Actually, it seems that it is trying to update the status twice, all at the same time. It should now catch all errors related to GET and POST requests. Fixed in v1.0.3.

On the other issue: I think the battery indicator is working as intended. It should, by default, reflect your fuel level if there is no EV battery detected. As far as I know, HomeKit doesn't allow for a separate battery level sensor. Instead, HomeKit automatically associates it with all other devices.

Can you confirm if it is indeed reflecting your fuel level?

Also, if you want, you can tweak the threshold for the battery low indicator under advanced settings, as per v1.0.4 and forward 😎 image

DJay-X commented 4 years ago

You are awesome. Thanks for your work. 🙏

I will give it a try this weekend and check how things are going.

I updated the config.joson. Also I set "highVoltageBatterySupported": false This is also for EV I think and not needed for my car, right?

Thanks again and I will report back soon. 👍

{
            "name": "Volvo",
            "email": "me@me.com",
            "password": "xxxxx",
            "region": "eu",
            "VIN": "xxxxx",
            "batteryLowThreshold": 10,
            "enabledFeatures": {
                "carLocatorSupported": true,
                "honkAndOrBlink": true,
                "honkAndBlink": true,
                "remoteHeaterSupported": true,
                "unlockSupported": true,
                "lockSupported": true,
                "preclimatizationSupported": true,
                "engineStartSupported": true,
                "highVoltageBatterySupported": false
            },
            "accessory": "Volvo"
        },
DJay-X commented 4 years ago

@trympet Hey there 👋😃 Battery/Fuel Level looking good, I think. 👍 Thanks a lot.

Napkin 20 07 20, 10 50 41 AM

However, I have problems from the first day on with VOC working reliable. Door open/close for example takes minutes to do something form the VOC App. Most of the time it's not working at all. Basic info like fuel etc. is working well. So there is a connection but not reliable for fast actions like lock/unlock the doors. Do you facing similar problems with VOC in general? But that's nothing to do with you great plugin.

trympet commented 4 years ago

Thanks for the kind words ❤

Generally no, though the buttons/switches in HomeKit sometimes do not update immediately.

Do you experience response times significantly slower than on the official VOC app? I'd be happy to look into it.

DJay-X commented 4 years ago

Thanks. I think its a general problem with VOC. The VOC App is not working well for me and the car. Nothing to do with you plugin. Unfortunately, because you could fix this sooner than Volvo Support. They are not helpful at all. 🤷🏼‍♂️

I close this Issue. Battery/Fuel Level works. 👍 Thanks again and I'm sure we'll talk again soon. 😅