psa_car_controller icon indicating copy to clipboard operation
psa_car_controller copied to clipboard

"kinetic" and "last_position" fields are empty

Open jlayec opened this issue 4 years ago • 214 comments

Describe the bug "kinetic" and "last_position" fields are empty in json answer of get_vehicleinfo/VIN Am I alone?

To Reproduce Steps to reproduce the behavior:

  1. what command did you use ? python3 server.py -l 0.0.0.0 --debug DEBUG
  2. when the bug append ? Everytime with get_vehicleinfo/VIN
  3. Does it persist after restarting the program? Yes

Here is the output of the API

			"type": "Fuel"
		}
	],
	"environment": null,
	"ignition": null,
	"kinetic": null,
	"last_position": null,
	"preconditionning": {
		"air_conditioning": {
			"failure_cause": null,
			"programs": [
				{
					"enabled": false,

I confirm that the privacy configuration in vehicle is share data and position (was not changed and was working before).

jlayec avatar Mar 20 '21 14:03 jlayec

Hello, For me it works well. Does it work in the past ?

flobz avatar Mar 23 '21 20:03 flobz

Hello Yeah ! I did some modifications in the code and started the hybrid car work 😊 I dont know what happened! But these fields are now empty. Hope that peugeot is not removing fields that are not mandatory for their mobile app. Hope i will get back position soon! But to be honest i m pessimistic

jlayec avatar Mar 23 '21 20:03 jlayec

The app use swagger codegen to generate the sdk to connect to the API. In some case if the openapi spec isn't correct it can lead to the problem you describe. Can you use a proxy like mitmproxy to see if the message received by the app is received without those informations ? You just have to install and launch it, then edit config.json file to add the proxy :

    "proxies": {
        "http": "http://localhost:8080",
        "https": "http://localhost:8080"
    }

Then test a request to see if information's are missing.

flobz avatar Mar 23 '21 20:03 flobz

Thanks for your reply. Just checked the proxy dump and "kinetic" and "last_position" fields are not present in the answer from psa servers.

GET https://api.groupe-psa.com/connectedcar/v4/user/vehicles/xxx/status?extension=odometer&client_id=xxx

{
	"preconditionning": {
		"airConditioning": {
			"updatedAt": "2021-03-23T18:07:55Z",
			"status": "Disabled"
		}
	},
	"energy": [
		{
			"updatedAt": "2021-03-23T18:07:55Z",
			"type": "Electric",
			"level": 62,
			"autonomy": 32,
			"charging": {
				"plugged": false,
				"status": "Disconnected",
				"chargingRate": 0,
				"chargingMode": "Slow",
				"nextDelayedTime": "PT0S"
			}
		},
		{
			"updatedAt": "2021-03-23T18:07:55Z",
			"type": "Fuel",
			"level": 0,
			"autonomy": 470
		}
	],
	"createdAt": "2021-03-23T18:07:55Z",
	"battery": {
		"voltage": 87.5,
		"current": 0,
		"createdAt": "2021-03-23T18:07:55Z"
	},
	"privacy": {
		"createdAt": "2021-03-23T18:07:55Z",
		"state": "None"
	},
	"service": {
		"type": "Hybrid",
		"updatedAt": "2021-03-22T11:32:35Z"
	},
	"_links": {
		"self": {
			"href": "https://api.groupe-psa.com/connectedcar/v4/user/vehicles/xxx/status"
		},
		"vehicles": {
			"href": "https://api.groupe-psa.com/connectedcar/v4/user/vehicles/xxx"
		}
	},
	"timed.odometer": {
		"createdAt": null,
		"mileage": xxxxx.x
	},
	"updatedAt": "2021-03-23T18:07:55Z"
}

jlayec avatar Mar 23 '21 23:03 jlayec

Ok, can you try the request without the extension=odometer parameter?

flobz avatar Mar 24 '21 06:03 flobz

I already tried last weekend as per the note in the API documentation. I did it again today and the result is the same unfortunately. Apparently the extension request is not needed as we still receive the odometer.

2021-03-24 07:36:09 GET https://api.groupe-psa.com/connectedcar/v4/user/vehicles/xxx/status?client_id=xxx
                        ← 200 OK application/hal+json 1.3k 1.42s
Host:                api.groupe-psa.com
Accept-Encoding:     identity
Accept:              application/hal+json
User-Agent:          Swagger-Codegen/4.0/python
Authorization:       Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxx
x-introspect-realm:  clientsB2CPeugeot
Content-Type:        application/json

client_id: xxxxxxxxxxxxxxxxxxxxx
{
	"preconditionning": {
		"airConditioning": {
			"updatedAt": "2021-03-23T23:56:55Z",
			"status": "Disabled"
		}
	},
	"energy": [
		{
			"updatedAt": "2021-03-23T23:56:55Z",
			"type": "Electric",
			"level": 64,
			"autonomy": 32,
			"charging": {
				"plugged": false,
				"status": "Disconnected",
				"chargingRate": 0,
				"chargingMode": "Slow",
				"nextDelayedTime": "PT0S"
			}
		},
		{
			"updatedAt": "2021-03-23T23:56:55Z",
			"type": "Fuel",
			"level": 0,
			"autonomy": 470
		}
	],
	"createdAt": "2021-03-23T23:56:55Z",
	"battery": {
		"voltage": 87.5,
		"current": 0,
		"createdAt": "2021-03-23T18:07:55Z"
	},
	"privacy": {
		"createdAt": "2021-03-23T23:56:55Z",
		"state": "None"
	},
	"service": {
		"type": "Hybrid",
		"updatedAt": "2021-03-22T11:32:35Z"
	},
	"_links": {
		"self": {
			"href": "https://api.groupe-psa.com/connectedcar/v4/user/vehicles/xxx/status"
		},
		"vehicles": {
			"href": "https://api.groupe-psa.com/connectedcar/v4/user/vehicles/xxx"
		}
	},
	"timed.odometer": {
		"createdAt": null,
		"mileage": xxxxx.x
	},
	"updatedAt": "2021-03-23T23:56:55Z"
}

jlayec avatar Mar 24 '21 07:03 jlayec

What's the car model?

flobz avatar Mar 24 '21 07:03 flobz

here it is. What is strange : it was working before :‑(

[
  {
    "vin": "VF3xxx",
    "vehicle_id": "xxx",
    "label": "SUV 3008",
    "brand": "Peugeot",
    "battery_power": 10.8,
    "fuel_capacity": 43,
    "max_elec_consumption": 70,
    "max_fuel_consumption": 30
  }
]

jlayec avatar Mar 24 '21 07:03 jlayec

Ok so it can be related to hybrid or 3008. . .

flobz avatar Mar 24 '21 07:03 flobz

yes... at least mine but maybe other cars soon...

jlayec avatar Mar 24 '21 07:03 jlayec

I suppose you don't have your position in mypeugeot?

flobz avatar Mar 24 '21 07:03 flobz

When you start the server you should received an mqtt message on this topic: mqtt msg psa/RemoteServices/to/cid/XXXXXXXXX/VehicleState Does this message contains the car position ?

flobz avatar Mar 24 '21 17:03 flobz

I suppose you don't have your position in mypeugeot?

I observed that the position in the app is updated through bluetooth and not through the API. Easy test - switch off bluetooth.

jlayec avatar Mar 26 '21 09:03 jlayec

When you start the server you should received an mqtt message on this topic: mqtt msg psa/RemoteServices/to/cid/XXXXXXXXX/VehicleState Does this message contains the car position ?

python3 server.py -l 0.0.0.0 --debug DEBUG

2021-03-26 09:43:51,301 :: INFO :: server start
2021-03-26 09:43:53,810 :: INFO :: ["{'vin': 'VF3xxx', 'vehicle_id': 'xxx', 'label': 'SUV 3008', 'brand': 'Peugeot', 'battery_power': 10.8, 'fuel_capacity': 43, 'max_elec_consumption': 70, 'max_fuel_consumption': 30}"]
2021-03-26 09:43:55,847 :: DEBUG :: refresh_remote_token: {'scope': 'psaCustomerId psaMqttService', 'expires_in': 899, 'token_type': 'Bearer', 'access_token': 'xxx', 'refresh_token': 'xxx'}
2021-03-26 09:43:55,920 :: INFO :: ask state to VF3xxx
2021-03-26 09:43:56,060 :: INFO :: Connected with result code {'session present': 0}
2021-03-26 09:43:56,060 :: INFO :: subscribe to psa/RemoteServices/to/cid/xxx/#
2021-03-26 09:43:56,061 :: INFO :: subscribe to psa/RemoteServices/events/MPHRTServices/VF3xxx
2021-03-26 09:43:56,163 :: INFO :: {"access_token": "xxx", "customer_id": "xxx", "correlation_id": "xxx", "req_date": "2021-03-26T09:43:56Z", "vin": "VF3xxx", "req_parameters": {"action": "state"}}
2021-03-26 09:43:56,166 :: INFO :: save config change
2021-03-26 09:43:56,168 :: WARNING :: Can't get language
2021-03-26 09:43:56,417 :: INFO :: mqtt msg psa/RemoteServices/to/cid/xxx/VehicleState/ProcessManagement b'{"process_date":"2021-03-26T09:43:56Z","vin":"VF3xxx","correlation_id":"xxx","process_code":"900","process_message":"Your request has been accepted and is being processed"}'
2021-03-26 09:43:56,418 :: DEBUG :: mqtt msg hasn't return code
2021-03-26 09:43:56,473 :: INFO :: mqtt msg psa/RemoteServices/to/cid/xxx/VehicleState b'
{
	"resp_date": "2021-03-26T09:43:56Z",
	"vin": "VF3xxx",
	"correlation_id": "xxx",
	"return_code": "0",
	"location": {
		"dop": {
			"h": 1.7,
			"p": 1.9,
			"v": 0.9,
			"valid_h": true,
			"valid_p": true,
			"valid_v": true
		},
		"dr": {
			"heading": xxx.xxx,
			"latitude": xxx.xxx,
			"longitude": xxx.xxx,
			"speed": 0,
			"valid_hdg": true,
			"valid_lat": true,
			"valid_lng": true,
			"valid_spd": true
		},
		"gnss": {
			"altitude": xxx.xxx,
			"error_altitude": 3.35,
			"error_h_position": 3.65,
			"error_v_speed": 0.09,
			"fix_status": 3,
			"heading": xxx.xxx,
			"latitude": xxx.xxx,
			"longitude": xxx.xxx,
			"speed": 0,
			"timestamp": "2021-03-19T14:46:13Z",
			"valid_alt": true,
			"valid_err_alt": true,
			"valid_err_hps": true,
			"valid_err_spd": true,
			"valid_hdg": true,
			"valid_lat": true,
			"valid_lng": true,
			"valid_spd": true
		},
		"satellites": {
			"tracked": 24,
			"used": 9,
			"valid_trk": true,
			"valid_usd": true,
			"valid_vis": true,
			"visible": 28
		}
	},
	"resp_data": {
		"date": "2021-03-26T09:15:22Z",
		"etat_res_elec": 5,
		"precond_state": {
			"available": 1,
			"programs": {
				"program1": {
					"hour": 34,
					"minute": 7,
					"on": 0,
					"day": [
						0,
						0,
						0,
						0,
						0,
						0,
						0
					]
				},
				"program2": {
					"hour": 34,
					"minute": 7,
					"on": 0,
					"day": [
						0,
						0,
						0,
						0,
						0,
						0,
						0
					]
				},
				"program3": {
					"hour": 34,
					"minute": 7,
					"on": 0,
					"day": [
						0,
						0,
						0,
						0,
						0,
						0,
						0
					]
				},
				"program4": {
					"hour": 34,
					"minute": 7,
					"on": 0,
					"day": [
						0,
						0,
						0,
						0,
						0,
						0,
						0
					]
				}
			},
			"asap": 0,
			"status": 0,
			"aff": 1
		},
		"charging_state": {
			"program": {
				"hour": 0,
				"minute": 0
			},
			"available": 1,
			"remaining_time": 635,
			"rate": 0,
			"cable_detected": 1,
			"soc_batt": 79,
			"autonomy_zev": 36,
			"type": 0,
			"aff": 1,
			"hmi_state": 0,
			"mode": 0
		},
		"vin": "VF3xxx",
		"reason": 2,
		"signal_quality": 5,
		"sev_stop_date": "2021-03-26T09:15:22Z",
		"fds": [
			"xxx",
			"xxx",
			"xxx",
			"xxx",
			"xxx",
			"xxx",
			"xxx"
		],
		"sev_state": 0,
		"timestamp_gnss": 1616165173, /* ===>>> 19/3/2021 à 14:46:13 */
		"obj_counter": 11,
		"privacy_customer": 0,
		"privacy_applicable": 0,
		"privacy_applicable_max": 1,
		"superlock_state": 0
	}
}
'
2021-03-26 09:43:59,053 :: INFO :: update_data
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

It seems that the location was not updated for a while.

And I mot alone now : https://github.com/flobz/psa_car_controller/issues/54

What are the privacy fields output for your car?

Mine are

		"privacy_customer": 0,
		"privacy_applicable": 0,
		"privacy_applicable_max": 1,
		"superlock_state": 0

jlayec avatar Mar 26 '21 09:03 jlayec

I suppose you don't have your position in mypeugeot?

I observed that the position in the app is updated through bluetooth and not through the API. Easy test - switch off bluetooth.

I think it depends of your car. If you have the Peugeot SOS option, you have a gps.

flobz avatar Mar 26 '21 10:03 flobz

I suppose you don't have your position in mypeugeot?

I observed that the position in the app is updated through bluetooth and not through the API. Easy test - switch off bluetooth.

I think it depends of your car. If you have the Peugeot SOS option, you have a gps.

I have Peugeot SOS option.

Everything was ok before in the API, the problem appeared 19/3/2021 à 14:46:13

Even when the API got the position, the app location was not updated if not connected with bluetooth. I m using 2 phones and the one not connected with bluetooth is able to remote control Preconditionning & Charge of the car and get level / autonomy but doesn't have car position updated.

jlayec avatar Mar 26 '21 10:03 jlayec

Ok can you confirm that car position is present in mqtt messages? I will check my privacy settings later.

flobz avatar Mar 26 '21 11:03 flobz

Ok can you confirm that car position is present in mqtt messages? I will check my privacy settings later.

well yes but values were not updated since I encountered the problem

		"dr": {
			"heading": xxx.xxx,
			"latitude": xxx.xxx,
			"longitude": xxx.xxx,
			"speed": 0,
			"valid_hdg": true,
			"valid_lat": true,
			"valid_lng": true,
			"valid_spd": true
		},
		"gnss": {
			"altitude": xxx.xxx,
			"error_altitude": 3.35,
			"error_h_position": 3.65,
			"error_v_speed": 0.09,
			"fix_status": 3,
			"heading": xxx.xxx,
			"latitude": xxx.xxx,
			"longitude": xxx.xxx,
			"speed": 0,
			"timestamp": "2021-03-19T14:46:13Z",

There is a problem somewhere... and now seems that I m not alone...

jlayec avatar Mar 26 '21 11:03 jlayec

My privacy settings:

"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":2,"

flobz avatar Mar 26 '21 12:03 flobz

my timestamp_gnss is old too : 27/1/2021:8:03:15 Well, it seems to be a car problem. You could maybe go see your mechanic.

flobz avatar Mar 26 '21 13:03 flobz

I have the following error with your branch:

(.env) psa_remote@FLOAPP-PEUGEOT:/usr/local/src/psa_car_controller $ python3 app_decoder.py ~/mypeugeot_1.28.apk
APK loading...
Requested API level 29 is larger than maximum we have, returning API level 28 instead.
RES_TABLE_LIBRARY_TYPE chunk is not supported
RES_TABLE_LIBRARY_TYPE chunk is not supported
APK loaded !
MyPeugeot email: mail
MyPeugeot password: password
What is your country code ? (ex: FR, GB, DE, ES...)
BE
Can't get car model please check cars.json
Traceback (most recent call last):
  File "app_decoder.py", line 151, in <module>
    label = vehicle["short_label"].split(" ")[-1]
KeyError: 'short_label'

Any idea? Thanks. Florent

Flodu31 avatar Mar 26 '21 13:03 Flodu31

I have the following error with your branch:

(.env) psa_remote@FLOAPP-PEUGEOT:/usr/local/src/psa_car_controller $ python3 app_decoder.py ~/mypeugeot_1.28.apk
APK loading...
Requested API level 29 is larger than maximum we have, returning API level 28 instead.
RES_TABLE_LIBRARY_TYPE chunk is not supported
RES_TABLE_LIBRARY_TYPE chunk is not supported
APK loaded !
MyPeugeot email: mail
MyPeugeot password: password
What is your country code ? (ex: FR, GB, DE, ES...)
BE
Can't get car model please check cars.json
Traceback (most recent call last):
  File "app_decoder.py", line 151, in <module>
    label = vehicle["short_label"].split(" ")[-1]
KeyError: 'short_label'

Any idea? Thanks. Florent

hello. please submit a new issue - it is not the same problem here. I don't know if flobz can hide the last message to keep a clean thread.

jlayec avatar Mar 26 '21 13:03 jlayec

I used the branch that you mentioned to me and my issue was closed, it is why I posted here ;)

Flodu31 avatar Mar 26 '21 13:03 Flodu31

I have the following error with your branch:

(.env) psa_remote@FLOAPP-PEUGEOT:/usr/local/src/psa_car_controller $ python3 app_decoder.py ~/mypeugeot_1.28.apk
APK loading...
Requested API level 29 is larger than maximum we have, returning API level 28 instead.
RES_TABLE_LIBRARY_TYPE chunk is not supported
RES_TABLE_LIBRARY_TYPE chunk is not supported
APK loaded !
MyPeugeot email: mail
MyPeugeot password: password
What is your country code ? (ex: FR, GB, DE, ES...)
BE
Can't get car model please check cars.json
Traceback (most recent call last):
  File "app_decoder.py", line 151, in <module>
    label = vehicle["short_label"].split(" ")[-1]
KeyError: 'short_label'

Any idea? Thanks. Florent

It's seems that's the car model isn't returned... I will changethe code to handle this error.

flobz avatar Mar 26 '21 13:03 flobz

@jlayec still the same problem ?

flobz avatar Apr 01 '21 15:04 flobz

I think there is a major issue with Peugeot API actually. In other services like Tronity.io, I can't see any trip information since Mar 23 because they are unable to retrieve location, maybe it could be related ?

In API reply I see this (timestamp is like yours) :

"gnss":{

    "altitude":7.3,
    "error_altitude":2.81,
    "error_h_position":3.53,
    "error_v_speed":0.09,
    "fix_status":3,
    "heading":**********,
    "latitude":**********,
    "longitude":**********,
    "speed":0,
    "timestamp":"2021-01-26T16:37:24Z",

In dashboard I see this :

last_position updated_at "2021-03-24 16:57:28+00:00"

Tronity.io support answer (regarding my support ticket for my own car) :

there is a problem with some cars at Peugeot. The problem is that we got the last GPS Update at 
2021-03-24 17:57. This is the reason why no trips are created. We wrote Peugeot about this issue
but still no feedback. We can't do much about it.

CalicodesIles avatar Apr 02 '21 10:04 CalicodesIles

I have similar issue: "last_position": null, "timed_odometer": null. In "gnss" (and in "dr") there is valid position, with "timestamp": "2021-03-15T12:35:06Z". But it didn't work before that either. My privacy settings are the same as flobz. It's a Peugeot e-208. The SatNav, Live traffic, My Peugeot app, etc has always worked, so I can't really complain at Peugeot. ( I tried, but they said everything is OK...). If anybody has found a possible solution, please let me know. Otherwise, as more and more people are affected, I hope PSA will do something on their side, which will solve it for everyone eventually.

B4jusz avatar Apr 02 '21 12:04 B4jusz

On my side, I have "privacy": {"state": "None"} but it is activated on my car:

20210402_140058495_iOS

Flodu31 avatar Apr 02 '21 14:04 Flodu31

Well I opened a ticket last Friday through Peugeot customer service. They asked me to send some logs from MyPeugeot iOS app with a specific procedure.

I have similar issues on MyPeugeot app, so I'm quite sure that it is related to API v4 :

  • Unable to retrieve real time data regarding autonomy and battery level (same wrong information displayed in psa_car_controller and MyPeugeot)
  • Battery level containing old values When there is a data refresh (randomly), I don't get latest data, it could be an hour old or multiple days
  • Autonomy : same issue
  • Preconditioning not returning status
  • Unable to configure preconditioning hours

I will inform you as soon as I get some information from their technical support.

CalicodesIles avatar Apr 02 '21 14:04 CalicodesIles

@Flodu31 Where do you see "privacy : None" ?

In my case, in resp_data section of the JSON, I have this :

"privacy_customer":0,
"privacy_applicable":0,
"privacy_applicable_max":2

When you change values on your screen capture, my "privacy_applicable" changes :

  • "0" shares data+location information.
  • "1" shares data only
  • "2" means no sharing

CalicodesIles avatar Apr 02 '21 14:04 CalicodesIles