MQTT - Publish Spotify currently playing track

Hello

I’m new to HA and MQTT , I figured out how to control spotify using MQTT to add it to my homeseer events , I couldn’t figure out how to make HA publish Spotify currently playing track to an MQTT topic to be able to show it in Homeseer , I’m currently relying on Homeseer for everything and use HA for all the other things that Homeseer doesn’t support .

can I do this using automation ? any help would be appreciated

Thanks
Rami

Old topic. :slight_smile: Have you found a solution?

Here is my automation for publishing Spotify to MQTT. It was done quickly and I didn’t leverage it yet but I plan to build an ESP-Home spotify jukebok.

alias: Spotify => MQTT
description: ''
trigger:
  - platform: state
    entity_id: media_player.spotify_mrr_holblin
condition: []
action:
  - service: mqtt.publish
    data:
      topic: ha-spotify
      payload_template: >-
        { "state": "{{states('media_player.spotify_mrr_holblin')}}",
        "volume_level": "{{state_attr('media_player.spotify_mrr_holblin',
        'volume_level')}}", "media_playlist":
        "{{state_attr('media_player.spotify_mrr_holblin', 'media_playlist')}}",
        "shuffle": "{{state_attr('media_player.spotify_mrr_holblin',
        'shuffle')}}", "repeat":
        "{{state_attr('media_player.spotify_mrr_holblin', 'repeat')}}",
        "media_title": "{{state_attr('media_player.spotify_mrr_holblin',
        'media_title')}}", "media_artist":
        "{{state_attr('media_player.spotify_mrr_holblin', 'media_artist')}}",
        "source": "{{state_attr('media_player.spotify_mrr_holblin',
        'source')}}", "media_duration":
        "{{state_attr('media_player.spotify_mrr_holblin', 'media_duration')}}",
        "media_position": "{{state_attr('media_player.spotify_mrr_holblin',
        'media_position')}}", "media_position_updated_at":
        "{{state_attr('media_player.spotify_mrr_holblin',
        'media_position_updated_at')}}", }
mode: restart
1 Like

Nice solution. Thank you!