flobz / psa_car_controller

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

issue sending battery state to ABRP #393

Closed cascer1 closed 2 years ago

cascer1 commented 2 years ago

Describe the bug

The program tries to update abrp using car.status.battery.current. however, this property does not exist. This is the status json:

{"embedded": null, "links": {"_self": {"deprecation": null, "href": "https://api.groupe-psa.com/connectedcar/v4/user/vehicles/something/status", "hreflang": null, "name": null, "profile": null, "templated": null, "title": null, "type": null}, "vehicle": null}, "battery": null, "doors_state": null, "energy": [{"updated_at": "2022-08-27 17:49:58+00:00", "autonomy": 110.0, "battery": null, "charging": {"charging_mode": "No", "charging_rate": 0, "next_delayed_time": "PT1M", "plugged": false, "remaining_time": null, "status": "Disconnected"}, "consumption": null, "level": 54.0, "residual": null, "type": "Electric"}], "environment": null, "ignition": null, "kinetic": {"acceleration": null, "moving": null, "pace": null, "speed": null}, "last_position": {"type": "Feature", "geometry": {"coordinates": [null, null, null], "type": "Point"}, "properties": {"heading": null, "signal_quality": null, "type": null, "updated_at": null}}, "preconditionning": {"air_conditioning": {"failure_cause": null, "programs": null, "status": "Disabled", "updated_at": "2022-08-27 17:49:25+00:00"}}, "privacy": {"state": "None"}, "safety": null, "service": {"type": "Hybrid", "updated_at": "2022-08-27 17:49:58+00:00"}, "timed_odometer": {"updated_at": null, "mileage": null}}

I believe that instead, energy.level should be used.

The error in my activity log is:

2022-08-27 17:56:57,979 :: ERROR :: abrp:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/psa_car_controller/psacc/application/abrp.py", line 40, in call
    "current": car.status.battery.current,
AttributeError: 'NoneType' object has no attribute 'current'

I'm driving a 2021 Opel Mokka-e

flobz commented 2 years ago

thanks for reporting this issue it's fixed by dec695a