Closed b0ne closed 5 years ago
@titilambert
Hi, I looked the code at the line 334 and it seem to try to get the value at position 0 of the array Json_Ouput['result'] and then get an error because the array seem to be empty. I modified the code to add a verification that the length of the arrary is >1 and if not then to do the same thing if the temperature data was missing.
if not json_output.get('results'):
Missing Temperature data from Hydro-Quebec (but don't crash the app for that)
hourly_weather_data = [None]*24 elif len(json_ouput['results'])<1:
Data from Hydro-Quebec isn't good (but don't crash the app for that)
hourly_weather_data = [None]*24 else: hourly_weather_data = json_output['results'][0]['listeTemperaturesHeure'] <
It seem to work for me!
This issue seems already fixed, see here: https://github.com/titilambert/pyhydroquebec/blob/master/pyhydroquebec/client.py#L341 Could you try with the 2.4.0 ?
I can confirm the the code you just linked dosn't work (event in 2.4.0). I added en else if if you look at the code I quoted!
You look if you get a result, but not if the result contain any data, for some rease the temperature was n/d today so the program got an array but an array of size 0 so when he try to look for the data at position 0 its throwing an out of bound.
I really don't understand your patch :/ The issue should be handled by
if not json_output.get('results'):
This is really strange...
Could you add :
print(json_output):
To see the value of the variable ?
Thanks !
The
if not json_output.get('results')
work if its returning None, but if it returning an empty array it will pass
I'm really not sure of that. Could you try this command line ?
python3 -c "print('EMPTY') if not [] else print('NOT EMPTY')"
python3 -c "print('EMPTY') if not [] else print('NOT EMPTY')"
EMPTY
Here the print value : {'success': True, 'results': []}
So in this case i think the
if not json_output.get('results')
Get the result from sucess : true and not the result []
I'm closing this issue because of the Hydroquebec update see https://github.com/titilambert/pyhydroquebec/issues/35
Describe the bug Error when trying to get the data from HydroQuebec
To Reproduce The command pyhydroquebec -u username -p password (-j and witouth -j) return an error
Seem linked to the fact that HydroQuebec dosn't register all the data yesterday