core: Amazon Alexa error when calling for a preset mode on MQTT Fan
The problem
Alexa gives an error in HA when I direct it to set my MQTT fan to a preset mode.
What is version of Home Assistant Core has the issue?
core-2021.4.3
What was the last working version of Home Assistant Core?
core-2021.3.x
What type of installation are you running?
Home Assistant Container
Integration causing the issue
MQTT Fan
Link to integration documentation on our website
https://www.home-assistant.io/integrations/fan.mqtt/
Example YAML snippet
- platform: mqtt
name: "Master Bedroom Fan"
command_topic: "cmnd/iFan03-2/FanSpeed"
state_topic: "stat/iFan03-2/RESULT"
state_value_template: >
{% if value_json.FanSpeed is defined %}
{% if value_json.FanSpeed == 0 -%}off{%- elif value_json.FanSpeed > 0 -%}on{%- endif %}
{% else %}
{% if states.fan.master_bedroom_fan.state == 'off' -%}off{%- elif states.fan.master_bedroom_fan.state == 'on' -%}on{%- endif %}
{% endif %}
availability_topic: tele/iFan03-2/LWT
payload_off: "off"
payload_on: "on"
payload_available: Online
payload_not_available: Offline
preset_modes:
- 'off'
- 'low'
- 'medium'
- 'high'
preset_mode_command_topic: "cmnd/iFan03-2/FanSpeed"
preset_mode_command_template: >
{% if value == 'low' %}
1
{% elif value == 'medium' %}
2
{% elif value == 'high' %}
3
{% else %}
0
{% endif %}
preset_mode_state_topic: "stat/iFan03-2/RESULT"
preset_mode_value_template: >
{% if value_json.FanSpeed == 1 %}
low
{% elif value_json.FanSpeed == 2 %}
medium
{% elif value_json.FanSpeed == 3 %}
high
{% else %}
off
{% endif %}
Anything in the logs that might be useful for us?
2021-05-06 14:40:35 ERROR (MainThread) [hass_nabucasa.iot] Error handling message
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/hass_nabucasa/iot.py", line 95, in _async_handle_handler_message
result = await handler(self.cloud, message["payload"])
File "/usr/local/lib/python3.8/site-packages/hass_nabucasa/iot.py", line 119, in async_handle_alexa
return await cloud.client.async_alexa_message(payload)
File "/usr/src/homeassistant/homeassistant/components/cloud/client.py", line 175, in async_alexa_message
return await alexa_sh.async_handle_message(
File "/usr/src/homeassistant/homeassistant/components/alexa/smart_home.py", line 39, in async_handle_message
response = await funct_ref(hass, config, directive, context)
File "/usr/src/homeassistant/homeassistant/components/alexa/handlers.py", line 1091, in async_api_set_range
speed_list = entity.attributes[fan.ATTR_SPEED_LIST]
KeyError: 'speed_list'
### Additional information
None
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 26 (24 by maintainers)
Yes
Since preset modes are a new feature, only a few integrations (I did homekit since I’m the homekit code owner) have been updated to add support for preset modes or be aware of their existence. Alexa has not yet been made aware of them.
OK, thanks for the explanation!
I don’t see any comment about “derived from”, where is it?
Right, and as I wrote before I think Alexa should be updated to handle presets
@bdraco what are the expected voice assistant commands for fans which have percentages?
@jbouwh right, I don’t mean there’s a problem in MQTT fan, I mean the problem in Alexa is triggered because the configuration used by @finity69x2 doesn’t have a
speed_list, and that Alexa should handle that.