[SOLVED] Broadlink Mqtt binding config

Hardware :pi3
OS: openhab 2.3

hello

i want to contol broadlink ir devices, and i found this

i install this on my openhabian, and its working great from its GUI, i can record and send IR commands, i have problem to config the mqtt binding to send command to this, i tried to config it like this

broadlink.url=tcp://192.168.1.101:3000
broadlink.user=openhabian
broadlink.pwd=openhabian

(i tried with and without passwod and user) but i receive this message in the log



  2018-11-03 02:19:17.731 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.

2018-11-03 02:19:17.741 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broadlink'

2018-11-03 02:19:17.800 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection

org.eclipse.paho.client.mqttv3.MqttException: Connection lost

	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146) [252:org.openhab.io.transport.mqtt:1.12.0]

	at java.lang.Thread.run(Thread.java:748) [?:?]

Caused by: java.io.EOFException

	at java.io.DataInputStream.readByte(DataInputStream.java:267) ~[?:?]

	at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65) ~[?:?]

	at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107) ~[?:?]

	... 1 more

please help

thanks

you need a MQTT Broker in the middle

read also MQTT Binding (v1.11) Getting Started 101

1 Like

Let me know

How you go cause I’m thinking about doing something like this too.

@Noam_Shaharabani, @adtwomey

The mqtt.cfg tcp address needs to point to the mqtt broker address. Have you installed a broker like mosquitto?

No, I thought that the broker is the bridge i installed for broadlink

do i need to install something else beside the broadlink bridge and the mqtt binding?

thanks

Yes as above, you need a mqtt broker. mosquitto is the most common one used.
See:

Thanks

i saw on the addon in openhabe there is " Embedded MQTT Broker" i installed it and i get this every few seconds in the log

==> /var/log/openhab2/openhab.log <==

2018-11-03 13:31:45.397 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '127.0.0.1' with clientid embedded-mqtt-broker and file store '/var/lib/openhab2/mqtt/127.0.0.1'

how can i config this ?

Did you install the mqtt binding?
The mqtt.cfg in the /services folder need to look like this:

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

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

You need to read the documentation
Did you read the link above?

Did you read the mqtt binding documentation?

Based on your questions, you are trying to rush through it and not understand properly what mqtt is and how is works.

Read the docs…

i read the mqtt bindind, and also the link you give me, i know how to set the config file of the mqtt i arleady post it on the first message, i did not know i need to install broker

i’m new in this, and i did not found any documentation on hoe to install ang config the broker on openhab, in the link you provided there are few software for windows, mac and android, but i want to ru this on the pi3 with the openhabian

as i mention, there is " Embedded MQTT Broker" but there is no documentation for this addon and i have no idea how to config it

i only open this thread because i didn’t understand the documentation and not becuse i did not reat it, and for now, i cant find any documentation for the " Embedded MQTT Broker" addon in openhab

thanks

In openhabian you have an option to install mosquitto
Remove the embeded mqtt broker and install mosquitto

@Noam_Shaharabani

In openhabian you have an option to install mosquitto
Remove the embeded mqtt broker and install mosquitto

thanks, i installed the mosquitto and config the mqtt binding and now i dont get error when connecting

2018-11-03 16:41:26.988 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'

this is my item

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

i cant understand how can i send this command to the boadlink scipt i install on the pi3, to get into the gui of the boadlink i go to this address in the browser

192.168.1.101:3000

do i need to config the mosquitto.conf with the ip address and port?
and if yes, what do i need to put in there

this is the broadlink script

thanks

No you don’t

but the item does not do anything

there is something more that i missing ?

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