jamesremuscat/pyze

vehicle.charge-schedule() returns TypeError

Opened this issue · 0 comments

A call to vehicle.charge_schedules() returns a TypeError:

Traceback (most recent call last):
  File "C:\Users\xxx\PycharmProjects\SolarMQTT\test.py", line 100, in <module>
    print(v.charge_schedules())
          ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\PycharmProjects\SolarMQTT\.venv\Lib\site-packages\pyze\api\kamereon.py", line 220, in charge_schedules
    return ChargeSchedules(
           ^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\PycharmProjects\SolarMQTT\.venv\Lib\site-packages\pyze\api\schedule.py", line 46, in __init__
    self._schedules[schedule['id']] = ChargeSchedule(schedule)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\PycharmProjects\SolarMQTT\.venv\Lib\site-packages\pyze\api\schedule.py", line 116, in __init__
    self.id, self.activated, self._schedule = _parse_schedule(data)
                                              ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xxx\PycharmProjects\SolarMQTT\.venv\Lib\site-packages\pyze\api\schedule.py", line 25, in _parse_schedule
    data[day]['startTime'],
    ~~~~~~~~~^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

The Renault API returns the following:
URL: https://api-wired-prod-1-euw1.wrd-aws.com/commerce/v1/accounts/xxx/kamereon/kca/car-adapter/v1/cars/xxx/charging-settings?country=DE

{
   "data":{
      "type":"Car",
      "id":"XXX",
      "attributes":{
         "dateTime":"2024-06-13T11:15:55.6948302Z",
         "mode":"scheduled",
         "schedules":[
            {
               "id":1,
               "activated":false,
               "monday":null,
               "tuesday":null,
               "wednesday":null,
               "thursday":null,
               "friday":null,
               "saturday":null,
               "sunday":{
                  "startTime":"T00:00Z",
                  "duration":1
               }
            },
            {
               "id":2,
               "activated":false,
               "monday":null,
               "tuesday":null,
               "wednesday":null,
               "thursday":null,
               "friday":null,
               "saturday":null,
               "sunday":null
            },
            {
               "id":3,
               "activated":false,
               "monday":null,
               "tuesday":null,
               "wednesday":null,
               "thursday":null,
               "friday":null,
               "saturday":null,
               "sunday":null
            },
            {
               "id":4,
               "activated":false,
               "monday":null,
               "tuesday":null,
               "wednesday":null,
               "thursday":null,
               "friday":null,
               "saturday":null,
               "sunday":null
            },
            {
               "id":5,
               "activated":true,
               "monday":null,
               "tuesday":{
                  "startTime":"T13:00Z",
                  "duration":180
               },
               "wednesday":null,
               "thursday":null,
               "friday":null,
               "saturday":null,
               "sunday":null
            }
         ]
      }
   }
}

The car is a Renault Zoe ZE50 R135 from 2021 in Germany.