Fix google_assistant climate modes might be None (#108793)

pull/109129/head
Jan Bouwhuis 2024-01-24 19:47:07 +01:00 committed by Franck Nijhof
parent eeafb61b8f
commit 12126ebfda
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
1 changed files with 4 additions and 3 deletions

View File

@ -1152,12 +1152,12 @@ class TemperatureSettingTrait(_Trait):
modes = []
attrs = self.state.attributes
for mode in attrs.get(climate.ATTR_HVAC_MODES, []):
for mode in attrs.get(climate.ATTR_HVAC_MODES) or []:
google_mode = self.hvac_to_google.get(mode)
if google_mode and google_mode not in modes:
modes.append(google_mode)
for preset in attrs.get(climate.ATTR_PRESET_MODES, []):
for preset in attrs.get(climate.ATTR_PRESET_MODES) or []:
google_mode = self.preset_to_google.get(preset)
if google_mode and google_mode not in modes:
modes.append(google_mode)
@ -2094,9 +2094,10 @@ class InputSelectorTrait(_Trait):
def sync_attributes(self):
"""Return mode attributes for a sync request."""
attrs = self.state.attributes
sourcelist: list[str] = attrs.get(media_player.ATTR_INPUT_SOURCE_LIST) or []
inputs = [
{"key": source, "names": [{"name_synonym": [source], "lang": "en"}]}
for source in attrs.get(media_player.ATTR_INPUT_SOURCE_LIST, [])
for source in sourcelist
]
payload = {"availableInputs": inputs, "orderedInputs": True}