MQTT New Fan Speed Implementation

Hi everyone!

In the new September releases, not sure specifically which one, but ceiling fans have stopped working and I’m a bit stuck on how to fix it. I know there was the change to fan speed percentages but I haven’t been able to work out how to map new requirements to my existing set-up. Is anyone able to give me some guidance on how to get this to work? Surely I’m not the only one in this boat (and from searching it doesn’t seem like I am - but I just cant join the dots to bring it all together).

My previously working set-up was as follows:

- platform: mqtt
    name: poppy-fan
    state_topic: tele/poppy-fan/STATE
    command_topic: cmnd/poppy-fan/POWER2
    state_value_template: "{{ value_json.POWER2 }}"
    speed_command_topic: cmnd/poppy-fan/Backlog
    speed_state_topic: tele/poppy-fan/STATE
    speed_value_template: >
      {% if value_json.POWER3 == 'OFF' and value_json.POWER4 == 'OFF' %}
        Event SetSpeed=1
      {% elif value_json.POWER3 == 'OFF' and value_json.POWER4 == 'ON' %}
        Event SetSpeed=2
      {% elif value_json.POWER3 == 'ON' and value_json.POWER4 == 'ON' %}
        Event SetSpeed=3
      {% endif %}
    availability_topic: tele/poppy-fan/LWT
    payload_available: Online
    payload_not_available: Offline
    payload_low_speed: "Event SetSpeed=1"
    payload_medium_speed: "Event SetSpeed=2"
    payload_high_speed: "Event SetSpeed=3"
    payload_off: 'OFF'
    payload_on: 'ON'
    speeds:
      - low
      - medium
      - high

Check breaking changes for 2021.9, I guess.

MQTT fan no longer supports the legacy speeds (OFF, LOW, MEDIUM, HIGH). With release 2021.3 the support for legacy speeds was announced to be removed after a quarter (2021.7).