Hi,
i have a Sonoff iFan02 with Tasmota. The integration is working very well with Home Assistant. This is the definition of the MQTT Fan:
- platform: mqtt
name: "Schlafzimmer-Ventilator"
command_topic: "cmnd/bedroomfan/FanSpeed"
speed_command_topic: "cmnd/bedroomfan/FanSpeed"
state_topic: "stat/bedroomfan/RESULT"
speed_state_topic: "stat/bedroomfan/RESULT"
state_value_template: >
{% if value_json.FanSpeed is defined %}
{% if value_json.FanSpeed == 0 -%}0{%- elif value_json.FanSpeed > 0 -%}4{%- endif %}
{% else %}
{% if states.fan.bedroomfan.state == 'off' -%}0{%- elif states.fan.bedroomfan.state == 'on' -%}4{%- endif %}
{% endif %}
speed_value_template: "{{ value_json.FanSpeed }}"
availability_topic: tele/bedroomfan/LWT
payload_off: "0"
payload_on: "4"
payload_low_speed: "1"
payload_medium_speed: "2"
payload_high_speed: "3"
payload_available: Online
payload_not_available: Offline
speeds:
- low
- medium
- high
Now i have published the fan towards Alexa with the generic Smart Home Discovery skill. Alexa has discovered the fan and is able to control it. However, there is an offset in the speed command. The iFan has three speeds, defined as 1,2 and 3. 0 is off. But: The Interface presented by Alexa has the speed settings 0, 1 and 3, and an additional off-Setting. So, the problem i have is now:
- “Alexa, set the fan speed to 0” -> Home Assistant is sending a 1 via MQTT to the fan
- “Alexa, switch off the fan” -> Home Assistant sends a 0
- “Alexa, Fan speed to 3” -> Nothing happens, since Alexa is only able to understand the values from 0 to 2.
I understand that the speed list is somehow an array internally, and the first element of an array is indexed with 0. But this isn’t resembling the actual fan speed.
Can i fix this offset somehow? I’d like to have the fan in 4 states (off and 3 speed settings) and give Alexa a command like "Alexa, set speed to 0/1/2/3 (or off/low/medium/high).