Fan Speed control ESP Home

I have a fan speed control circuit and I would like to integrate it to the home assistant using esp home. I have used the slider speed control component of esp home. I am getting the following error.

My code

esphome:
name: fantest

esp32:
board: esp-wrover-kit
framework:
type: arduino

Enable logging

logger:

Enable Home Assistant API

api:
encryption:
key: “+zlIPRvkYW7PPIUArp1cRVbI8RTyDxIiLHzGZ6FW8J8=”

ota:
password: “7c0dbc14bdeb7b0b1b2a80e9fa7d9c05”

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “Fantest Fallback Hotspot”
password: “RsjSfReXIMag”

captive_portal:

switch:

  • platform: gpio
    pin: 5
    name: “Master Bedroom Fan Speed Relay 1”
    id: mbedspeed1
  • platform: gpio
    pin: 18
    name: “Master Bedroom Fan Speed Relay 2”
    id: mbedspeed2

output:

  • platform: template
    id: custom_fan
    type: float
    write_action:
    • if:
      condition:
      lambda: return ((state == 0));
      then:
      # action for off
      - switch.turn_off: mbedspeed1
      - switch.turn_off: mbedspeed2

    • if:
      condition:
      lambda: return ((state > 0) && (state < 0.3));
      then:
      # action for speed 1
      - switch.turn_on: mbedspeed1
      - switch.turn_off: mbedspeed2

    • if:
      condition:
      lambda: return ((state > 0.6) && (state < .9));
      then:
      # action for speed 3
      - switch.turn_on: mbedspeed1
      - switch.turn_on: mbedspeed2

fan:

  • platform: speed
    id: mbedfan
    output: custom_fan
    name: “Master Bedroom Fan”
    speed_count: 2

Could someone help me.