TroyFernandes / hass-mqtt-mediaplayer

Fill out your Media Player Entity with MQTT Topics
MIT License
31 stars 18 forks source link

MQTT as input to topics #6

Closed charlesomer closed 3 years ago

charlesomer commented 3 years ago

Is it possible to use MQTT as the input to topics rather than sensors?

Currently the example is

topic:
      song_title: "{{ states('sensor.musicbee_nowplaying_songtitle') }}"

But I would like to do something like this but have had little success so far.

topic:
      song_title: "{{ states('mqtt.shairport-sync-living-room/title') }}"

I know shairport-sync-living-room/title works because I have a test sensor it works for.

Thank you

TroyFernandes commented 3 years ago

In the beginning the plugin used to use the example you provided (where you put the topic right in the config for the plugin). I forgot the reason I changed away from this, but I think it's because I wanted to remove a dependency within the plugin and it made more sense for Home Assistant to handle the subscribing to the topic.

It's more work to create sensors for each topic, but it should give less problems overall.

Does this example work for you? (This is how I have mine setup) ex:

sensor:
    - platform: "mqtt"
      state_topic: "musicbee/song/artist"
      name: "Musicbee_Song_Artist"

I have a custom sensor setup like above, and then I can just use that sensor name in the plugin config.

charlesomer commented 3 years ago

Yeah I'm using sensors now but at the time it would have been nice to not need to add these :)