Hi everyone,
I’m trying to integrate a BLE remote into openHAB via MQTT. The remote expects commands on the topic:
BLERemote/cmd
with payloads like:
-
PLAY -
PAUSE -
NEXT -
PREVIOUS
I would like to expose this in openHAB as a MediaPlayer Item so that the UI shows the proper media controls (play, pause, next, previous).
Here’s what I tried so far:
Thing
Thing mqtt:topic:bleremote "BLE Remote" {
Channels:
Type string : control "Media Control" [
commandTopic="BLERemote/cmd",
commandTransformation="JS:bleremote.js"
]
}
Transformation (transform/bleremote.js)
(function(command) {
switch(command) {
case "PLAY": return "PLAY";
case "PAUSE": return "PAUSE";
case "NEXT": return "NEXT";
case "PREVIOUS": return "PREVIOUS";
default: return "";
}
})(input)
Item
Player BLERemoteControl "BLE Remote" { channel="mqtt:topic:bleremote:control" }
The problem:
-
If I try to define the channel as
Type player, I getChannel mqtt:topic:bleremote:control not supported! -
Using
Type stringworks, but I’m not sure if this is the correct or recommended approach for binding aPlayerItem to MQTT.
My questions:
-
Is there a “best practice” way to map an MQTT topic to a
PlayerItem? -
Should I continue using a
stringchannel with aPlayerItem, or is there a better way? -
Has anyone built a similar MQTT → MediaPlayer setup and can share their config?
-
No command is send out finally, where is my failure of definition?
Thanks a lot in advance!