Fixed issue 15340. alexa/smart_home module can now skip properties that aren't supported in the current state, eg lowerSetpoint in Heat mode or targetSetpoint in Eco mode for Nest devices. (#15352)

This commit is contained in:
iliketoprogram14 2018-07-09 02:44:50 -07:00 committed by Paulus Schoutsen
parent b9eb0081cd
commit 1d1408b98d

View File

@ -270,11 +270,14 @@ class _AlexaInterface(object):
"""Return properties serialized for an API response.""" """Return properties serialized for an API response."""
for prop in self.properties_supported(): for prop in self.properties_supported():
prop_name = prop['name'] prop_name = prop['name']
yield { # pylint: disable=assignment-from-no-return
'name': prop_name, prop_value = self.get_property(prop_name)
'namespace': self.name(), if prop_value is not None:
'value': self.get_property(prop_name), yield {
} 'name': prop_name,
'namespace': self.name(),
'value': prop_value,
}
class _AlexaPowerController(_AlexaInterface): class _AlexaPowerController(_AlexaInterface):
@ -438,14 +441,17 @@ class _AlexaThermostatController(_AlexaInterface):
unit = self.entity.attributes[CONF_UNIT_OF_MEASUREMENT] unit = self.entity.attributes[CONF_UNIT_OF_MEASUREMENT]
temp = None temp = None
if name == 'targetSetpoint': if name == 'targetSetpoint':
temp = self.entity.attributes.get(ATTR_TEMPERATURE) temp = self.entity.attributes.get(climate.ATTR_TEMPERATURE)
elif name == 'lowerSetpoint': elif name == 'lowerSetpoint':
temp = self.entity.attributes.get(climate.ATTR_TARGET_TEMP_LOW) temp = self.entity.attributes.get(climate.ATTR_TARGET_TEMP_LOW)
elif name == 'upperSetpoint': elif name == 'upperSetpoint':
temp = self.entity.attributes.get(climate.ATTR_TARGET_TEMP_HIGH) temp = self.entity.attributes.get(climate.ATTR_TARGET_TEMP_HIGH)
if temp is None: else:
raise _UnsupportedProperty(name) raise _UnsupportedProperty(name)
if temp is None:
return None
return { return {
'value': float(temp), 'value': float(temp),
'scale': API_TEMP_UNITS[unit], 'scale': API_TEMP_UNITS[unit],