jamesremuscat / pyze

Unofficial Python client and API for Renault ZE
MIT License
111 stars 30 forks source link

Support v2 charge scheduler API #27

Closed jamesremuscat closed 4 years ago

jamesremuscat commented 4 years ago

New endpoint (GET): car-adapter/v1/cars/{vin}/charging-settings.

Example response:

{
    "data": {
        "type": "Car",
        "id": "xxxxxxxxxxxxxxxxx",
        "attributes": {
            "mode": "scheduled",
            "schedules": [{
                "id": 1,
                "activated": true,
                "monday": {
                    "startTime": "T12:00Z",
                    "duration": 15
                },
                "tuesday": {
                    "startTime": "T04:30Z",
                    "duration": 420
                },
                "wednesday": {
                    "startTime": "T22:30Z",
                    "duration": 420
                },
                "thursday": {
                    "startTime": "T22:00Z",
                    "duration": 420
                },
                "friday": {
                    "startTime": "T12:00Z",
                    "duration": 15
                },
                "saturday": {
                    "startTime": "T12:00Z",
                    "duration": 15
                },
                "sunday": {
                    "startTime": "T12:00Z",
                    "duration": 15
                }
            }]
        }
    }
}

Looks vaguely the same, except:

I'm assuming the POST endpoint at car-adapter/v2/cars/{vin}/actions/charge-schedule behaves in a somewhat similar manner to the existing one. (Note the v2 in this URL, which does not appear in the GET endpoint, though it probably should have done...)

boekabart commented 4 years ago

With the car set to 'charge now', the schedules comes back an empty array.

jamesremuscat commented 4 years ago

@boekabart That's not what I get:

>>> v._get('charge-mode')
{"data":{"type":"Car","id":"VF1xxxxxxxxxxx","attributes":{"chargeMode":"always_charging"}}}
{'chargeMode': 'always_charging'}

>>> v._get('charging-settings')
{"data":{"type":"Car","id":"VF1xxxxxxxxxxx","attributes":{"mode":"scheduled","schedules":[{"id":1,"activated":true,"monday":{"startTime":"T12:00Z","duration":15},"tuesday":{"startTime":"T12:00Z","duration":15},"wednesday":{"startTime":"T12:00Z","duration":15},"thursday":{"startTime":"T12:00Z","duration":15},"friday":{"startTime":"T12:00Z","duration":15},"saturday":{"startTime":"T12:00Z","duration":15},"sunday":{"startTime":"T04:30Z","duration":420}}]}}}
{'mode': 'scheduled', 'schedules': [{'id': 1, 'activated': True, 'monday': {'startTime': 'T12:00Z', 'duration': 15}, 'tuesday': {'startTime': 'T12:00Z', 'duration': 15}, 'wednesday': {'startTime': 'T12:00Z', 'duration': 15}, 'thursday': {'startTime': 'T12:00Z', 'duration': 15}, 'friday': {'startTime': 'T12:00Z', 'duration': 15}, 'saturday': {'startTime': 'T12:00Z', 'duration': 15}, 'sunday': {'startTime': 'T04:30Z', 'duration': 420}}]

Or do you mean something else by "charge now"?

boekabart commented 4 years ago

Probably yet another artefact of the connected service not being completely 'live' yet - similar result as you now.