skodaconnect / homeassistant-myskoda

Homeassistant integration for MySkoda.
7 stars 3 forks source link

REST API bug when configuring the integration #36

Open LasseHedeby opened 1 day ago

LasseHedeby commented 1 day ago

I get an error after I have configured the integration. It seems that some key/value pairs is missing in the response from my car.

From log: Logger: myskoda.rest_api Kilde: /usr/local/lib/python3.12/site-packages/myskoda/rest_api.py:43 Første forekomst: 21.24.44 (7 forekomster) Senest logget: 21.29.22

Failed to load data from url /v1/charging/TMBJC9NY5MFremoved. Return value was '{"isVehicleInSavedLocation":false,"status":{"chargingRateInKilometersPerHour":0.0,"chargePowerInKw":0.0,"remainingTimeToFullyChargedInMinutes":0,"battery":{"remainingCruisingRangeInMeters":194000,"stateOfChargeInPercent":43}},"settings":{"targetStateOfChargeInPercent":80,"preferredChargeMode":"MANUAL","availableChargeModes":["MANUAL"],"chargingCareMode":"ACTIVATED","autoUnlockPlugWhenCharged":"OFF","maxChargeCurrentAc":"MAXIMUM","batterySupport":"DISABLED"},"carCapturedTimestamp":"2024-09-26T18:19:57Z","errors":[{"type":"STATUS_OF_CHARGING_NOT_AVAILABLE","description":"Status of charging is not available."}]}' Traceback (most recent call last): File "", line 24, in mashumaro_from_json File "", line 14, in __mashumaro_from_dict_json__ mashumaro.exceptions.MissingField: Field "state" of type ChargingState is missing in ChargingStatus instance

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/myskoda/rest_api.py", line 41, in _make_get_request data = deserialize(response_text) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 26, in mashumaro_from_json mashumaro.exceptions.InvalidFieldValue: Field "status" of type Optional[ChargingStatus] in Charging has invalid value {'chargingRateInKilometersPerHour': 0.0, 'chargePowerInKw': 0.0, 'remainingTimeToFullyChargedInMinutes': 0, 'battery': {'remainingCruisingRangeInMeters': 194000, 'stateOfChargeInPercent': 43}}

LasseHedeby commented 1 day ago

Could this be the issue in the myskoda python library? image

Should line 92 in myskoda/models/charging.py be state: ChargingState | None

From what I see in the response from my integration the ChargingState is missing

{
  "isVehicleInSavedLocation": false,
  "status": {
    "chargingRateInKilometersPerHour": 0,
    "chargePowerInKw": 0,
    "remainingTimeToFullyChargedInMinutes": 0,
    "battery": {
      "remainingCruisingRangeInMeters": 194000,
      "stateOfChargeInPercent": 43
    }
  },
  "settings": {
    "targetStateOfChargeInPercent": 80,
    "preferredChargeMode": "MANUAL",
    "availableChargeModes": [
      "MANUAL"
    ],
    "chargingCareMode": "ACTIVATED",
    "autoUnlockPlugWhenCharged": "OFF",
    "maxChargeCurrentAc": "MAXIMUM",
    "batterySupport": "DISABLED"
  },
  "carCapturedTimestamp": "2024-09-26T18:19:57Z",
  "errors": [
    {
      "type": "STATUS_OF_CHARGING_NOT_AVAILABLE",
      "description": "Status of charging is not available."
    }
  ]
}
WebSpider commented 1 day ago

Indeed, we dont have this one yet, we'll add it and update the library.

In the mean time, did you do anything special to arrive at this state?

LasseHedeby commented 1 day ago

Thnx

No I did not. My app is reporting the same error. But I cannot get it to disappear.

LasseHedeby commented 1 day ago

It is planned for charging to night so I will check tomorrow to see if it has disappeared.

LasseHedeby commented 19 hours ago

This morning after my car had charged the error disappeared and I got in HA image image