MQTT fan payload issues

Background:
I’m currently running HA 0.92.2 on Debian using a Python virtual env. I would like to convert from directly connected Z-Wave to MQTT for a few reasons. I have an Open Z-Wave to MQTT gateway running on another PC. Using mosquitto_sub, I can control all Z-Wave devices fine, so that much works very well.

My fan controllers are GE 14287 which use ranges for a given speed (think dimmer) instead of fixed numbers like 1-3 for low-high. When manually changing speeds at the switch itself, low usually reports around 1, medium reports around 40, and high reports around 99. BUT these numbers do vary.

Issue:
The code snippet below works great when manually changing speeds, or manually sending commands via mosquitto_sub. HOWEVER, the lovelace card always sends “low”, “medium”, or “high” instead of numeric values. SO, when I set the payload speeds (commented out below), the lovelace interface sends the correct values, BUT, manually controlling the fan reports back various ranges that do not match the speed payloads, so lovelace isn’t updated.

Question
Is there anyway (maybe using templates?) that lovelace can send out fixed numeric values for the speed payloads AND still use ranges for speed_value_template? My jinja-foo is weak, but I get the general concepts.

fan:
  - platform: mqtt
    name: "MQTT Office Ceiling Fan"
    state_topic: "zwave/node19/switch_multilevel/1/level"
    command_topic: "zwave/node19/switch_multilevel/1/level/set"
    qos: 2
    speed_state_topic: "zwave/node19/switch_multilevel/1/level"
    speed_command_topic: "zwave/node19/switch_multilevel/1/level/set"
    #payload_low_speed: "1"
    #payload_medium_speed: "66"
    #payload_high_speed: "99"
    state_value_template: >
      {% if value | int > 0 %}
        ON
      {% else %}
        OFF
      {% endif %}
    speed_value_template: >
      {% if value | int == 0 %}
        off
      {% elif value | int < 33 %}
        low
      {% elif value | int < 67 %}
        medium
      {% else %}
        high
      {% endif %}

Even though this is 2 years old, it is the post that kept showing up in my search for the same issue. I struggled with this for a day or so, so wanted to post my solution.
Go ahead and use:
payload_low_speed: “1”
payload_medium_speed: “66”
payload_high_speed: “99”
But use those same numbers in the place of “low”, “medium” and “high” in the value template.