Alexa fan preset_mode support (#50466)

* fan preset_modes

* process preset mode updates from alexa correctly

* add tests

* codecov patch additional tests
This commit is contained in:
Jan Bouwhuis 2021-05-31 20:58:01 +02:00 committed by GitHub
parent 0e7c2cddf7
commit 7403ba1e81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 189 additions and 6 deletions

View file

@ -958,6 +958,16 @@ async def async_api_set_mode(hass, config, directive, context):
service = fan.SERVICE_SET_DIRECTION
data[fan.ATTR_DIRECTION] = direction
# Fan preset_mode
elif instance == f"{fan.DOMAIN}.{fan.ATTR_PRESET_MODE}":
preset_mode = mode.split(".")[1]
if preset_mode in entity.attributes.get(fan.ATTR_PRESET_MODES):
service = fan.SERVICE_SET_PRESET_MODE
data[fan.ATTR_PRESET_MODE] = preset_mode
else:
msg = f"Entity '{entity.entity_id}' does not support Preset '{preset_mode}'"
raise AlexaInvalidValueError(msg)
# Cover Position
elif instance == f"{cover.DOMAIN}.{cover.ATTR_POSITION}":
position = mode.split(".")[1]