Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MQTT support discussion
#11
So I decided today that I was just being way too overly-elaborate. Then I was looking at the docs about some issues wrt to overlapping of msgs and such. And my whole completely async thing was just way more machines than was needed. So I cut it down to a much simpler, more synchronous sort of deal. And, in any eventual move towards a server, it would insure that things happen in the required order.

So it can really be done basically in the style of device drivers that have to deal with async replies, and just have a 'wait reply' that processes asyncs (really just publish messages) while waiting for other things. And even there, it would really only be when waiting for a publish ack msg since that's the only 'send and wait for reply' type scenario that happens after you get through the startup stuff. Well, during the subscribe phase it can start sending stuff for the things you've already successfully subscribed to.

But, basically a much simpler scheme and it should work perfectly fine.
Dean Roddey
Explorans limites defectum
Reply
#12
Finally, some actual MQTT action. I feel like I've been taking stupid pills or something because I've screwed up this stuff so many different ways. I've been on a hardcore diet, maybe I'm starving my brain too much. But, anyhoo, the simple scheme mentioned above is working well and is an order of magnitude easier to understand. I just got the real service guy to the point where he's coming up, parsing the config, connecting and successfully registering the topics. So he's ready to accept data.

So now it's on to processing publish msgs and getting the new values stored away. Then I can start working on the driver to talk to this guy. Not sure how I'm going to talk to it. I'll probably just treat it like a device and use a raw socket connection, which will be best since this guy needs to send async change reports to the driver, for quick response for stuff like motion sensors.
Dean Roddey
Explorans limites defectum
Reply
#13
Thats all good news Dean

What you are seeing is one of the reason I originally indicated that you should be involved in the implementation of MQTT into CQC - I could see that it was so open in how it could be implemented and my gut told me it was not really possible as a basic driver.

The other reason is that I can't code something that complex.

Following with interest
Mykel Koblenz
Illawarra Smart Home
Reply
#14
Here is an updated sample config. This one includes the descriptive info about the payload data, i.e. the value being reported and how to interpret it.


Code:
<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE MQTTCfg PUBLIC "urn:charmedquark.com:CQC-MQTTCfg.DTD" "CQCMQTTCfg.DTD">
<MQTTCfg Version="1" MQTTPort="1883" MQTTAddr="test.mosquitto.org">

    <Fields>
        <BoolSwitch Topic="CQCMQTTTest/Power1" BaseName="FanPower" Access="RW">
            <PLFmt PLType="Text" FalseVal="off" TrueVal="on"/>
        </BoolSwitch>

        <Dimmer Topic="CQCMQTTTest/Light2" BaseName="KitchenTable" Access="RW"
                MinVal="0" MaxVal="100">
            <PLFmt PLType="Card" PLBytes="2" PLEndian="Big"/>
        </Dimmer>

        <TempSensor Topic="CQCMQTTTest/Temp1" BaseName="LRTemp" Type="Int"
                    MinVal="-10" MaxVal="48">
            <PLFmt PLType="Text"/>
        </TempSensor>

        <TempSensor Topic="CQCMQTTTest/Temp2" BaseName="KitchenTemp" Type="Float"
                    MinVal="30" MaxVal="115">
            <PLFmt PLType="Text" Precision="1"/>
        </TempSensor>
    </Fields>
</MQTTCfg>


- The first one is a boolean switch, read/write. The payload format is text, and the values to expect are off and on. If it were a binary number, it would be assumed that 0 is off and non-zero is on.

- The second is a dimmer and the value is a binary cardinal value, 2 bytes, and it's big endian. The min/max values and R/W access would make it V2 compatible.
- The third is a temp sensor that has an integer value. The payload is text, so it would be assumed to be just the formatted out number.
- The fourth is another temp sensor, this one a float type. It is text as well, and has a precision of 1, which means it's assumed to be text in the form 509, so 50.9 because there's 1 digit of precision. It could also of course just be formatted out as 50.9, in which case the precision value isn't used (and would default appropriately to zero.)


These are fairly simple interpretation criteria but hopefully useful for a lot of stuff. We can add more complex ones as they prove necessary.
Dean Roddey
Explorans limites defectum
Reply
#15
So if we have say 50 fields to create, how do we do it efficiently?

I work a lot with OPC, OSI Pi and other HMI's that all support excel and pretty much use delimited files as an option to mass data import/export.

Your xml file looks like every field would need to be entered in manually and excludes the use of tools like excel.

My request is that you give thought to config file manipulation as well. If excel can do a table to xml translation then I am happy with that.
Mykel Koblenz
Illawarra Smart Home
Reply
#16
Everything in there is necessary. I can't see how to make it any easier. It's going to require some thought to set up. This initial stuff is more oriented towards individual sensors. Later, I can add maybe device classes, and then after that devices. But, we'd still need the means to do simple, individual sensors, or devices that just serve up individual sensors.

For actual device classes or devices, to the extent that anything out there in MQTT land is actually capable of supporting any of our device classes, then it would more tend to know what to look for, so there would be less detail provided.

I don't necessarily want to get into the business of parsing other people's files, which would never have all of the required info anyway. You'll like have to provide the CQC specific stuff required to set up the right fields.
Dean Roddey
Explorans limites defectum
Reply
#17
(02-14-2019, 05:26 PM)Dean Roddey Wrote: Everything in there is necessary. I can't see how to make it any easier. It's going to require some thought to set up. This initial stuff is more oriented towards individual sensors. Later, I can add maybe device classes, and then after that devices. But, we'd still need the means to do simple, individual sensors, or devices that just serve up individual sensors.

For actual device classes or devices, to the extent that anything out there in MQTT land is actually capable of supporting any of our device classes, then it would more tend to know what to look for, so there would be less detail provided.

I don't necessarily want to get into the business of parsing other people's files, which would never have all of the required info anyway. You'll like have to provide the CQC specific stuff required to set up the right fields.

I dont want you to parse anyone else's files - I was just indicating that it is going to be a PITA to write that xml file when there are say 50+ devices to add to it.

Excel allows you to quickly create configurations and that's where a CSV file has its strengths.  Not saying any data should be removed, just asking to consider the format of the file.
Mykel Koblenz
Illawarra Smart Home
Reply
#18
I need something that's a strictly defined format, which CSV isn't. For stuff this detailed and the various variations, a bunch of undifferentiated values in lines would be a huge mess. It will be some effort to initially get set up, but once you do it should be solid because the format is very well defined.

Ultimately there's going to be a configuration tab anyway, once the format is well worked out and tested by people in the field. So in the long run you won't deal with this file directly anyway.

In the short term, I'm providing a little command line configuration file checker program that will find errors for you. So you can make sure the file is solid and correct before you commit to using it. It won't require trying it, seeing what shows up in the logs, editing it, making it reload, rinse and repeat.
Dean Roddey
Explorans limites defectum
Reply
#19
Anyhoo, I banged through the bulk of the 'how to deal with incoming values and decode the data' and all that today. I was just testing it and the test server went offline for a bit. It's back now, but I'm too fried to do more. I'll pick it back up tomorrow.

I'm guessing that tomorrow I'll get it to the point where I need to start working out the connection between it and the driver, and testing that a bit with the little test program. Once that seems to be working, I can start on the driver itself. I don't think the driver will be very complicated at all.
Dean Roddey
Explorans limites defectum
Reply
#20
Oh I'm really excited about this, I just ordered some parts to put together a MySensors gateway and a bunch of sensors.  I already planned on publishing everything out to my MQTT instance so this should easily allow me to get it right into CQC almost effortlessly!  I was struggling with a good way of getting all the sensor data into CQC and now this will also take care of that and so much more!
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Official 5.4 Beta Discussion Thread Dean Roddey 334 22,612 02-15-2019, 03:20 PM
Last Post: Dean Roddey
  Official 5.3 Beta Discussion Thread Dean Roddey 815 119,217 07-05-2018, 12:44 PM
Last Post: Dean Roddey
  Official 5.2 Beta Discussion Thread Dean Roddey 244 77,406 10-14-2017, 07:57 PM
Last Post: Dean Roddey
  Official 5.1 Beta Discussion Thread Dean Roddey 453 176,218 05-16-2017, 03:45 PM
Last Post: Dean Roddey
  Official 4.7 Beta discussion thread Dean Roddey 295 77,221 04-23-2015, 04:19 PM
Last Post: Dean Roddey
  4.4 Beta Discussion Thread Dean Roddey 327 75,955 10-06-2013, 12:46 PM
Last Post: Dean Roddey
  4.3 Beta Discussion Thread Dean Roddey 386 83,711 04-24-2013, 04:37 PM
Last Post: Dean Roddey
  4.2 Beta Discussion Thread Dean Roddey 216 46,870 08-01-2012, 12:44 PM
Last Post: Dean Roddey
  Official 4.0 Beta Discussion Thread Dean Roddey 573 124,612 09-01-2011, 11:35 AM
Last Post: Dean Roddey
  XBMC discussion Dean Roddey 19 9,357 03-13-2011, 02:51 PM
Last Post: wuench

Forum Jump:


Users browsing this thread: 1 Guest(s)