ardevd / jlrpy

Python library for interacting with the JLR Remote Car API
MIT License
85 stars 28 forks source link

sample/charge_offpeak.py broken due to get_status() return change (see #80) #81

Closed simonjmckenna closed 3 years ago

simonjmckenna commented 3 years ago

Hi Ardevd,

When you updated the get_status function in the jlrpy.py module recently for the change made by jag , it appears that change also managed to break the check_soc facility in the charge_offpeak.py file in the sample code library....

line 89: status = { d['key'] : d['value'] for d in v.get_status()['vehicleStatus'] }

now generates an error: File "/home/pi/ipace/charge_offpeak.py", line 134, in check_soc() File "/home/pi/ipace/charge_offpeak.py", line 89, in check_soc status = { d['key'] : d['value'] for d in v.get_status()['vehicleStatus'] } File "/home/pi/ipace/charge_offpeak.py", line 89, in status = { d['key'] : d['value'] for d in v.get_status()['vehicleStatus'] } TypeError: string indices must be integers

If I replace line 227 (return result) with the following code :

coreStatusList = result['vehicleStatus']['coreStatus'] evStatusList = result['vehicleStatus']['evStatus'] result['vehicleStatus'] = coreStatusList + evStatusList

    return result

<< The original sample code now works.

ardevd commented 3 years ago

Nice catch. Mind creating a pull request for this?