I have an OpenHAB 2 and MQTT broker working together successfully for a few different devices.
Right now I’m trying to get a Rollershutter working with a Broadlink RM Pro+ and broadlink-mqtt-bridge.
Broadlink-mqtt-bridge is installed and connected to my MQTT broker. I’m able to learn and play commands through the broadlink-mqtt-bridge web interface successfully.
My challenge is with the thing, item and sitemap configurations in OpenHAB. It seems that broadlink-mqtt-bridge requires a different topic for each command (up, down, stop), and I apparently need to be able to send the action “play” to the specific topic.
The documentation for broadlink-mqtt-bridge only shows .items entry for a switch example, like so:
I use PaperUI to configure my things and items. Using PaperUI, how would I create a similar channel/item/sitemap for a rollershutter? When I create a rollershutter channel/item in PaperUI, it only gives me one field for the topic…and the actions being sent to that topic are 0 or 100.
Assuming you are using the MQTT 2.x binding the Rule would look something like:
rule "Rollershutter"
when
Item Rollershutter_Proxy received command
then
val mqttActions = getActions("mqtt","mqtt:mosquitto:broker")
val topic = "broadlink/rollershutters/indoor/window1/"
var cmd = ""
switch(receivedCommand){
UP: cmd = "up"
DOWN: cmd = "down"
// and so on
}
mqttActions.publish(topic+cmd, "play")
end
I don’t know these devices so I’m making up the topic names and commands.
Yes, I’m using the MQTT 2.4 binding. I have a generic MQTT broker thing set up that points to an external MQTT broker.
Just curious before I go down the path you suggest…
The example I showed above is a switch item from a .items file that has multiple topics and specified actions. In looking at the source documentation (https://github.com/fbacker/broadlink-mqtt-bridge), he seems to reference the MQTT 1 binding. Is it no longer possible to apply multiple topics to an item with the MQTT 2.x binding, or is the issue that I’m using PaperUI and it isn’t possible to configure it this way in PaperUI?
Okay, so it sounds like even if I used a .items file, I wouldn’t be able to do this with MQTT 2.x because it doesn’t allow a separate topic for each command. Is that right? Thanks again for your help, I’ll respond back when I get this working so others can benefit from my experience.
I think that’s correct. You can do all sorts of manipulations on the payload, but not the topic.
It is possible to link multiple channels to one Item, which offers a glimmer of hope because channels may have different topics … but I cannot see.any way to suppress each channel sending when the “wrong” command is seen.
There is an allowedStates configuration for channels. What you’d need is an allowedCommands equivalent.
If a use case could be made - let’s say to filter out ON/OFF from numerics for a Dimmer and route to different topics - it might be worth raising an enhancement request on Github.
Okay, I’m all set with the proxy rule…here’s what I did, nearly identical to what Rich suggested.
rule "Rollershutter1 proxy"
when
Item RollerShutter1 received command
then
val mqttActions = getActions("mqtt","mqtt:broker:<id>")
val topic = "broadlink/rollershutters/1/"
var cmd = ""
switch(receivedCommand){
case UP: cmd = "up"
case DOWN: cmd = "down"
case STOP: cmd = "stop"
}
mqttActions.publishMQTT(topic+cmd, "play")
end