I have a class member. How do I access "value" of the remotesensor temperature? This is the response from pyecobee module for ECOBEE thermostat.
I tried thermostat_response.thermostatList
but it gives me error "AttributeError: 'EcobeeThermostatResponse' object has no attribute 'thermostatList'"
I am able to access thermostat_response.page
and thermostat_response.status
but not thermostat_response.thermostatList
thermostat_response = EcobeeThermostatResponse(
page=Page(
page=1,
pageSize=1,
total=1,
totalPages=1
),
status=Status(
code=0,
message=
),
thermostatList=[
Thermostat(
alerts=None,
modelNumber=athenaSmart,
reminders=None,
remoteSensors=[
RemoteSensor(
capability=[
RemoteSensorCapability(
id=1,
type=temperature,
value=717
),
RemoteSensorCapability(
id=2,
type=occupancy,
value=true
)
],
code=EDGJ,
id=rs:100,
inUse=False,
name=Bedroom,
type=ecobee3_remote_sensor
),
RemoteSensor(
capability=[
RemoteSensorCapability(
id=1,
type=temperature,
value=696
),
RemoteSensorCapability(
id=2,
type=humidity,
value=62
),
RemoteSensorCapability(
id=3,
type=occupancy,
value=true
)
],
code=None,
id=ei:0,
inUse=True,
name=Living Room,
type=thermostat
)
],
runtime=None,
weather=None
)
]
)
This is the defination of EcobeeThermostatResponse class
class EcobeeThermostatResponse(EcobeeStatusResponse):
__slots__ = ['_page', '_thermostat_list']
attribute_name_map = {'page': 'page', 'thermostat_list': 'thermostatList',
'thermostatList': 'thermostat_list', 'status': 'status'}
attribute_type_map = {'page': 'Page', 'thermostat_list': 'List[Thermostat]', 'status': 'Status'}
def __init__(self, page, thermostat_list, status):
"""
Construct a EcobeeThermostatResponse instance
:param page: The page information for the response
:param thermostat_list: The list of thermostats returned by the request
:param status: The api response code
"""
self._page = page
self._thermostat_list = thermostat_list
EcobeeStatusResponse.__init__(self, status)
@property
def page(self):
"""
Gets the page attribute of this EcobeeThermostatResponse instance.
:return: The value of the page attribute of this EcobeeThermostatResponse instance.
:rtype: Page
"""
return self._page
@property
def thermostat_list(self):
"""
Gets the thermostat_list attribute of this EcobeeThermostatResponse instance.
:return: The value of the thermostat_list attribute of this EcobeeThermostatResponse instance.
:rtype: List[Thermostat]
"""
return self._thermostat_list
According to the documentation, you can use
thermostat_response.thermostat_list()
(as a function).What if you did not have documentation?
In case you bump into a similar issue and do not have documentation, you can use Python's
dir()
to output all properties of an object, e.g. in your case:More info about that in this SO question.