Configuring sensors.yaml for spotify for a noob

Hi all,

YAML sadly is something that manages to utterly confuse me. I have homeassistant happily running and would like to integrate a spotify control via ESPHome, as shown here Awesome Spotify Touch Control via ILI9341-Screen

However - for the life of me - i don’t get my sensor to work. I tried different variations, e.g.

sensor:
  - platform: edl21
    serial_port: /dev/ttyUSB0
    name: Stromzaehler

  esp32_media_player_current_title:
    friendly_name: "Joe's current spotify title"
    value_template: "{{ state_attr('media_player.spotify_joe','media_title') }}"

which doesn’t work, or e.g.

sensor:
  - platform: edl21
    serial_port: /dev/ttyUSB0
    name: Stromzaehler
  - platform: template
    sensors:
      esp32_media_player_current_title:
        friendly_name: "Joe's current spotify title"
        value_template: "{{ state_attr('media_player.spotify_joe','media_title') }}"

What am I doing wrong?

Hi Joey,

the second version seems to be ok. Do you get an error message?
Can you see the attributes of the spotify player? (in Dev → States)
BTW, the attributes are only available, when Spotify in playing.

Best,
Axel

Hi Axel,

I can see the actual attributes of the spotify player. However I cannot see the actual sensor. I also don’t get an error message in the second example. The first example delivers me an error message.

Best,
Joey

Hi Joey,

does the sensor template resolve, when you put it to Development - > Template (template Editor)?

This one works for me:
{{ state_attr(‘media_player.spotify_xxx’, ‘media_title’) }}

Axel

Now it worked, I see it under states as well… Thanks so much! @brix29

Great. You are welcome! :muscle: