Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New MQTT support
I deleted the previous thread because it was now full of out of date information... Since we have the driver now pretty much at an initial release state, I wanted to start a new one that wouldn't confuse folks who haven't been following along. This information is as of 5.3.951 an beyond. The driver is documented under the Miscellaneous driver category. It's not in the online stuff yet because that's for the released version. It's only in the local, installed help content. I'm pretty much waiting for this MQTT stuff to solidify before doing the next release.

MQTT is a messaging scheme based on some earlier IBM technology. It involves a server where various parties can 'publish' data under some name, and other parties can subscribe to that data if they know the name. This is useful for CQC in that various devices support publishing their state to an MQTT server. This driver can be set up to subscribe to that information and load the data into CQC driver fields so that you can access it within CQC.

The name under which each piece of data is published is called the 'topic', and it's in the form of a path like:


There's no standards for either the paths or the format in which the data is stored, which is pretty sub-optimal and makes things a lot more complicated for you and me than would otherwise be the case. 

The driver is uses a configuration file that you set up, which tells it what topics you want it to subscribe to, what field to store that topic data in, how to translate from the incoming MQTT data to a valid field value, and if the field is writable how to translate back the other way. It also contains connection information for the target MQTT server you want to use. Since there are no standards for the format of published data there's a fair number of options for providing the back and forth translation stuff. The configuration options are documented in the driver docs, and it's too much to repeat here. But, once you set it it up, it's done and shouldn't require much or any more fiddling about.

The MQTT server passes along incoming changes to published data pretty much immediately to subscribed clients. So it tends to have good response times. If the data is published in 'retained' mode, then the server hangs onto it and will immediately send out values when a client subscribes to it, so for that type of data the driver will get immediate information when it loads. Otherwise, it won't see anything until the next time the device publishes a new value. Typically data will be stored in retain mode, from what I've seen so far. For outgoing field writes, you can mark each field as to whether it should send the new values with the retain option or not, with sending it being the default if you don't say otherwise.

Some MQTT servers are available publicly and some you can set up locally in your local network, depending on how you feel about such things. Amazon has one, though setting it up can be tricky because of all of the certificate stuff it requires. I'm not too hip on the local options but hopefully other folks can kick in on that front.

I've considered doing an MQTT server and selling it separately as our first and only ever non-CQC specific product. Not sure if that's worth it or not though.
Dean Roddey
Explorans limites defectum
How's the latest and greatest version of this stuff doing?
Dean Roddey
Explorans limites defectum
I have not had any issues at all - its been used every day to turn on gear in the gym. I have a test unit set-up sending temperatures and have not seen any issues with it either.

I have four more plug in switches coming that will be flashed to support Tasmota and MQTT so more testing with them as well.

Trying to find and build other devices to expand its use - just cant find the time to do all the little things I want to do.

This could make Halloween for you guys so easy with little things like a Wemos D1 mini and other esp based boards. You can use CQC to automate all your Halloween decorations so easily.

I still would like to see wild cards supported as well.
Mykel Koblenz
Illawarra Smart Home
What do you mean by wild cards in this case? I added the ability to have fields respond to incoming topics based on wild card, which I thought met the basic needs in this area?
Dean Roddey
Explorans limites defectum
Oh - I must have missed that.

So we can have a field subscribing to say #/topic/+ and published data that is in topics of say CQC/Dev/topic/device1 and CQC/topic/Device2 will both update the same field. (they both match the valid subscription - I remember discussing it but I did not realize you had implemented it.)

If so I need to test that feature out to confirm it works as indicated
Mykel Koblenz
Illawarra Smart Home
They still have to subscribe to a specific topic. But there's a new 'AltInTopic' that let's you set a regular expression that will be used to determine what incoming topics can be seen by that field beyond just it's main one. If you set the alternate in topic, generally the main topic would also match that regular expression but it doesn't enforce that. So be careful you only let it see things it should be seeing.
Dean Roddey
Explorans limites defectum
I was modifying a relay last night with some additional feature and had an issue with MLineMap

I had this line <MLineMap LineNum="1" ExtractFrom="Char=:" ExtractTo="Offset=1" StripWS="Yes"> and the driver was throwing an error when trying to re-load based on teh ExtractTo value. "End" and "Char=x" both allowed the driver to load fine.

Can you check that this option works and its just not me.

I have a json payload
BlinkCount : 3

I tried a JSON mapping and got an error, but I think its me not the driver as I have another field in a seperate driver working with a JSON payload.

<JSONMap InPath="/BlinkCount">

No mapping was required as the number is to be read as a Card. I cant remember the error, but it was not working for me.

This field is a read write field, but the payload for the write is just a number (card) and then the reply payload is JSON formatted. How do I set up the field to read JSON and write text?
Mykel Koblenz
Illawarra Smart Home
You can't set up different formats for in and out. That shouldn't even be possible for a single topic since the server just reports whatever is written to the topic.

On the MLineMap map thing, I'm guessing that that's not a valid combination. What was the text of the line you were extracting from?

And always use the command line configuration validation tool to check the configuration before you reload it. It gets you the actual error info and saves you a lot of hassle.
Dean Roddey
Explorans limites defectum

Its a valid combination according to the doc
"The ExtractTo values can be:

End, which means the end of the line
Offset=x, where x is an offset from the last character.
Char=x, where x is a character. The last instance of that character is found and extraction goes up to but not including that character."

In my example, I start after the ":" and finish just before the last "}" , but it will not load and generates the error.

I may have tried to use the same topic for the read and write - I'm going from memory here so I need to double check tonight.

What bout the JSON payload above - I just want to read the number. How do I do construct the mapping for that?
Mykel Koblenz
Illawarra Smart Home
OK, the docs are wrong. The ExtractTo only supported a Count not an offset. But, it could support and offset and that would be necessary for certain things, so I'll add that as well.
Dean Roddey
Explorans limites defectum

Possibly Related Threads...
Thread Author Replies Views Last Post
  SubSonic Media Server API Support? gReatAutomation 4 308 06-16-2019, 02:45 PM
Last Post: gReatAutomation
  Does the auto-gen template system support Roku? ghurty 3 713 12-31-2018, 06:14 PM
Last Post: Dean Roddey
  What CQC compatible sound system can support 14 rooms? ghurty 14 3,232 08-05-2018, 07:18 AM
Last Post: zra
  I found NVRs that support WebRTC ghurty 3 1,138 05-25-2018, 01:07 PM
Last Post: Dean Roddey
  New Amazon Echo Support Dean Roddey 591 161,663 02-21-2018, 12:56 PM
Last Post: Dean Roddey
  Does GC-100 Driver Support Tri-Port Cable? Jnetto 18 5,924 01-29-2018, 08:16 AM
Last Post: RichardU
  Support for Bryant Evolution Connex agarden 21 9,064 10-24-2017, 05:17 PM
Last Post: jkmonroe
  Support for Honeywell Ademco Vista agarden 14 6,322 07-06-2017, 07:13 PM
Last Post: agarden
  V2 Somfy API Support? agarden 19 8,902 06-29-2017, 09:18 AM
Last Post: Dean Roddey
  Spotify Support? agarden 1 1,777 04-29-2017, 09:46 AM
Last Post: Dean Roddey

Forum Jump:

Users browsing this thread: 1 Guest(s)