How to add track selection for DF Player Mini to dashboard

I am using a DF Player mini and an NodeMCU ESP8266. I’ve managed to created entities for some of the basic functions of the DF player, and can add those to the dashboard (stop, start, vol up, vol down). I’m stuck on play and set volume, as those require an input variable. How do I go about putting something on the dashboard that lets me pick a track to play (even if I’m just specifying an int for it) and how do I write the ESPHome YAML to do that?

Hi @BlueWRXPride

Maybe have a look at the test setup as looks like it has every option for the DF Player Mini.

I assume you add the api service:

  - service: dfplayer_play
    variables:
      file: int
    then:
      - dfplayer.play: !lambda 'return file;'

and then call the service from ha with data:

file: 1

Sorry, I probably wasn’t clear. I got that api service added and it works by manually calling the service in the developer section. I was struggling in figuring out how to be able to use that functionality from an automation or on the HA dashboard. But I think I figured out something that works late last night, even though it might be the most efficient. Into the yaml file I used a number which seems to interact correctly with the api service call. I was able to add that number to the dashboard and control the track this way.

number:
  - platform: template
    name: MP3_1_track
    max_value: 100
    min_value: 1
    step: 1
    mode: box
    optimistic: true
    on_value:
      then:
         dfplayer.play: !lambda 'return x;'