flobz / psa_car_controller

Control psa car with connected_car v4 API.
GNU General Public License v3.0
429 stars 226 forks source link

psa-car-controller not working since 20.10.2022 #415

Closed lebetz closed 1 year ago

lebetz commented 2 years ago

The controller still records charging events in the database. But it shows nothing on UI (to few data) and also does not record any trips. Everything was working fine till 20.10.2022. These are the logs:

2022-10-25 20:22:42,896 :: INFO :: save config change
2022-10-25 20:22:42,989 :: INFO :: ask wakeup to VXxxx6
2022-10-25 20:22:42,990 :: INFO :: topic: psa/RemoteServices/from/cid/OV-ACNT2000xxx06/VehCharge/state: {'action': 'state'}
2022-10-25 20:22:42,993 :: WARNING :: Can't get language
WARNING: dev bundles requested with serve_locally=False.
This is not supported, switching to serve_locally=True
2022-10-25 20:22:43,088 :: INFO :: Connected with result code {'session present' : 0}
2022-10-25 20:22:43,088 :: INFO :: subscribe to psa/RemoteServices/to/cid/OV-ACNT2xxx06/#
2022-10-25 20:22:43,088 :: INFO :: subscribe to psa/RemoteServices/events/MPHRTServices/VXxxx6
2022-10-25 20:22:43,100 :: INFO :: NumExpr defaulting to 1 threads.
2022-10-25 20:22:43,487 :: INFO :: mqtt msg received: psa/RemoteServices/to/cid/OV-ACNT200008076906/VehCharge/state/ProcessManagement b'{"process_date":"2022-10-25T18:22:43Z","vin":"VXxxx6","correlation_id":"10xxx0","process_code":"900","process_message":"[process.900.request.accepted.key]"}'
2022-10-25 20:22:43,630 :: INFO :: update_data
2022-10-25 20:22:43,744 :: INFO :: mqtt msg received: psa/RemoteServices/to/cid/OV-ACNT200008076906/VehCharge/state/ProcessManagement b'{"process_date":"2022-10-25T18:22:43Z","vin":"VXxxx6","correlation_id":"10axxx501869eb3b00f20221025182242990","process_code":"901","process_message":"[process.901.vehicle.asleep.key]"}'
2022-10-25 20:22:59,671 :: INFO :: mqtt msg received: psa/RemoteServices/events/MPHRTServices/VXxxx6 b'{"date":"2022-10-25T18:22:52Z","etat_res_elec":0,"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},"charging_state":{"program":{"hour":0,"minute":1},"available":1,"remaining_time":635,"rate":0,"cable_detected":1,"soc_batt":89,"autonomy_zev":260,"type":0,"hmi_state":0,"mode":2},"stolen_state":0,"vin":"VXxxx6","reason":0,"signal_quality":5,"sev_stop_date":"2022-10-25T17:30:36Z","fds":["NDR01","NBM01","NCG01                                                                                                                                                             ","NAO01","NAS01"],"sev_state":0,"obj_counter":1,"privacy_customer":0,"privacy_applicable":0,"privacy_applicable_max":2,"superlock_state":0}'
2022-10-25 20:22:59,671 :: ERROR :: on_mqtt_message:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/psa_car_controller/psa/RemoteClient.py", line 96, in _fix_not_updated_api
    if car and car.status.get_energy('Electric').charging.status != INPROGRESS:
AttributeError: 'NoneType' object has no attribute 'get_energy'
shortcut18 commented 2 years ago

Can confirm. Last Entry in Trips on 20.10.2022

kurim commented 2 years ago

I did a clean install, but yes it does not record trips anymore.

After Debugging a trip i can see the following:

2022-11-03 07:59:33,900 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12466.8 level:51.0 charge_date:2022-11-03 06:58:40+00:00 level_fuel:None moving:True
2022-11-03 08:01:33,957 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12470.3 level:49.0 charge_date:2022-11-03 07:01:01+00:00 level_fuel:None moving:True
2022-11-03 08:03:33,988 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12473.8 level:48.0 charge_date:2022-11-03 07:02:40+00:00 level_fuel:None moving:True
2022-11-03 08:05:32,665 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12477.3 level:47.0 charge_date:2022-11-03 07:04:40+00:00 level_fuel:None moving:True
2022-11-03 08:05:33,917 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12477.3 level:47.0 charge_date:2022-11-03 07:04:40+00:00 level_fuel:None moving:True
2022-11-03 08:07:33,963 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12480.9 level:46.0 charge_date:2022-11-03 07:06:40+00:00 level_fuel:None moving:True
2022-11-03 08:09:33,994 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12483.8 level:45.0 charge_date:2022-11-03 07:08:41+00:00 level_fuel:None moving:True
2022-11-03 08:10:32,662 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12485.5 level:45.0 charge_date:2022-11-03 07:09:41+00:00 level_fuel:None moving:True
2022-11-03 08:12:34,290 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12486.8 level:44.0 charge_date:2022-11-03 07:11:42+00:00 level_fuel:None moving:True
2022-11-03 08:13:33,966 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12487.8 level:44.0 charge_date:2022-11-03 07:12:40+00:00 level_fuel:None moving:True
2022-11-03 08:15:32,865 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12488.9 level:44.0 charge_date:2022-11-03 07:14:40+00:00 level_fuel:None moving:True
2022-11-03 08:15:34,036 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12488.9 level:44.0 charge_date:2022-11-03 07:14:40+00:00 level_fuel:None moving:True
2022-11-03 08:17:33,904 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:19:34,038 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:20:32,693 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:21:33,963 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:23:33,994 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:25:32,638 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:25:33,941 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:27:34,004 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:29:34,260 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:30:32,600 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:31:33,980 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:33:34,560 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:35:32,641 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:35:34,001 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:37:34,012 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:39:33,989 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:40:32,624 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:41:33,985 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:43:34,007 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:45:32,706 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:45:33,958 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:47:33,998 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:49:34,005 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:50:32,619 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:51:33,986 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:53:33,988 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:55:32,653 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:55:34,075 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True
2022-11-03 08:57:34,004 :: DEBUG :: vin:VXKU longitude:7.52437 latitude:51.51256 date:2022-10-20 15:41:07+00:00 mileage:12489.1 level:44.0 charge_date:2022-11-03 07:16:40+00:00 level_fuel:None moving:True

It stuck on the same long/latitude + Date from 20.10.2022, but as you can see mileage + level changed. I think the broken long/latitude cause the issue @flobz can you take a look at it?

francogodi commented 2 years ago

Can confirm. Last Entry in Trips on 20.10.2022

even a reinstall and re-auth does not help. any news?

flobz commented 2 years ago

Longitude and latitude are fixed. So it's duplicate with #50

kurim commented 2 years ago

@flobz

yes it might be #50 but it should still track the rides w/o position. I have done trips today but they don't have stored

flobz commented 2 years ago

Trips recording needs position changed. So it's a normal behavior.

lebetz commented 2 years ago

@flobz: But I do not have a GPS in the car so it cannot send the position. But trip recording was working in the past. Will check tomorrow, if the new version fixes the problem...

lebetz commented 2 years ago

@flobz

I tested today: still no trips with new version. Was working till 20.10.2022. As mentioned, I have no GPS in the Opel. Can I do anything to debug the issue? Can we reopen the issue because it isn't fixed yet?

kurim commented 2 years ago

Trips recording needs position changed. So it's a normal behavior.

Since GPS is broken again may be you should offer a option to just capture it by KM + Date/Time

lebetz commented 2 years ago

@flobz I analyzed a little bit more and found the reason for the problem.

        date = car.status.last_position.properties.updated_at
        if date is None or date < datetime.now(timezone.utc) - timedelta(days=1):  # if position isn't updated
            date = car.status.service.updated_at

Without GPS I have no last position so it falls back to updatedAt of the service. But updatedAt of the service is frozen since 2012-10-20. I changed the fallback line now to date = charge_date which seems to be updated. Now it seems that I get entries again in database.

temesinko commented 2 years ago

@flobz Could you please re-open this issue? See comment above.

A lot of cars do not provide the coordinates because of some PSA-related problems and since the updated_at property seems to be frozen since October it's not recording any trips at all. :/

francogodi commented 2 years ago

@flobz please re-open this issue, I'm not able to record trips anymore because of this bug :(

flobz commented 1 year ago

I will follow fix this in next version.

bbr111 commented 1 year ago

any updates here? Is there a date for the next version?

francogodi commented 1 year ago

just apply the lebetz fix editing /usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/psa_client.py and re authenticate to have new trips recorded in the meantime!

SinaDD commented 1 year ago

@flobz I analyzed a little bit more and found the reason for the problem.

        date = car.status.last_position.properties.updated_at
        if date is None or date < datetime.now(timezone.utc) - timedelta(days=1):  # if position isn't updated
            date = car.status.service.updated_at

Without GPS I have no last position so it falls back to updatedAt of the service. But updatedAt of the service is frozen since 2012-10-20. I changed the fallback line now to date = charge_date which seems to be updated. Now it seems that I get entries again in database.

Hi, please could you explain where we need change the valor? I don't understend what line I need modify. Thankyou

gerar19 commented 1 year ago

And how i Can modify this file? I can't acces this.

Dirtylife commented 1 year ago

Ssh to the raspberry and edit the file wtih nano or vi...

See: https://github.com/flobz/psa_car_controller/issues/415#issuecomment-1353834251

=> Attention: Maybe you have python3.7...

DavidFFerreira commented 1 year ago

new year....and it still dont work....no even charging record work anymore