Universal Media Player attributes bi-directional?

At first sight this integration seems like the perfect one to use to implement my Raspberry Pi that I use to control my Marantz receiver.
I programmed an MQTT interface on it so it can take MQTT commands to tell stuff to the Marantz via serial, and it reads serial updates from the Marantz and sends those back over MQTT.

Now I’m trying to use the Universal Media Player to integrate it into HA, but it seems like either the documentation is lacking or it’s just not possible to do this.
I want it to be bi-directional, so I control the receiver from HA, and if the receiver is controlled natively via the remote for example and have those changes be reflected in HA.

I figured out the first part, I can just call the mqtt.publish service and it works.
But I’m also trying to use the attributes. It seems like I’ll have to make seperate entities for every type of state (volume/source/etc).
I already made a volume one that updates when the volume changes. I then put this entity as

    attributes:
      volume_level: sensor.marantz_main_volume

but it is not changing the slider of the media player. In fact, that slider resets to max everytime I change it.
So my question is, is this an issue with the integration or an issue with my implementation?(or my expectations?)

Check the value of the volume that’s actually being sent by the Marantz. The media player volume goes from 0 to 1 - so if your receiver is sending over the raw volume level, and that volume is greater than 1, then the volume slider on the media player will always jump to max volume.

I don’t have a Marantz, but ran into a similar problem with my Yamahas. This is how I solved it.

Good call. I convert from HA volume to 0-100 volume already, but not the other way around.

  - platform: mqtt
    name: 'Marantz main volume'
    state_topic: "marantz/state/0/volume"
    entity_category: system
    value_template: "{{ states(entity_id) / 100 }}"

This is what I got currently, but it doesn’t seem to be doing anything. (still shows in 0-100) Do you know what to use for entity_id? I cannot find that in the documentation.

To set the volume, you mean? It’s not an entity, it would be a call_service to media_player.volume_set.

No, I’m getting a volume value between 0 and 100 from MQTT, and need to convert into a sensor between 0 and 1 for the HA media player to use. But I’ll just make sure the Pi sends avalue between 0 and 1 already, since Python is 100x easier than HA templates for me lol

Well, in my scripts where I need to get the value of some field, it looks like this:

'{{ states(''input_text.kitchenradio'') }}'

I would guess something similar? I’m not really an HA expert either (lots of trial and error here), but maybe something like

value_template: '{{ states(''entity_id'') | int / 100 }}'