[CLOSED] MQTT binding version 2.4 (Pre-release !)

Okay, I finally figured out how to try out the new mqtt binding with OpenHabian: You need to manually DOWNGRADE from the M4 milestone build to the daily snapshot! Apparently the debian versioning system regards M4 as a higher version number than 20181018…

Anyway, I now have a test installation up and running and I must say, I’m impressed. And I take back most of the things I said in the previous post.
As you have to manually create the channels for each variable manually (with a different command topic where applicable), you really have all the flexibility that one needs. For my example of the RFLink thermometer, one can easily set up three channels with the same topic and use different transformations (you need to press “Show More” to show the input field for the transformation, but then you even get the nice hint how to use it).

So, the only thing that is left is the transformation for the command. To turn the Venta humidifier on, I need to send “ventapower 1” to the command topic rather than only the item value 1. Similarly, to switch to a given level, I need to send “ventalevel [level]”. Having a command transformation would be very helpful.
In the old mqtt binding, the transformation for the level was simply ‘ventalevel {command}’, while for the on/off command I had to condition on the current status and send the opposite status, i.e.

mqtt=">[mqtt:/Venta/Venta/cmd:command:ON:ventapower 1], 
>[mqtt:/Venta/Venta/cmd:command:OFF:ventapower 0]"

Another issue I encountered was that the temperature was defined as a decimal, but at least the display in PaperUI showed it as integer. So even though the thermometer resported a temperature of 15,6C, the PaperUI showed 16C.

@reinhold
And did the MQTT 1.x still ran in the meantime?
I don’t want to migrate everything in one go. This is going to take hours!! and I don’t want hours of down time

Mqtt1 will get automatically uninstalled but you can just reinstall it. It will run side by side but that should be temporarily only.

Cheers David

How can I use the new mqtt binding with .things files?

I have tried to create the MQTT things via .things files rather than through PaperUI. The things are generate and the channels appear in PaperUI, but I cannot get any values for them. My mqtt-things.things file is:

Bridge mqtt:broker:10_0_0_113_1883 "MQTT Broker: Mosquitto Raspi"  [ 
	host="10.0.0.113",
	port=1883,
	clientid="dreistein_raspi_binding",
	secure="OFF"
] {}

Thing mqtt:topic:7f5f9964a "ESP32 OLED things" (mqtt:broker:10_0_0_113_1883) @ "Arbeitszimmer" {
    Channels:
        State Number : UptimeState [ stateTopic="/esp32oled/Uptime/" ]
}

Thing mqtt:topic:210b5763a "MQTT Außenthermometer things" (mqtt:broker:cbaa07b1) @ "Wohnzimmer" [] {
	Channels:
		State Number : Temperature "Temperatur things" [ stateTopic="/RFLink/sensors/Alecto V1/00bc", transformationPattern="JSONPATH:$.TEMP", isfloat=true]
		State Number : Humidity "Luftfeuchtigkeit things" [ stateTopic="/RFLink/sensors/Alecto V1/00bc", transformationPattern="JSONPATH:$.HUM", isfloat=true]
		State Switch : Battery "Batteriestand things" [ stateTopic="/RFLink/sensors/Alecto V1/00bc", transformationPattern="JS:MQTT_BatteryState.js"]
}

In the karaf console I get the warnings:

2018-10-21 15:38:27.117 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'mqtt-thing.things'
2018-10-21 15:38:27.221 [INFO ] [.transport.mqtt.MqttBrokerConnection] - Starting MQTT broker connection to '10.0.0.113' with clientid paho4829060945385722 and file store '/var/lib/openhab2/mqtt/10.0.0.113'
2018-10-21 15:38:27.241 [WARN ] [internal.handler.GenericThingHandler] - Channel Uptime has no type
2018-10-21 15:38:27.301 [WARN ] [internal.handler.GenericThingHandler] - Channel Temperatur things has no type
2018-10-21 15:38:27.307 [WARN ] [internal.handler.GenericThingHandler] - Channel Luftfeuchtigkeit things has no type
2018-10-21 15:38:27.315 [WARN ] [internal.handler.GenericThingHandler] - Channel Batteriestand things has no type

And if I link the channels to an item, the items always have value NA…

I’m failing to use this too.

I’ve set up the “internal MQTT broker” and can connect to it (also verified from MQTT.fx).
I have connected a (Sonoff-Tasmota) device to the MQTT broker and can see the messages (again through MQTT.fx).

When I try to set up a simple thing/item combination to read the status, I cannot find the solution.

Here is what I have tried:

Thing mqtt:topic:sonoff-h801-1 "Sonoff H801 1 Thing" (mqtt:broker:127_0_0_1_1883) {
    Channels:
        State String : Status [ stateTopic="stat/sonoff-H801-1/RESULT" ]
}

OR

Thing mqtt:topic:sonoff-h801-1-test "Sonoff H801 1 Thing" (mqtt:broker:127_0_0_1_1883) {
    text [ mqttstate="stat/sonoff-H801-1/RESULT", mqttcommand="lamp/command" ]
}

The first creates a new Thing (I see it in the PaperUI), the second fails to create a thing.
When I try to connect to the thing with an item:

String  Sonoff_Bedroom_Test "Bedroom Light: MQTT return message [%s]"               (gMQTT,gBedroomLight) {channel="mqtt:topic:sonoff-h801-1:Status"}

The log says:

2018-10-22 19:25:37.791 [WARN ] [nal.handler.AbstractMQTTThingHandler] - Channel Status not supported

Any hints?

EDIT:

I’ve also tried configuring everything through the PaperUI.
Creating the “MQTT Things” “Topic Thing” works.
However when adding the “Channel” I get an error 500 - Internal server error.

The second one is missing the Channels: statement

Everyone still having problems with this new MQTT bindings:
Please wait for the fixes coming with https://github.com/eclipse/smarthome/pull/6339. Probably available in OH snapshots within a few days after the fixes got merged.

Cheers, David

3 Likes

@David_Graeff
As per the requests and questions you can see how some of us are eager to get our hands on this.
Some of us have even started experimenting
I am waiting for your word that it is ready to start experimenting

A lot of questions in the forum are related to MQTT so I really want to understand the set-up of things and items to be able to help on the forum

I, for one, am waiting with baited breath…

2 Likes

Thanks for the hint, I will be patient.
I already like the concept and can’t wait to migrate to the modern implementation!

Will report back when results show success!

@David_Graeff
I know your new MQTT binding is a work in progress. And, I for one, can’t wait until it is complete . I stumbled across a partial documentation at one point you had started to put together - I think it was in a PR. Can you share the link to your document in progress?

I have a binding I am working on that will rely on your homie implementation and would like to continue development and begin integration testing prior to the launch of Openhab 2.4.

It’s not a work in progress, it is fully finished. But without the mentioned fixes PR, it does not work reliably. Please wait for another few days. After the merge, the documentation will be available on the website as well.

Cheers, David

The binding documentation is still not linked to the binding in PaperUI (I’m running the latest OH SNAPSHOT). Is there a goal date for getting the documentation released…

… and the fixes to make the binding not work reliably?

Thanks.

Mike

Trying to test this out however I need to append the message payload to include NEOPIXELALL,(RGB VALUE). Is this possible?

Not yet. You can only transform incoming data. I have opened an issue.

@meingraham
The documentation will be linked with an official release only, I’m afraid. But I have a posted a link somewhere above to the repository file that will become the documentation.

And the last question was: when is it available? This is not in my hands. The Fixes-PR took three weeks for the eclipse license compliance team to review. Probably because of the eclipse Con happing right at that time. Each feature is carefully reviewed by the eclipse Smarthome team.
The main parts are all merged now though. I guess the next openhab snapshot release could include everything necessary.

Cheers,
David

I see the Build #1406 has the fixes!
I created topic-things and items through Paper UI and I see the item values change - it works!
But I still have some struggles with textual configuration.

My broker is this:

mqtt:broker:127_0_0_1_1883

and I can connect to it through other applications (using mqtt.fx) so that is OK too.

Then I copy-pasted from here: https://github.com/eclipse/smarthome/tree/master/extensions/binding/org.eclipse.smarthome.binding.mqtt.generic and only replaced the broker:

Thing mqtt:127_0_0_1_1883:topic:mything {
Channels:
    Type Switch : lamp "Kitchen Lamp" [ mqttstate="lamp/enabled", mqttcommand="lamp/enabled/set" ]
    Type Switch : fancylamp "Fancy Lamp" [ mqttstate="fancy/lamp/state", mqttcommand="fancy/lamp/command", on="i-am-on", off="i-am-off" ]
    Type EnumSwitch : alarmpanel "Alarm system" [ mqttstate="alarm/panel/state", mqttcommand="alarm/panel/set", allowedStates="ARMED_HOME,ARMED_AWAY,UNARMED" ]
    Type Color : lampcolor "Kitchen Lamp color" [ mqttstate="lamp/color", mqttcommand="lamp/color/set", rgb=true ]
    Type Dimmer : blind "Blind" [ mqttstate="blind/state", mqttcommand="blind/set", min=0, max=5, step=1 ]
}

Now what I get in the log is this:

2018-10-31 11:18:22.951 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'mqtt.things' has errors, therefore ignoring it: 
[18,10]: mismatched input 'Switch' expecting RULE_ID
[19,10]: mismatched input 'Switch' expecting RULE_ID
[21,10]: mismatched input 'Color' expecting RULE_ID
[22,10]: mismatched input 'Dimmer' expecting RULE_ID

What do I do? Did I specify the broker incorrectly?

@David_Graeff, for a Homie-device the channels are automatically generated?
Can the homie devices things also be automatically found by the inbox? That would be awesome!

Homie 3.0 only though

I’ve tested with a home assistant device, but get an error.
The thing would be automatically discovered, but when adding an error occurs.

in the log viewer I see :

2018-11-02 18:32:25.712 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'mqtt:homeassistant:192_168_5_49_1883:irrigation-' to inbox.
2018-11-02 18:32:41.511 [WARN ] [g.discovery.internal.PersistentInbox] - Cannot create thing. No binding found that supports creating a thing of type mqtt:homeassistant.

Am I missing something or did I found a bug?

the topic where i put the message is:

homeassistant/switch/irrigation/config

the payload:

{
    "name": "garden switch",
    "state_topic": "homeassistant/switch/irrigation",
    "command_topic": "homeassistant/switch/irrigation/set",
    "availability_topic": "homeassistant/switch/irrigation/available",
    "payload_on": "ON",
    "payload_off": "OFF",
    "state_on": "ON",
    "state_off": "OFF"
}

Kudo and thank you. I have a number of homemade esp8266 devices communicating with MQTT and the setup with the new binding was very simple. Everything configured through PaperUI, only file edit was to my sitemap.

No failures or problems to report. Thanks you

You found a bug :slight_smile:
I’ll have a look.

1 Like