sherif-fanous/Pyecobee

Working App suddenly started crashing with apparent error in pyecobee code

pfletch101 opened this issue · 5 comments

This afternoon, a service which uses pyecobee to monitor my Ecobee Thermostat and has been running without problems for months suddenly crashed. This does occasionally happen when the ecobee server or the network glitches, but when I attempted to restart the service it crashed immediately, Running it (with appropriate privileges) from the command line produced the following chain of exceptions:

Traceback (most recent call last):
File "ThermostatService.py", line 164, in
t_response = e_service.request_thermostats(selection, timeout=30)
File "/usr/local/lib/python3.7/dist-packages/pyecobee/service.py", line 292, in request_thermostats
return Utilities.process_http_response(response, EcobeeThermostatResponse)
File "/usr/local/lib/python3.7/dist-packages/pyecobee/utilities.py", line 325, in process_http_response
is_top_level=True)
File "/usr/local/lib/python3.7/dist-packages/pyecobee/utilities.py", line 243, in dictionary_to_object
return eval(''.join(response_properties[parent_classes[0]]))
File "", line 155
, ^

SyntaxError: invalid syntax

When the error occurs, pyecobee has already been successfully initialized. I have looked at the indicated pyecobee source file and cannot see an obvious problem, and I don't understand the apparent reference to 'File "string>"'. Any suggestions?

@pfletch101 I just tested request_thermostats on my end and could not reproduce any issue with it.

I have tried to match the stack trace you shared with the current version and it seems you're not running the latest version of Pyecobee.

I'd suggest you use pip to upgrade to the latest version of Pyecobee and try again. If the issue is still happening then we'll see how to further debug it.

Thanks! No problems with doing the pip upgrade, but it still crashes and the only things changed in the stack trace are the line numbers:

Traceback (most recent call last):

File "ThermostatService.py", line 164, in
t_response = e_service.request_thermostats(selection, timeout=30)
File "/usr/local/lib/python3.7/dist-packages/pyecobee/service.py", line 385, in request_thermostats
return Utilities.process_http_response(response, EcobeeThermostatResponse)
File "/usr/local/lib/python3.7/dist-packages/pyecobee/utilities.py", line 437, in process_http_response
is_top_level=True,
File "/usr/local/lib/python3.7/dist-packages/pyecobee/utilities.py", line 332, in dictionary_to_object
return eval(''.join(response_properties[parent_classes[0]]))
File "", line 155
,
^
SyntaxError: invalid syntax

FWIW, here is the definition of selection used for the above original call:

selection = Selection(selection_type=SelectionType.REGISTERED.value, selection_match='',
include_settings=True, include_equipment_status=True,
include_runtime=True, include_sensors=True,
include_events=True)

@pfletch101

I've managed to reproduce the issue but need to further debug it. I'm not sure if what i'll propose now will work for you but if you set the include_runtime flag to False then it'll work.

I'll try to look into it further later today

Ok, I've fixed the issue. ecobee added a few new attributes and code that I had in place to avoid crashing in this situation had a bug (Duh)!!!

Please install the latest version and try again. I'll close the issue now but please re-open it in case it's not working for you.

Thanks! Everything does, indeed, now seem to be working again. I wish the publishers of some of my expensive commercial applications offered the quality of support that you do!