[SOLVED] Fbacker/broadlink-mqtt-bridge

  • Platform information:
    • Hardware: Raspberry Ip
    • OS: openhabian
    • openHAB version: openHAB2.4
      I trying to get this to work.

I have don every thing I think I may of missed something can some one help

yes I have MQTT Binding (v1.x)
have use mqtt fx to

broadlink/epson_projector/menu
play

and it worked.

mqtt.cfg

#
# 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>

Items

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

site map

Frame label="Garage"
       {
           Switch item=DEMOSW
           Switch item=Menu

Configure

in ./config there’s a couple of options in default.json. Do not change this. This is the default settings that can be overwritten. Make your own file ./config/local.json and only add and change values that you want.

NOTE: Changing the default.json will 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
  }
}

Let’s start with the basics…
Is your Mosquitto up and running? (sudo systemctl status mosquitto.service)
Is your OH2 MQTT Binding up and running? (any other existing MQTT bound items work?)

Change your /etc/openhab2/services/mqtt.cfg to:

pid:org.openhab.mqtt
broker.url=tcp://127.0.0.1:1883

I assume that Mosquitto is running on the same (local) host as OH2… correct?

Then we tackle the broadlink bridge stuff

p.s every thing works with MQTT FX
An my othere items work with OPENHAB MQTT before fbacker told me to do
try to create a local.json in broadlink/config and add to fix broadlink.

{
  "mqtt": {
    "host": "192.168.0.4"
  }
}

now MQTTFX still works but no MQTT items in my openhab.

 mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
   Active: active (running) since Tue 2018-11-06 10:41:28 AEST; 4h 29min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 352 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/mosquitto.service
           └─414 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Nov 06 10:41:28 openHABianPi systemd[1]: Starting LSB: mosquitto MQTT v3.1 message broker...
Nov 06 10:41:28 openHABianPi mosquitto[352]: Starting network daemon:: mosquitto.
Nov 06 10:41:28 openHABianPi systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker

Ok I don’t get were to put this do I need to put it in my MQTT.cfg.

My MQTT.cfg

#
# 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>

change your mqtt.cfg and put these 2 lines as the first 2 lines
everything else below should be commented out (with #)

pid:org.openhab.mqtt
broker.url=tcp://127.0.0.1:1883

#
# 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>
...

Is your broker running on the same host as OH2 and the broadlink bridge?

pid:org.openhab.mqtt

broker.url=tcp://127.0.0.1:1883

#

# Define your MQTT broker connections here for use in the MQTT Binding or MQTT

# Persistence bundles. Replace &lt;broker&gt; 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.

#&lt;broker&gt;.clientId=&lt;clientId&gt;

# 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.

#&lt;broker&gt;.allowLongerClientIds=false

# Optional. User id to authenticate with the broker.

#&lt;broker&gt;.user=&lt;user&gt;

# Optional. Password to authenticate with the broker.

#&lt;broker&gt;.pwd=&lt;password&gt;

# 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.

#&lt;broker&gt;.qos=&lt;qos&gt;

# Optional. True or false. Defines if the broker should retain the messages sent to

# it. Defaults to false.

#&lt;broker&gt;.retain=&lt;retain&gt;

# Optional. True or false. Defines if messages are published asynchronously or

# synchronously. Defaults to true.

#&lt;broker&gt;.async=&lt;async&gt;

# Optional. Defines the last will and testament that is sent when this client goes offline

# Format: topic:message:qos:retained &lt;br/&gt;

#&lt;broker&gt;.lwt=&lt;last will definition&gt;

yes

then use 127.0.0.1 also in your ./config/local.json

{
  "mqtt": {
    "host": "127.0.0.1"
  }
}

edit: actually this is not needed, since 127.0.0.1 is already within default.json, so no need to create a local.json

there is already and default.json with —>

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

I Delete config/local.json once I find out I lost all my othere MQTT items eg: MK Smart House spinkler system. after Delete it didn"t come back working.

you need me to bring back local.json or is default.json will do the job now?

the broadlink configs have nothing to do with your other MQTT stuff (like the MK SH sprinklers)
something else is wrong. how have you defined the other mqtt items?

no need for a local.json. just use the default one

ok what next I get broadlink up 1st

Switch MKSprinklerSystemZone1 "Sprinklers Zone 1" &lt;water&gt; [ "Switchable" ] {mqtt="&gt;[broker:MKSmartHouse/utilities/MkSprinklerSystem:command:ON:Z1ON],&gt;[broker:MKSmartHouse/utilities/MkSprinklerSystem:command:OFF:Z1OFF],&lt;[broker:MKSmartHouse/utilities/MkSprinklerSystem/state:state:ON:Z1ON],&lt;[broker:MKSmartHouse/utilities/MkSprinklerSystem/state:state:OFF:Z1OFF]", autoupdate="false"}

Switch MKSprinklerSystemZone2 "Sprinklers Zone 2" &lt;water&gt; [ "Switchable" ] {mqtt="&gt;[broker:MKSmartHouse/utilities/MkSprinklerSystem:command:ON:Z2ON],&gt;[broker:MKSmartHouse/utilities/MkSprinklerSystem:command:OFF:Z2OFF],&lt;[broker:MKSmartHouse/utilities/MkSprinklerSystem/state:State:ON:Z2ON],&lt;[broker:MKSmartHouse/utilities/MkSprinklerSystem/state:State:OFF:Z2OFF]", autoupdate="false"}

Switch MKSprinklerSystemZone3 "Sprinklers Zone 3" &lt;water&gt; [ "Switchable" ] {mqtt="&gt;[broker:MKSmartHouse/utilities/MkSprinklerSystem:command:ON:Z3ON],&gt;[broker:MKSmartHouse/utilities/MkSprinklerSystem:command:OFF:Z3OFF],&lt;[broker:MKSmartHouse/utilities/MkSprinklerSystem/state:state:ON:Z3ON],&lt;[broker:MKSmartHouse/utilities/MkSprinklerSystem/state:State:OFF:Z3OFF]", autoupdate="false"}

Switch SprinklerCycle "20 Minute Cycle" &lt;water&gt; [ "Switchable" ]

Switch SprinklerSystemSchedule "Sprinkler System Schedule" &lt;calendar&gt; [ "Switchable" ]

I don’t know how the MK Sprinkler system works but your mqtt items seem to be ok
they don’t work?

you need to follow the instructions on https://github.com/fbacker/broadlink-mqtt-bridge/blob/master/README.md

did you use the AutoInstaller or the manual installation method?

AutoInstaller

is the bridge running?

I don’t know how to check. there is nothing in home.things file

what is the output of:

ls -al /srv/openhab2-conf/broadlink-mqtt-bridge/
ls -al /home/openhabian/broadlink-mqtt-bridge
ps -efw |grep index.js

log files

2018-11-06 15:52:58.478 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SprinklerSystemSchedule' for widget org.eclipse.smarthome.model.sitemap.Switch

2018-11-06 15:52:58.481 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Switch

2018-11-06 15:52:58.484 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SprinklerSystemSchedule' for widget org.eclipse.smarthome.model.sitemap.Switch

2018-11-06 15:52:58.487 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SprinklerSystemSchedule' for widget org.eclipse.smarthome.model.sitemap.Switch

2018-11-06 15:52:58.490 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'SprinklerSystemSchedule' for widget org.eclipse.smarthome.model.sitemap.Switch

2018-11-06 15:53:03.447 [INFO ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/Menu' for the unknown item 'Menu'.

2018-11-06 15:53:06.106 [INFO ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/Menu' for the unknown item 'Menu'.

2018-11-06 16:19:11.717 [INFO ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/MKSprinklerSystemZone1' for the unknown item 'MKSprinklerSystemZone1'.

2018-11-06 16:19:13.965 [INFO ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/Menu' for the unknown item 'Menu'.

2018-11-06 16:19:49.654 [INFO ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/MKSprinklerSystemZone1' for the unknown item 'MKSprinklerSystemZone1'.

2018-11-06 16:19:50.977 [INFO ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/Menu' for the unknown item 'Menu'.

do I put that on in one line??

3 different commands in the Linux shell

you have another mess in your hands :slight_smile:
maybe something is wrong with your items files… you need to double check them

[16:31:26] openhabian@openHABianPi:~$ ls -al /srv/openhab2-conf/broadlink-mqtt-bridge/
total 224
drwxrwxr-x+  10 openhabian openhabian  4096 Nov  5 15:31 .
drwxrwxr-x+  14 openhab    openhabian  4096 Nov  5 15:29 ..
drwxrwxr-x+   3 root       root        4096 Nov  5 15:31 commands
drwxrwxr-x+   2 openhabian openhabian  4096 Nov  6 10:39 config
-rw-rw-r--    1 openhabian openhabian  1586 Nov  5 15:29 device.js
-rw-rw-r--    1 openhabian openhabian    51 Nov  5 15:29 .dockerignore
-rw-rw-r--    1 openhabian openhabian   163 Nov  5 15:29 .eslintrc.json
drwxrwxr-x+   8 openhabian openhabian  4096 Nov  6 16:03 .git
drwxrwxr-x+   2 openhabian openhabian  4096 Nov  5 15:29 github
-rw-rw-r--    1 openhabian openhabian    61 Nov  5 15:29 .gitignore
drwxrwxr-x+   2 openhabian openhabian  4096 Nov  5 15:29 html
-rw-rw-r--    1 openhabian openhabian 20648 Nov  5 15:29 index.js
drwxrwxr-x+   3 openhabian openhabian  4096 Nov  5 15:29 installers
-rw-rw-r--    1 openhabian openhabian    21 Nov  5 15:29 .jshintrc
drwxr-xr-x+ 185 openhabian openhabian  4096 Nov  5 15:30 node_modules
-rw-r--r--    1 root       root       14021 Nov  6 16:31 output.log
-rw-rw-r--    1 openhabian openhabian   465 Nov  5 15:29 package.json
-rw-rw-r--    1 openhabian openhabian 57138 Nov  5 15:30 package-lock.json
-rw-rw-r--    1 openhabian openhabian  7035 Nov  5 15:29 README.md
drwxrwxr-x+   2 openhabian openhabian  4096 Nov  5 15:29 .vscode
-rw-rw-r--    1 openhabian openhabian 53843 Nov  5 15:29 yarn.lock
[16:31:45] openhabian@openHABianPi:~$ ls -al /home/openhabian/broadlink-mqtt-bridge
ls: cannot access '/home/openhabian/broadlink-mqtt-bridge': No such file or directory
[16:32:47] openhabian@openHABianPi:~$ ps -efw |grep index.js
root       399     1  1 16:30 ?        00:00:02 /usr/bin/node index.js
openhab+  1106   929  0 16:33 pts/0    00:00:00 grep --color=auto index.js