Fan template not recognizing preset and speed commands

I have configured a dummy air humidifier (off + 4 intensity modes) as a fan, because it seems to be best suited for such case. I have the following definition in my config:

# https://www.home-assistant.io/integrations/fan.template/  
fan:
  - platform: template
    fans:
      duka:
        friendly_name: "DUKA nawilzacz"
        value_template: "{{ int(states('counter.dukastate')) != 0 }}"
        percentage_template: "{{ float(states('counter.dukastate'))/4 }}"
        preset_mode_template: "{{ state_attr('fan.duka','preset_modes')[int(states('counter.dukastate'))]}}"
        turn_on:
          service: script.dukaspeed
          data:
            percentage: "{{ 0.25 }}"
        turn_off:
          service: script.dukaspeed
          data:
            percentage: "{{ 0.0 }}"
        set_percentage:
          service: script.dukaspeed
          data:
            percentage: "{{ float(percentage) }}"
        set_preset_mode:
          service: script.dukapreset
          data:
            preset_mode: "{{ preset_mode }}"
        speed_count: 4
        preset_modes:
          - 'off'
          - 'interested'
          - 'aroused'
          - 'horny'
          - 'nympho'

As you see set_percentage uses the exact same script as turn_on and turn_off. Yet on/off works and percentaga fails with “Failed to call service fan/set_percentage. Set of Tasks/Futures is empty.” Similarly with preset: “Service script.dukamode called service fan.set_preset_mode which was not found.” Is this a bug?

Another strange failure happens for these buttons:

type: buttons
entities:
  - entity: media_player.denon_avr_x1400h
    show_icon: true
    show_name: true
    icon: mdi:circle-small
    name: interested
    tap_action:
      action: call-service
      service: script.dukaspeed
      data:
        percentage: '{{ float(0.2) }}'
  - entity: media_player.denon_avr_x1400h
    show_icon: true
    show_name: true
    icon: mdi:pinterest
    name: aroused
    tap_action:
      action: call-service
      service: script.dukaspeed
      data:
        percentage: '{{ float(0.4) }}'
  - entity: media_player.denon_avr_x1400h
    show_icon: true
    show_name: true
    icon: mdi:audio-input-xlr
    name: horny
    tap_action:
      action: call-service
      service: script.dukaspeed
      data:
        percentage: '{{ float(0.6) }}'
  - entity: media_player.denon_avr_x1400h
    show_icon: true
    show_name: true
    icon: mdi:audio-input-xlr
    name: nympho
    tap_action:
      action: call-service
      service: script.dukaspeed
      data:
        percentage: '{{ float(0.8) }}'

They call exactly the same script, yet pressing them gives: “Failed to call service script/dukaspeed. TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’”

Can anyone help?