Tuya fan speed changing template

Dear all.
I have connected my Tuya fan to HA using Tuya component.
But I am unable to make this template )given below) working to change speed.
The template only helps me to turn on the fan and running it again does not change the speed, but the fan speed stays the same. Somebody, please help me achieve this

data_template:
  speed: >-
    {%set s=state_attr('fan.04060105d8bfc0003b72','speed')|int%}{{ 1 if s>5 else
    s+1 }}
entity_id: fan.04060105d8bfc0003b72
service: fan.set_speed

If you look it up in the Developer Tools/States
What does it show
Screenshot please

when the fan is off, this is what shows in developer states"