Player Item connected to MQTT

Running OH 4.1.3 on a RPi4

All configuration done using Main UI.

I’m trying to connect a Player item to and MQTT channel.

I configured the channel as a text channel with a command topic.

Here is the channel code

  • id: BrianRemote
    channelTypeUID: mqtt:string
    label: Brian Remote
    description: “”
    configuration:
    qos: 1
    commandTopic: brian/remote
    postCommand: true

The Item sends a command to the Thing but I don’t see any MQTT messages being sent

Did you set the mqtt bridge?

yes I have a working bridge handling lots of other topics

I’m trying to send to another topic called remote on this player

It’s difficult to figure this out without more details.

  • Try setting postCommand to false (a long shot, I’m not too familiar with this. It should have nothing to do with sending a command from item → thing. It’s for the other way around.)
  • Show us your full thing definition
  • Show us the item that is linked to this channel

Thanks for the quick response!
I realize my details were sketchy but I was looking for some guidance that it should work or is not not supported.

I’m going to try creating a new Thing instead of just adding a channel to a Thing I created a long time ago.

I did some tests. It seems that a String mqtt channel won’t accept PlayPauseType as a command.

So as a “trick”, you can add a profile in your player item to channel link. This one would work: profile="transform:DSL", commandFromItemScript="|input"

That converts the PlayPause command to a String which the mqtt will accept.

We should probably relax the requirement for the string channel so it could receive stuff like this though.

added that profile to the channel

Got an error in the events log

09:30:35.282 [ERROR] [n.module.script.profile.ScriptProfile] - Failed to process script ‘profile=“transform:DSL”, commandFromItemScript=“|input”’: Could not get script for UID ‘profile=“transform:DSL”, commandFromItemScript=“|input”’.

In the “itemtothingtransformation” option, you’d just type |input. I’m not sure if this works in openhab 4.1 but give it a try

yup, that worked!

Even though I’m sending commands my player does not respond.
Here is a screenshot from MQTT Explorer.

Apparently the commands need to to formatted as lower case with quotes, such as “play”

So I need to transform them in some way. Can that be done in the channel?

|input.toLowerCase

that did it!
Thanks again!

So this is working for the Play command.

The player item sends a Next command but my device needs a nextitem command. Can that be done?

Maybe use map transform instead of dsl.

thanks, I’ll give that a try