MQTT – setup and use
-
Ah! Yes that explains the empty variable, though I'm going to have to dig into my lua book to understand why! I was assuming that the concat function returned a series of string values from a table, and therefore, the output could be sent to the log for display.
-
It works only for a contiguous array of numbers and/or strings...
local x = {"a ", 1, " b ", 2} local y = table.concat (x) print(y)
gives
a 1 b 2
@akbooer Ok, so the variable "message " contains more than just a value array.
I've never been able to get zerobrane as a debugger working with openLuup, though the instructions on how to do so have been written about previously. I just couldn't get the debugger working on a target remote PC, so it's difficult to watch what's going on within the myriad method code in the object model you've created. I don't write code for a living--never have-- though I use SQL, VBA and Python in my day to day job. The debuggers for those languages are a breeze compared to setting up zerobrane and Vera.....
-
Yes, the message structure is an object with various values and methods:
{ -- variables length = nb, -- byte count for statistics packet_type = packet_type, control_flags = control_flags, body = body, -- may include variable header and payload ptr = 0, -- pointer to parse position in body packet_name = pname, -- string name of packet type -- methods read_bytes = read_bytes, read_flag_byte = read_flag_byte, -- converting octet to 8 separate flag bits read_word = read_word, read_string = read_utf8, }
It's that way, because MQTT message formats are dependent on the type of message, so the methods contain here do some of that job. However, for the publish / subscribe functions, the topic and message parameters are simple strings, so easy to print out.
As for debugging, I run the entire openLuup system within ZeroBrane during development, so most things are directly traceable and the debugging facilities are very adequate. I've never, ever, tried to debug a remote system.
Still keen to discover the cause of your bridged server issue...
...have you tried enabling DEBUG of the MQTT module itself? It provides some useful information.
-
Yes, the message structure is an object with various values and methods:
{ -- variables length = nb, -- byte count for statistics packet_type = packet_type, control_flags = control_flags, body = body, -- may include variable header and payload ptr = 0, -- pointer to parse position in body packet_name = pname, -- string name of packet type -- methods read_bytes = read_bytes, read_flag_byte = read_flag_byte, -- converting octet to 8 separate flag bits read_word = read_word, read_string = read_utf8, }
It's that way, because MQTT message formats are dependent on the type of message, so the methods contain here do some of that job. However, for the publish / subscribe functions, the topic and message parameters are simple strings, so easy to print out.
As for debugging, I run the entire openLuup system within ZeroBrane during development, so most things are directly traceable and the debugging facilities are very adequate. I've never, ever, tried to debug a remote system.
Still keen to discover the cause of your bridged server issue...
...have you tried enabling DEBUG of the MQTT module itself? It provides some useful information.
-
@christian_fabre I added my Shelly 1PM today to OpenLuup v21.4.29b.
At first it did not work, and I could not figure out why. Then I found a post on the Shelly forum that said that there in some cases (or for some devices) could be a problem with the latest Shelly firmware and Mqtt.
I had the latest v1.10.3 in my 1PM. After I downgraded the Shelly to v1.9.4 it worked.
Check what firmware you have in your plug and if you have the latest you can try to downgrade and see if it works.
Go to https://www.shelly-support.eu/index.php?shelly-firmware-archive/ and enter your IP address, select the right plug variant (there are a few to choose from) and firmware release. Then you copy the url that is generated into a browser.
If you have blocked the Shelly in your router from Internet access you probably have to open it temporary for the downgrade.I also added my Shelly Button to OpenLuup and for some reason I could not downgrade it, but I managed to get it working anyway after a few attempts.
(A bit strange since the post I found on the forum was on problems with the Button and v1.10.3.)Another tip is to use MqttExplorer if you do not already use it and see if the Shelly shows up there. If it does, then at least the Mqtt part of the Shelly most likely works.
@archers said in MQTT – setup and use:
I found a post on the Shelly forum that said that there in some cases (or for some devices) could be a problem with the latest Shelly firmware and Mqtt.
Do we know if this issue has been solved yet?
I’ll update all my device firmware if so, but I’m loathe to do so without some sort of confirmation. TIA.
-
@archers said in MQTT – setup and use:
I found a post on the Shelly forum that said that there in some cases (or for some devices) could be a problem with the latest Shelly firmware and Mqtt.
Do we know if this issue has been solved yet?
I’ll update all my device firmware if so, but I’m loathe to do so without some sort of confirmation. TIA.
-
@archers said in MQTT – setup and use:
I found a post on the Shelly forum that said that there in some cases (or for some devices) could be a problem with the latest Shelly firmware and Mqtt.
Do we know if this issue has been solved yet?
I’ll update all my device firmware if so, but I’m loathe to do so without some sort of confirmation. TIA.
@akbooer today I set up a new Shelly Plug.
The firmware on it was quite old and I thought I would give the latest release a go and see if the Mqtt problem was solved. I loaded "v1.11.4-DNSfix" on the plug and then set up Mqtt as per my other Shellies, then - nothing. It did not show up in Mqtt Explorer at all.
I then downgraded to v1.9.4 on the plug and it immediately showed up as it should.
I did not dive down into the problem more, I will however stay away from the latest releases for the time being. On my devices v1.9.x does the job and Mqtt works.
As a side note I also set up a Shelly Flood that will live under the dishwasher and it seems to work pretty good. The Shelly battery devices are a bit of a pain to set up but I got it to work eventually. I have since before a Button1 that was painfully slow on battery; I run it on USB and then it is ok.
After having set up the flood sensor I tested it and it gave an alert as it should only after a few seconds delay.