ricott / homey-com.volvocars

Volvo On Call app for Homey
https://apps.athom.com/app/com.volvocars
GNU General Public License v3.0
9 stars 5 forks source link

Parking Climate (heater) not starting #1

Closed chixxi closed 5 years ago

chixxi commented 5 years ago

THANK YOU! That is really amazing to have a homey app.

I did reverse engineer and develop a similar app for NEEO: https://github.com/chixxi/neeo-voc

Issue: I am using a flow to start my heater, but the heater is not actually starting.

Car: Volvo XC90 2017 model.

Questions: Are you sending the position to the car as well when starting the heater? I think that is required to actually make it work.

Let me know what additional information I can deliver, would be lovely if we can make this work. I am happy to explore and test and I will give this another try as well once I am home tonight.

ricott commented 5 years ago

Thanks for your willingness to help :)

I do not send position data when starting the heater, I think it is only needed for the blink and honk actions and there I do send it. Currently there are 50 installs of the app and I don't have any other reports that the heater action is not working. But the API is not officially documented so programming is to some extent a bit of guesswork.

For the heater action there are some ifs and buts as can be seen on the official VOC apps info page

The engine heater only starts if the following criteria are met: The outdoor temperature at your Volvo is below 15 °C Your Volvo has sufficient fuel. Your Volvo has sufficient battery power Your Volvo has mobile coverage (i.e. that it can receive the engine heater's start command)

I don't think it helps in this case but in the advanced settings for the car in the homey app there are two debug fields containing the last status and attributes response from the VOC API. For the heater status there is no warning field as we have for the remote engine start (ERS) feature.

Let me know if it works if you test again and all conditions are met.

chixxi commented 5 years ago

Thanks for the quick reply.

All the conditions were met since the heater started when using the VolvoOnCall App. I can also confirm that in general your app is working just fine, I receive all the data and I can make the car blink, lock it etc. Remote engine start is not working, that is expected since my car does not support that.

I didn't manage to trigger the heater through homey yet, if I have new ideas I will keep trying. What I think is strange is that in the VOC-Attributes you mentioned it says "remoteHeaterSupported = false;".

chixxi commented 5 years ago

VOC Attributes (XXXX is stuff I have removed for privacy reasons. Justz trying to provide as much information as I can:

{ "engineCode": "XXXX", "exteriorCode": "XXXX", "interiorCode": "XXXX", "tyreDimensionCode": "2421R508", "tyreInflationPressureLightCode": null, "tyreInflationPressureHeavyCode": null, "gearboxCode": "2421DB01", "fuelType": "HEV", "fuelTankVolume": 50, "grossWeight": 3010, "modelYear": 2016, "vehicleType": "XC90", "vehicleTypeCode": "XXXX", "numberOfDoors": 5, "country": { "iso2": "CH" }, "registrationNumber": "XXXX", "carLocatorDistance": 1000, "honkAndBlinkDistance": 500, "bCallAssistanceNumber": "XXXX", "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": "2016-02-04T00:00:00+0000", "subscriptionEndDate": "2021-02-06T14:23:03+0000", "serverVersion": "4.22.63-voc-deployable", "VIN": "XXXX", "journalLogEnabled": true, "highVoltageBatterySupported": true, "maxActiveDelayChargingLocations": 7, "preclimatizationSupported": true, "sendPOIToVehicleVersionsSupported": [ "sendSinglePOIToVehicle" ], "climatizationCalendarVersionsSupported": [ "climatizationCalendarV1" ], "climatizationCalendarMaxTimers": 8, "vehiclePlatform": "2421", "vin": "XXXX", "overrideDelayChargingSupported": true, "engineStartSupported": false, "status.parkedIndoor.supported": false }

When I try to start the engine, your app says in the timeline that this is not supported, but I don't get any such hints when trying to start the heater: https://photos.app.goo.gl/v5SHDFFxCHkrBLMWA

What I was just thinking: In the VOC App I don't "start the heater", I start "Parking Climate". Could it be that my car does not support the heater and it should actually activate the parking climatization? Reason for my thinking: remoteHeaterSupported": false preclimatizationSupported": true

I know this is a hard one, having reverse-egineered the API a while ago myself, I know there is no public info available whatsoever. I will also dive into my notes, I somehow remember that I didn't get the heter to work either.

chixxi commented 5 years ago

According to my notes (https://github.com/chixxi/neeo-voc) I had the parking clima up and running, I will test this again as soon as possible.

Here you can see how I did that: https://github.com/chixxi/neeo-voc/blob/master/controller.js

Basically I sent a http post to this URL with the attached headers: https://vocapi.wirelesscar.net/customerapi/rest/v3.0/vehicles/VIN/preclimatization/start

  auth: {
    username: '',
    password: ''
  },
  headers: {
    'cache-control': 'no-cache',
    'content-type': 'application/json',
    'x-device-id': 'Device',
    'x-originator-type': 'App',
    'x-os-type': 'Android',
    'x-os-version': '22',

},

I went ahead and looked at your code. You have functions for both: VOC.prototype.startHeater = function (vehicleId) VOC.prototype.startPreClimatization = function (vehicleId)

How is it determinded which function is being used? Am I maybe simply making wrong flows by adding the card "Heater ON"?

chixxi commented 5 years ago

Oh, I see you have that covered in https://github.com/ricott/homey-com.volvocars/blob/master/drivers/voc/device.js.

Now I am out of ideas :-(

` startHeater() { if (this.car.attributes.remoteHeaterSupported) { this.log('Heater supported, using heater/start'); this.car.vocApi.startHeater(this.car.vin);

} else if (this.car.attributes.preclimatizationSupported) {
  this.log('Pre climatization supported, using preclimatization/start');

  this.car.vocApi.startPreClimatization(this.car.vin);

} else {
  this.log('No heater or preclimatization support.');
}

} stopHeater() { if (this.car.attributes.remoteHeaterSupported) { this.log('heater/stop'); this.car.vocApi.stopHeater(this.car.vin);

} else if (this.car.attributes.preclimatizationSupported) {
  this.log('preclimatization/stop');

  this.car.vocApi.stopPreClimatization(this.car.vin);

} else {
  this.log('No heater or preclimatization support.');

}`

chixxi commented 5 years ago

When I enable the parking climatisation over the VOC App, Homey receives the right status and "Parking Heater says ON". I went ahead and did a flow to turn off parking, that works just fine, status in VOC and Homey App do change correctly.

ON is still not working.

Sorry for the mess here, I am not really expecting a reply, just trying to document what I have figured out so far.

ricott commented 5 years ago

Hi,

At my day job so not much time right now, but I see you sorted out most questions by yourself :) We can conclude, as you already have that your car have preclima and not heater, which is fine and should work. I know there are other users with preclima and it works for them. For instance the hybrid models also have preclima, and I had two cars like that in the alpha versions.

Basically only way to debug this is to deploy app locally and see the debug prints. Have you done that before on Homey? You would need to follow this guide and get the tools setup. Then you just download the source from repo here and run command athom app run inside the folder where you downloaded the source. This will deploy the app in debug mode and all debug prints will be shown in the console on your computer.

chixxi commented 5 years ago

I fully understand and I don't have much time either. I am driving a XC90 T8, so hybrid as well.

I have not deployed apps locally on Homey before but I am sure I will manage to go through that process. It will just take me a while. Closing this for now and I will re-open was I have logs to provide.

Thanks for your help so far.

ricott commented 5 years ago

I started adding better debugging options in the app yesterday, will continue with that and push a new version. The last VOC error response will be stored in a new debug setting called "Most recent VOC Error".

Technically, after each action invocation the VOC API responds back immediately. In the response you get a link to a new endpoint that you can poll for the result of VOC trying to get the car to perform the action. I query that endpoint a maximum of 15 times while sleeping 1 second before each attempt. The response from this status endpoint usually says 'MessageDelivered' when trying to wake the car and get it to process the request and then it will either state 'Successful' or 'Failed'. If status is failed then there is a failureReason field that contains the reason for failure (sometimes cryptic). If status is failed, then I will put entire response in the "Most recent VOC Error" property. Should make it easier to understand why it fails on your car.

chixxi commented 5 years ago

Thanks for that! Everything else is working just fine, really love having the car connected to Homey!

I will have time this weekend to do some testing and get you more info after running the app locally.

ricott commented 5 years ago

Problem found, thanks to one of the Swedish PHEV users. Thanks Tomas! They changed /preclimatization/start API and now require an empty body to be passed '{}', without that the API call was rejected. Will trigger a new Homey release that should be approved by Homey sometime mid next week.

chixxi commented 5 years ago

Yeah, thanks Thomas! Really cool to here that.

This error is shown in my debug field:

Error: ServiceId is null! at awaitSuccessfulServiceInvocation (/lib/voc.js:358:41) at /lib/voc.js:111:14 at at process._tickCallback (internal/process/next_tick.js:189:7)

ricott commented 5 years ago

Great, then it is same error 👍

chixxi commented 5 years ago

Tested again with App version 1.0.1. Works perfectly fine now.

THANK YOU!