PWM fan - set fanspeed as percentage?

I have an esp8266 unit with a PWM fan attached to it. It is adjusted by PWM.

configged as:

sensor:
  - platform: dht
    pin: D1
    temperature:
      name: "AVR temperatur"
      id: avr_temperature
    humidity:
      name: "AVR fugtighed"
      id: avr_humidity
    update_interval: 60s
    model: AM2302
    
output:
  - platform: esp8266_pwm
    pin: D4
    frequency: 1000 Hz
    id: avr_fan_pwm

fan:
  - platform: speed
    output: avr_fan_pwm
    name: "AVR Fan"

It works fine in home assistant when I set the speed to either low, mid or high.
Problems is I need a finer granularity. a percentage value (1-100) would be most desireable.
Is this doable in esphome ?

If I try and set a integer value for the “speed” attribute I get an error in my call.
This is when using the service section under dev tools (fan.set_speed).

my previous custom coded fan controller for the esp8266 supported MQTT and had a working home assistant config. that looked like this:

- platform: mqtt  
    name: "Blæser AVR"  
    state_topic: "enkegaard/firstfloor/avr/fan/on/status"
    command_topic: "enkegaard/firstfloor/avr/fan/on/set"    
    payload_off: "0"
    payload_on: "1"
    speed_state_topic: "enkegaard/firstfloor/avr/fan/speed/status"
    speed_command_topic: "enkegaard/firstfloor/avr/fan/speed/set"    
    payload_low_speed: "20"
    payload_medium_speed: "50"
    payload_high_speed: "100"        
    qos: 2
    speeds:      
      - low
      - medium
      - high

I’m currently in the process of reflashing my custom coded ESP8266 modules with similar functionality using esphome as its way easier to maintain etc.
But I guess I could just go back to my old custom firmware ?

A fan intregration with “continuous” levels to use with PWM would in general be nice to have in HA in the first place.

@gibman Are you using a 4 pin fan?

Yes… im using a 4pin pwm fan.
Works great

As a workaround, could you set it up as a monochromatic light instead? Then the speed should be able to be adjusted using the “brightness”. Tweak as desired (icon, slider-entity-row, etc.) to get the right look in the UI.

-J