watchforstock / evohome-client

Python client to access the Evohome web service
Apache License 2.0
88 stars 52 forks source link

zone_schedules_restore reports error #38

Closed bmCwmbran closed 6 years ago

bmCwmbran commented 6 years ago

Thank you for developing evohome-client. I have little experience in python but the documents are very helpfull. I am using Python 3.5 on Windows 10

If I call ec.zone_schedules_backup('zones.json'), the file jones.json is created as expected. If I then call ec.zone_schedules_restore('zones.json'), an error is reported (see below)

Do I need to modify the contents of zones.json in some way?

Traceback (most recent call last): File "evo.py", line 20, in ec.zone_schedules_restore('zones.json') File "C:\Users\Brian\AppData\Local\Programs\Python\Python35\lib\site-packages\evohomeclient2__init__.py", line 130, in zone_schedules_restore return self._get_single_heating_system().zone_schedules_restore(filename) File "C:\Users\Brian\AppData\Local\Programs\Python\Python35\lib\site-packages\evohomeclient2\controlsystem.py", line 116, in zone_schedules_restore for zone_id, zone_schedule in schedules.iteritems(): AttributeError: 'dict' object has no attribute 'iteritems'

watchforstock commented 6 years ago

Thanks for the report. It looks like you've hit a bit of the code that's not compatible with Python 3. The code was originally written for Python 2.x although the main routines were tested against Python 3 too. The easiest, immediate, solution would be to run your script using Python 2.x.

If you're comfortable, we'd also accept a pull request to make it compatible, but we'd also want to maintain Python 2 compatibility (which can be tricky).

bmCwmbran commented 6 years ago

Hi Andrew, Thanks for the really quick reply.

I have no other code to consider so I will try Python 2.x. I will let you know how I get on asap

bmCwmbran commented 6 years ago

I changed to Python 2.7 and everything is ok now.

Thanks for the invitation, but as my Python experience is minimal, I won't make a pull request.

zxdavb commented 6 years ago

FYI @bmCwmbran,

The offending line in evohomeclient2\controlsystem.py is: for zone_id, zone_schedule in schedules.iteritems():

This is the only time (grep -rnw '/root/evohome-client'/ -e 'iteritems') that iteritemsappears in the entire repository.

I got the code working in python3 by simply changing that line to: for zone_id, zone_schedule in schedules.items():

All: I may do a PR soon, but I am scared of git (and I have yet to test against python2).

namadori commented 6 years ago

HomeAssistant is Python 3.5, any reason to keep Python 2 compatibility?

watchforstock commented 6 years ago

@namadori Home assistant is only one use of this library so I'm keen to retain Python 2 compatibility for the other uses. I've just pushed a fix to master which should retain compatibility with both.