MQTT Broker gateway
-
I think maybe it depends on the next protocol implementation. Personally i wouldn't mind if the full path mapping was /[0-255]/[0-255]/etc.. to keep (prog)mem print smaller (use the V_ and S_ array index values). It could leave space for more specific things or some extra gateway specific functions.
it would be nice if the mqtt gateway output was "cloned" to the serial output. Controllers should/could be able to map the S_ and V_ types internally. I'm not aware of the openhab config if that would allow this, or that such a setup would require a lot of coding at openhab side.
[EDIT]
It would be more difficult to read though if a path would only exist of numbers. But could also introduce easier maintainability in your library because you wouldn't have to keep track on type namings.
[/EDIT]. -
I think maybe it depends on the next protocol implementation. Personally i wouldn't mind if the full path mapping was /[0-255]/[0-255]/etc.. to keep (prog)mem print smaller (use the V_ and S_ array index values). It could leave space for more specific things or some extra gateway specific functions.
it would be nice if the mqtt gateway output was "cloned" to the serial output. Controllers should/could be able to map the S_ and V_ types internally. I'm not aware of the openhab config if that would allow this, or that such a setup would require a lot of coding at openhab side.
[EDIT]
It would be more difficult to read though if a path would only exist of numbers. But could also introduce easier maintainability in your library because you wouldn't have to keep track on type namings.
[/EDIT].@John That was my first aproach, and I might set a define configuration to choose if the MQTT gateway should translate or not. As you say, the footprint would be much smaller.
Might be next version of the MQTT, slectable address layout :) -
@Damme
That would be really cool :)It would be nice though if there was a way to identify node id's with AUTO turned on. Maybe i'm missing something or do you have to know up front with auto enabled which node id is going to be assigned?
I'm just asking this because of identifying new/existing nodes in the network. Is it the V_SKETCH_NAME i can refer to?
And i hope some last questions protocol specific:
- Version compatibility is 3.1?
- All session are clean by default?
-
@Damme
That would be really cool :)It would be nice though if there was a way to identify node id's with AUTO turned on. Maybe i'm missing something or do you have to know up front with auto enabled which node id is going to be assigned?
I'm just asking this because of identifying new/existing nodes in the network. Is it the V_SKETCH_NAME i can refer to?
And i hope some last questions protocol specific:
- Version compatibility is 3.1?
- All session are clean by default?
@John upon node startup it translates gw.sendSketchInfo("Battery Meter", "1.0"); into MyMQTT/20/255/V_SKETCH_NAME and version
so you could have a list as in my first post and it would get filled up with all your sketch names
@John ; Yes and I hope so :) (I might have missed some stuff, I do not take regard of QOS etc)
if its not working,, I'll try to fix it :) -
I can confirm it's working with UIPEthernet.h and the ENC28J60 module as well. You need to turn off debugging in MyConfig.h to make the code fit.
-
As I understand it:

The packet on the left would be from the node, the packet on the right would be to the node. Besides swapping sender and destination, the difference is that in 1.4 the gateway does not have the information to binary encode the value, so it sends the value as a string (payload type 0).
EDIT: added alternate MQTT respresentation of V_code as numeric -
As I understand it:

The packet on the left would be from the node, the packet on the right would be to the node. Besides swapping sender and destination, the difference is that in 1.4 the gateway does not have the information to binary encode the value, so it sends the value as a string (payload type 0).
EDIT: added alternate MQTT respresentation of V_code as numeric -
At first, I thought MQTT would be a great extension to the functionality, in particular because it might systematize the idea of routing messages to more than one destination - eg: to both a HA controller and to a cloud storage service.
So I saw these possible advantages of MQTT:
- Route to multiple destinations, dynamically updated
- Subscription wildcards to filter for desired subsets
- Possibly easier to build plug-ins for some HA controllers
As I look deeper into it, I'm coming to wonder about that.
- There are lighter weight ways to send to more than one destination
- Does subscription wildcarding meet the filtering needs well (below)?
- Is it easier or not?
I'm wondering what subscription wildcards really get used - how valuable is the type of filtering functionality offered by MQTT for our purposes? The meaingful patterns I would imagine are:
- everything
- everything from one node
- everything from one child of one node
- everything of type V_RAIN from one child of one node (ie: one variable)
- everything of type V_RAIN from anywhere
Are any of these (or other options) in use except "everything"? Do you anticipate that they will be?
Just as "route to multiple destinations" could be lighter, filtering could be done differently as well. For example, suppose you wanted to receive all report of inside temperature (7 sensors in your network) or humidity (5 sensors), but not outside temp or humidity and not other v codes. That might take 12 subscriptions - and they would have to be manually set up, or make use of manually entered metadata tables in the controller plug-in (eg: the plug-in might be configured to know which nodes had temp and/or humidity, and which ones were considered "inside", if it was written to handled that).
I could imagine that even if the subscription filtering wasn't highly useful, MQTT might make it easier to create plug-ins for some HA controllers, than using semicolon separated values (serial text format). Is that the case?
I'm very open to hearing other advantages of MQTT, I'm not against it, just trying to understand the benefits vs cost aspect better.
-
The other extension that occurs to me, in the gateway-as-transparent-switch model, is that if we ever wanted to encode binary values OTA from the gateway to the node, the plug-in would have to tell the gateway which payload_type to use. In the Semicolon Separted Values format, that could be another parameter, eg:
<node id>;<child id>;<command>;<ack>;<v_code>;<payload_type>;<value>Or it could be added to one of the other fields with a comma sub-delimiter, etc.
How would a controller plug in tell the MQTT gateway to use payload type P_UNIT16 to send to node 7?
I'm thinking that it would be done in the value string, rather than encoded into the topic. So maybe the value string goes from "321" to "4,321" or something like that.
-
@ToSa I'll update mqtt later with option to not translate V_TYPE into name string but to keep it as a byte, that would save a lot of memory and might solve problem you have. I'll keep you posted
@Damme said:
@ToSa I'll update mqtt later with option to not translate V_TYPE into name string but to keep it as a byte, that would save a lot of memory and might solve problem you have. I'll keep you posted
I could not follow the discussions the last few days - will definitely have a look over the weekend and let you know if that worked. Thanks!
-
@Damme
When the MQTT gateway prints information about itself like "started", is this done with node id 0 or 255?@John 'started' is only a internal log message, I've changed how that part works.
I've also fixed a couple of bugs and will test the changes tomorrow before I publish them.
New functionallity there user can choose of MQTT should translate ID to V_TYPE or not too. -
@Damme
Ok, my plugin will then just try to reconnect.Ok, i will check that then probably the day after tomorrow, i will make my code take no translation as first and if not found try the naming (internally), because the server takes over the semantics anyway because it also is going to include a MQTT broker service.
Currently the MQTT implementation is being tested with an end user. Maybe he will help test the new possibility without V_TYPE translation when your changes are implemented.
-
@Damme
When does exactly the messages like "MyMQTT/[NODEID]/255/V_SKETCH_NAME" and/or "MyMQTT/[NODEID]/255/V_SKETCH_VERSION" appear? is this only when an address is assigned or always when a node is started?@John then node is started, There was a bug not processing that message which is fixed now.
hasn't been pulled to official yet but can be found at https://github.com/Damme/MQTTGateway/commit/f10843f5efd9c37900624fe57275be11c69e3942 -
@John then node is started, There was a bug not processing that message which is fixed now.
hasn't been pulled to official yet but can be found at https://github.com/Damme/MQTTGateway/commit/f10843f5efd9c37900624fe57275be11c69e3942 -
Dear colleagues,
I have been using OpenHAB for a couple of days now, everything is going the right way, I've been using it with mosquitto broker for Windows, everything is solid, working well an fast. Decided to go a step further and use the MQTT Gateway presented here.
I've made a MQTT Gateway but get the "Not connected to broker" message from OpenHAB. First of all, the Gateway is an arduino uno with a w5100 shield on top in which I inserted the RF module (NRF24L01). Configured my ip in the gateway sketch (192.168.1.11) and uploaded to the arduino.
The first test was to connect with a phone (using MQTT from Playstore - used it many times before) and with a PC (using WMQTT Utility - used it many times before) and things don't look that promising, the problem beeing that client somethimes disconnects, and I cannot receive the message published in a topic (topic that I am subscribed to on the phone, pc and tablet using MQTT clients). I somethimes get the message in the serial monitor of the arduino, somethimes not.
Configured openhab.cfg to use the mqtt broker at 192.168.1.11 (before I was using mosquitto on pc 192.168.1.10 and working without problems) and everythime I change state of something in the dashboard of openhab I get this Broker Connection not Started even if after starting openhab I get serial output from arduino for some time, after this everything drops. Here is the serial output:serial_output.txt
Last two entries are: I opened the MQTT client on my phone, connected to MQTT Gateway and subscribed to topic home/# and the last one is me publishing from the phone to topic home/test the message "test message". None of the messages come back to the clients on the phone, tablet, pc, all of them subscribed to home/#
And here is the output from openhab: openhab_output.txt Ignore the samsung connect stuff, I have pull it off the network, i have managed to get it working well.
Best regards,
Adrian