New crash in previously working code
pfletch101 opened this issue · 5 comments
I have been updating the program which monitors and controls my thermostat for summer conditions. In doing so, I exercised some code which was certainly working a couple of months ago, but which is not normally called when it is not significantly colder than it has been since March or April. I am having problems pasting the code, because neither 'Insert code' nor quoting it are retaining comprehensible formatting, so I have attached the function source as a file.
The exception report is as follows:
Traceback (most recent call last):
File "ThermostatService0a.py", line 226, in <module>
set_hold(set_temp_cool,set_temp_heat,'on') # Turn fan on
File "ThermostatService0a.py", line 101, in set_hold
params={'heatHoldTemp':heat_set,'coolHoldTemp':cold_set,'fan':fan_setting,'holdType':'nextTransition'})])
TypeError: __init__() got an unexpected keyword argument 'type'
It appears that the Function initializer is not recognizing the documented 'type' argument. but this does not make sense. The parameters passed to my function are valid and reasonable, and the function used to work. What am I missing?
Code.txt
Hey @pfletch101
I made some cleanup changes a few releases ago to align the code to some best practices as recommended by pylint. One of these is to avoid using the name type
as it redefines the built-in function type
in Python. So the parameter was renamed to type_
You just have to change your code on line 10 to the following
type_='setHold',
Makes sense, but is there somewhere where you documented the change? The docs on PyPi, which I did check, still have 'type', as do the examples on the front page here.
Hey @pfletch101
I made some cleanup changes a few releases ago to align the code to some best practices as recommended by pylint. One of these is to avoid using the name
type
as it redefines the built-in functiontype
in Python. So the parameter was renamed totype_
There are other places where ecobee and (up to now) you have used 'type'. Two that I immediately spotted were in the Event and Capability objects. These properties do not seem to have changed their names in pyecobee, which feels a bit inconsistent.
Makes sense, but is there somewhere where you documented the change? The docs on PyPi, which I did check, still have 'type', as do the examples on the front page here.
Documentation needs to be updated. Thanks for pointing that out 👍
Hey @pfletch101
I made some cleanup changes a few releases ago to align the code to some best practices as recommended by pylint. One of these is to avoid using the nametype
as it redefines the built-in functiontype
in Python. So the parameter was renamed totype_
There are other places where ecobee and (up to now) you have used 'type'. Two that I immediately spotted were in the Event and Capability objects. These properties do not seem to have changed their names in pyecobee, which feels a bit inconsistent.
I just checked both modules and they're correctly updated.
It's only the name of the method parameter that needs to be updated. An attribute with the name type
is ok because it's an object instance attribute, however a bare type
parameter shadows/hides the built-in type
function