[SOLVED] Broadlink Mqtt binding config

You don’t
You still haven’t understood how MQTT works
openHAB will send a message to the broker with a topic
Any client connected to the broker subscribed to taht topic will receive the message

You need to tell the broadlink bridge to connect to the broker
Is there an MQTT option if the bridge GUI? So that you can input the broker address and port?

no, in the gui there is only option to record\send ir, there config file in the folder of the broadlink

{
  "mqtt": {
    "host": "127.0.0.1",
    "port": 1883,
    "protocol": "mqtt",
    "subscribeBasePath": "broadlink"
  },
  "recording": {
    "timeout": {
      "ir": 30,
      "rf": 30
    },
    "path": null
  },
  "gui": {
    "port": 3000
  }
}

i think this is the place, but i dont see the option to ad user name and password og the broker

Ok the next step, I highly recommend when dealing with mqtt is to install an mqtt monitor like mqtt.fx

Did you configure mosquitto to use a username and password?

Maybe you can try:

{
  "mqtt": {
    "host": "127.0.0.1",
    "port": 1883,
    "username": username,
    "password": password,
    "protocol": "mqtt",
    "subscribeBasePath": "broadlink"
  },
  "recording": {
    "timeout": {
      "ir": 30,
      "rf": 30
    },
    "path": null
  },
  "gui": {
    "port": 3000
  }
}

i remove the pass and username from mosquito, and now its finally working (thanks for all the help) and i can see that the broadlink can receive the message, but i have another problem

this is how i define my item (this is taken from the broadlink script page)

Switch tv "turn on tv" {mqtt=">[mosquitto:broadlink/tv/peerless/turnon:command:ON:play:0d43b4e42518],>[mosquitto:broadlink/tv/peerless:command:OFF:play:0d43b4e42518]"}

but i get an error, because the mqtt binding only let me send 5 parameters with “:”, this is the error from the log

 is not a valid outbound configuration: Configuration requires 5 parameters separated by ':'

when i remove one of the “:” its send the message, for example without the “0d43b4e42518” but this is the device id, so it receive message but it will not work as i need to send this id number

any idea how to solve this ?
thanks

The “problem” is that the developer is using the : as a delimiter to send play:{deviceid} for the mqtt payload and this conflicts with the structure of the mqtt binding config

Try to escape the extra colon with \\ (or \):

Switch tv "turn on tv" {mqtt=">[mosquitto:broadlink/tv/peerless/turnon:command:ON:play\\:0d43b4e42518],>[mosquitto:broadlink/tv/peerless:command:OFF:play\\:0d43b4e42518]"}

If it works, notify the developer of the bridge to update the readme https://github.com/fbacker/broadlink-mqtt-bridge/issues/6

Sources: How to convert MQTT into command? & [SOLVED] Item from mqtt topic with colons and JSONPATH & How to escape colon (:) in Item REGEX transformation

1 Like

Ok I think I have miss some think But don’t know.

1: 1 I trying to test on MQTT FX.
1: 2 # (try this one 1st)
1: 2 broadlink (then try this one too)
Then subscribe
1: 3 broadlink/epson_projector/menu
1: 4 play
Then Pulblish

2: TV menu in MQTT fx don’t come up

3: Items (I have try 3 ways so far)

//Test
Switch Menu                      "Menu"                                                 {mqtt=">[brokwe:broadlink/epson_projector/menu:command:ON:play\\:0d43b4e42518],>[broker:broadlink/epson_projector/menu:command:OFF:play\\:0d43b4e42518]"}
Switch Mebu2                     "MENU 2"                                               {mqtt=">[mqtt:broadlink/epson_projector/menu:command:ON:play]"}
Switch tv                        "turn on tv"                                           {mqtt=">[mosquitto:broadlink/epson_projector/menu:command:ON:play\\:0d43b4e42518],>[mosquitto:broadlink/epson_projector/menu:command:OFF:play\\:0d43b4e42518]"}

4: Sitmap files (3 ways)

Frame label="TV"  
	   {
           Switch item=Menu label="MENU"
		   Switch item=Mebu2 label="menu2"
		   Switch item=tv label="TV"

5: Log file

2018-11-04 20:28:48.228 [ome.event.ItemCommandEvent] - Item 'tv' received command ON

2018-11-04 20:28:48.236 [vent.ItemStateChangedEvent] - tv changed from NULL to ON

2018-11-04 20:28:50.914 [vent.ItemStateChangedEvent] - CurrentDate changed from 2018-11-04T20:27:50.864+1000 to 2018-11-04T20:28:50.869+1000

2018-11-04 20:28:51.653 [ome.event.ItemCommandEvent] - Item 'tv' received command OFF

2018-11-04 20:28:51.664 [vent.ItemStateChangedEvent] - tv changed from ON to OFF

6: Also this is my default.json (what I think I don’t change or I break updates)

{
  "mqtt": {
    "host": "127.0.0.1",
    "port": 1883,
    "protocol": "mqtt",
    "subscribeBasePath": "broadlink"
  },
  "recording": {
    "timeout": {
      "ir": 30,
      "rf": 30
    },
    "path": null
  },
  "gui": {
    "port": 3000
  }
}

7: Also this is my local.json (what I add my self but dont know what I or need to change)

{
  "mqtt": {
    "host": "127.0.0.1",
    "port": 1883,
    "protocol": "mqtt",
    "subscribeBasePath": "broadlink"
  },
  "recording": {
    "timeout": {
      "ir": 30,
      "rf": 30
    },
    "path": null
  },
  "gui": {
    "port": 3000
  }
}

Thanks Guys

I just fixed it to broker still not working

I think I stuffed up. From copying the text they had spaces.

I have fixed up but they is 2 epson_projector now

It’s still not working when using it.

But MQTT FX is working and understanding the controls.

Just not working on basic UR

thanks you! i add the // and now its working, i also post message for the developer to fix this

1 Like

Must be something wrong about mine something else missing cause

As MQTT FX is working with the link.

Can you post your mqtt.cfg file to verify its setup correctly.

I i haven’t change anything in that file in a while.

#
# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
broker.url=tcp://192.168.0.4:1883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a random default is generated.
#<broker>.clientId=<clientId>

# Optional. True or false. If set to true, allows the use of clientId values
# up to 65535 characters long. Defaults to false.
# NOTE: clientId values longer than 23 characters may not be supported by all
# MQTT servers. Check the server documentation.
#<broker>.allowLongerClientIds=false

# Optional. User id to authenticate with the broker.
#<broker>.user=<user>

# Optional. Password to authenticate with the broker.
#<broker>.pwd=<password>

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
#<broker>.qos=<qos>

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
#<broker>.retain=<retain>

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
#<broker>.async=<async>

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
#<broker>.lwt=<last will definition>

@adtwomey In the mqtt.cfg you need to change the name or use the same in the items file. The item above has brokwe not broker try changing the item to:

Switch Menu                      "Menu"                                                 {mqtt=">[broker:broadlink/epson_projector/menu:command:ON:play\\:0d43b4e42518],>[broker:broadlink/epson_projector/menu:command:OFF:play\\:0d43b4e42518]"}

Yep already fixed that still didn’t work

//Test
Switch Menu                      "Menu"                                                 {mqtt=">[broker:broadlink/epson_projector/menu:command:ON:play\\:0d43b4e42518],>[broker:broadlink/epson_projector/menu:command:OFF:play\\:0d43b4e42518]"}
 Frame label="TV"  
	   {
           Switch item=Menu label="MENU"
		 }
}

@H102
1:You think this could of don some thing?
2:Is there a away to just uninstall and reinstall?

Uninstall mqtt?

Check that the mqtt binding is installed and if you have the mqtt action binding installed I would uninstall it (mqtt action binding only).

@H102
@H102 Uninstall broadlink-maqq-bridge

I Uninstall and install MQTT
and install and then uninstall action-mqtt
still not working

2018-11-05 01:54:29.971 [thome.event.ExtensionEvent] - Extension 'action-mqtt' has been installed.

2018-11-05 01:54:53.937 [thome.event.ExtensionEvent] - Extension 'binding-mqtt1' has been installed.

2018-11-05 01:55:19.942 [INFO ] [core.karaf.internal.FeatureInstaller] - Uninstalled 'openhab-action-mqtt'

2018-11-05 01:55:19.947 [thome.event.ExtensionEvent] - Extension 'action-mqtt' has been uninstalled.