Configuring MQTT for node red (generic mqtt nodes)

mqtt
Tags: #<Tag:0x00007f1e5b4607a0>
(Vincent) #1

Hi All,

Well, all the Z-wave “Things” are configured and migrated from domoticz and working very nice, no problems here.
Next step for me is on how to connect node-red over mqtt with openhab.
I followed this guide: https://www.smarthomeblog.net/mqtt-openhab/ which helped me further, the broker is configured and node-red is connected to the broker but now, what are next stepts ?

From domoticz it was quite easy, every device action, sensor reading etc was configure to publish on topic domoticz/out , every action from node-red could write to domoticz/in.

This was an easy configuration which I was very happy with, al the filtering of devices was done in node-red, worked great.

Is a configuration like that possible in OpenHab ? I like to keep as much intelligence as possible in node-red, do if openhab can be configured to do the same, it would be nice…

Greetings,

Vincent

0 Likes

(Rich Koshak) #2

It’s my understanding that NodeRed has an openHAB node so there is no need to use MQTT for this. NodeRed supports OH natively.

The MQTT 1.x binding has a mode called EventBus which will allow OH to publish/subscribe to a topic that includes all events that occur on Items on the event bus. There is a way to do this using a Rule and the MQTT 2 binding as well.

0 Likes

(Vincent) #3

The problem with the opehab nodes in node-red is that this is a node for every “thing” and, that it is not generic. I prefer to use mqtt because it is a standard and allows me to switch controllers by seperating things.
I found another post, explaining the use of the standaard mqtt nodes with openhab, I’ll try that first.

0 Likes

(Odd Gilinsky) #4

I use the MQTT 1.x Eventbus, it works like you describes the domoticz in/out setup. I also use an external system (CDP Studio) for the logic, alarm handling, logging, standalone GUI, etc.) i.e. use OpenHAB as a bridge to all the bindings. I assume this was how OpenHAB started out in the first place. I did not see an easy way to set that up with the 2.x MQTT binding, so sticking to the 1.x, which in any way is just a few configuration lines, and works flawlessly.

0 Likes

(Vincent) #5

Thanks, I already figgured out that using the eventbus is the way to go…
Still, that does not provide payloads like I’m used to get (in JSON)
I’m pretty used to getting data in like this:

15-5-2019 10:54:39node: 6f9dbd3.a53e744
domoticz/out : msg.payload : Object
object
Battery: 255
RSSI: 12
description: ""
dtype: "General"
id: "00004101"
idx: 879
name: "Keuken Vaatwasser"
nvalue: 0
stype: "kWh"
svalue1: "0.000"
svalue2: "222520.000"
unit: 1

Is that something that is also possible ?
The other way around, I do sent values and actions from node-red to domoticz like this:

{"command": "switchlight", "idx": 2450, "switchcmd": "On" }
{"command": "switchlight", "idx": 2450, "switchcmd": "Set Level", "level": 100 }

More info is here : https://www.domoticz.com/wiki/MQTT

Is it hard to configure something like that ?

0 Likes

(Gad Ofir) #6

i also had that concern of a non generic flow in NR as you need a node for each item

it can be solved with the rest API and using templates…
i did not think on MQTT as solution to tell you the truth…

if you do such implantation do share with us… i never seem to have time for this … but i always think about it :slight_smile:

its right way to go from start, my flows are to scary now to tinker with this :slight_smile:

0 Likes

(Vincent) #7

Well, I do not have any interest in working via the rest API (then I can as well replace the mqtt nodes in node-red for the openhab nodes).
The nice thing of mqtt is that it has very little overhead and that it is a standard.
If mqtt implementation in openhab 2.5x is too complicated then I think I’ll wait a little longer…

0 Likes

(David Graeff) #8

There is only an mqtt2 binding in openHAB. A bindings tasks is to offer external integration into openHAB, not the other way round. To use an external tool you need another kind of addon called “IO Service” (like HomeKit, Hue Emulation, Alexa, Google Home).

So what you need is an MQTT IO Service. The mqtt1-eventbus addon is an IO service and therefore works best in this scenario.

0 Likes