Skip to content

Commit

Permalink
Fixed issue 15340. alexa/smart_home module can now skip properties th…
Browse files Browse the repository at this point in the history
…at aren't supported in the current state, eg lowerSetpoint in Heat mode or targetSetpoint in Eco mode for Nest devices. (home-assistant#15352)
  • Loading branch information
iliketoprogram14 authored and balloob committed Jul 9, 2018
1 parent b9eb008 commit 1d1408b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions homeassistant/components/alexa/smart_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,14 @@ def serialize_properties(self):
"""Return properties serialized for an API response."""
for prop in self.properties_supported():
prop_name = prop['name']
yield {
'name': prop_name,
'namespace': self.name(),
'value': self.get_property(prop_name),
}
# pylint: disable=assignment-from-no-return
prop_value = self.get_property(prop_name)
if prop_value is not None:
yield {
'name': prop_name,
'namespace': self.name(),
'value': prop_value,
}


class _AlexaPowerController(_AlexaInterface):
Expand Down Expand Up @@ -438,14 +441,17 @@ def get_property(self, name):
unit = self.entity.attributes[CONF_UNIT_OF_MEASUREMENT]
temp = None
if name == 'targetSetpoint':
temp = self.entity.attributes.get(ATTR_TEMPERATURE)
temp = self.entity.attributes.get(climate.ATTR_TEMPERATURE)
elif name == 'lowerSetpoint':
temp = self.entity.attributes.get(climate.ATTR_TARGET_TEMP_LOW)
elif name == 'upperSetpoint':
temp = self.entity.attributes.get(climate.ATTR_TARGET_TEMP_HIGH)
if temp is None:
else:
raise _UnsupportedProperty(name)

if temp is None:
return None

return {
'value': float(temp),
'scale': API_TEMP_UNITS[unit],
Expand Down

0 comments on commit 1d1408b

Please sign in to comment.