Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - bdevlin

Pages: [1] 2 3
Ya it's a pain, but I learned a lot re-architecting for MQTT with Python and Postgres SQL. It was worth it for sure, as it's now mostly in my own sandbox. I struggled to IFTTT working again, then finally gave up. A month later in my spare time I was able to produce a far more stable workflow. As  long as the gateway works, that is.

I do not believe the problem occurs with ethernet, however, my topology required that the MC-110 be place near my back yard wall and there is no ethernet there, hence my preference that the WiFi functions correctly.

Based on my logs, I am 99% sure that there is no "wifi test then re-connect" code implemented in the gateway mc-110. I can duplicate the problem by resetting my router, the mc-110 gateway simply will not reconnect via wifi until I hit the reset button on the mc-110. This behavior occurred with the previous firmware, but not as often.

I think maybe you could look at that snippet of firmware code and do some re-connect tests. The simplest thing would be to put it in an intermittent reset state loop if connection is lost, until it can re-establish one. However, that would just fix my problem and perhaps cause problem for others with different use cases.


The middle LED continues to blink like it's connected to my router.

I upgraded the latest gw110app firmware and I am now experiencing max 24-48 hours responsiveness before it crashes. I downgraded to the prior version and the problem persisted, so I upgraded again and I still have the same problem. Logging to usb would be helpful for us to get you debug info. My gateway is now totally unstable and I have no idea how to fix it. I have uses .5/1/2 amp power supplies with no apparent difference regarding this issue. Please advise.

Every column that is solid red indicates when the gateway stops relaying mqtt from all of my devices. It is then also unresponsive (not even visible) in mc-Studio.

[ Guests cannot view attachments ]

mc-Gateway / beacondata API
« on: November 06, 2017, 12:48:17 pm »
Is there an api for reading the beacondata directly from the gateway? My thought is if the beacondata is extremely low power, I can extend battery life on modules by using beacondata instead of Lplan.Publish. Clearly an API exists as mc-Studio can read beacons. How do you plan to expose this API to us? I prefer python. Or what if we could program the gateway to publish beacondata to an mqtt server?


MQTT / Re: Sending Beacon Data Over MQTT
« on: October 23, 2017, 08:31:34 pm »
Here's a snippet of code that works. I use it for versioning the MC-110/120 modules. This way I can see in the ide which ones have the latest code.

Class mqtt_json
    Shared version As Float
    Shared Event Boot()
        '############ This is your mcMod software version. You can see the version in the first byte of beacon data in Device maintenence and Connections under the ->Tools->Devices menu.
        version = 2
        '############ Add the version to the first byte of beacon data.
        Dim beacondata As ListOfByte = New ListOfByte()
        '### Write out boot acknowledgement for debugging. Not required for the beacon, but picked up in an MQTT subscription
        Dim id As String = Device.mcUID().ToString("x8")
        Lplan.Publish("mqtt/boot", ("{Boot:" + id + ",Version:" + version.ToString+ "}").ToListOfByte, QoS.AtLeastOnce)       
    End Event

Yes, the upgrade completely broke my IFTTT integration. I am just finalizing my switch over to MQTT. A lot of work but also learned a lot.

Old solution:
IFTTT messages from my-mods logged to google sheets. Google sheets then act as database for data visualization.

Pros: Simple and sweet.
Cons: Not very flexible within scope of IFTTT and Google. Prone to hiccups on 3rd party cloud side of solution (i.e.
IFTT would just stop receiving messages for hours, code updates seemed to tweak the column output to google sheets. 1000 row limit per sheet, so visualizations require append/union of sheets, and additional parsing for column discrepancies.)

New Solution:
MQTT JSON data published from Mc-mods. Python ( using paho and Postgres library ) script on Raspberry pi subscribes and parses JSON into a Postgres DB (also on pi) insert statement. Postgres is now DB for visualization.

Pros: more robust. Can point to a different Postgres host any time. Python allows for post-processing of data and data augmentation. Python gives much more control and allows for pretty much anything else I can imagine to do with it.

Cons: needed to learn python (and paho, Postgres libs, lots of samples out there, but googled answers frequently), more complex, but I am in control. does not seem to capture on boot prior to first publish, so first boot record is bad device date data (year 2000). Something strange with needing to connect via gateway first. Tried some boot event code with limited success. I now capture 3 dates in Postgres, device.datetime, python sub receive datetime and Postgres auto datetime for record write.

Both solutions capture and log the . I use a lookup table to join the ID for the location the sensor is located. I need to add valid-from and valid-to date fields to the lookup so I can swap out devices and still get proper historicals.

I consider my solution a beta 2. I'll post on github once I hit beta 3 or 4 if anyone is interested.


mc-Module / Re: Time fails to sync
« on: July 24, 2017, 05:49:20 pm »
See my comments near the end of this thread. I am still struggling a bit with the same issue, but I have been experimenting with the While loop I posted with mixed success.


mc-Studio / Re: Timestamps
« on: July 17, 2017, 01:35:04 pm »
So that would be this in uSeconds?

        While DateTime.Now().Year= 2000
        End While

mc-Studio / Re: Timestamps
« on: July 12, 2017, 02:53:17 pm »
I can get data from DateTime.Now() but The data transmitted via publish in the first module boot is "2000-01-01T00:00:00+00:00", then the second and subsequent publish the time nearly correctly, however it's off by an hour (-8:00N is my time zone). I can't figure out how to force the module to fetch the time fist in the boot() event successfully first.

This seems to work ok, any problems with this method?

    Shared Event Boot()
        While DateTime.Now().Year= 2000
        End While
    End Event

I believe I have discovered the gateway110 problem.

I have my OpenWRT router configured to reset at 6am every morning. The previous Gateway110 firmwares would simply reconnect after the router reset, however, the latest firmware does not seem able to rediscover my network after a disconnect (during the reset). I removed the reset from my router and the gateway is relaying fine for over 24 hours now. However, I think the gateway should have the ability to rediscover the network after a lost connection without have to hit the reset button (as it worked in prior firmware).


mc-Studio / Re: Timestamps
« on: July 09, 2017, 01:08:19 pm »
I can't seem to get until the second request from a module. It kinda makes sense I guess, but that means the modules first response is bad data.

The crashes seemed to have calmed down a little. As far as the error text, that's not possible because it literally just closes the app with no error report.

A have managed to get the gateway to receive MQTT pubs from the mods (four 110's and one 120). But success is still down at one in ten. I disconnect the gateway, close the connection screen, open it back up and cross my fingers. One in three times if I connect to one, then I maybe connect to a second.

My gateway120 on the new firmware does not seem to want to receive MQTT messages from the modules for a full 24 hours. It basically works for a while, then stops relaying until I reset the unit. When I hit the reset button, it relays again, so the modules work fine. You may not have the space in the gateway memory, but it would be good if you could write a basic routine (in the next firmware) that logs activity to a USB stick in the port. I would happily send the data to your team.

So for now:
   mcStudio is still unstable but functional in the mcScript editor. Crashes are just a shutdown most of the time. Try alternate click paths, you probably all use the perfect click paths when you are testing, put it in front of your kids and significant others. You'll find the problems fast. (HINT: don't tell them where to click!)
   mcStudio/gateway is now worse at discovering mcMods. Gateway discovery is fast. Mod discovery is rare and unpredictable. Same, Kids and SO's for testing, there are still many problems here.
   Gateway110 appears to be crashing inside 24 hours and failing to relay MQTT pubs without a restart. No debug options. I will monitor and advise while I build out my IFTTT replacement. This is a huge issue for me, and I am not even a commercial client, just a hacker geek for personal amusement. The gateway must not crash!

MQTT / Re: Setting up MQTT on pi and gateway
« on: July 08, 2017, 01:55:29 pm »
I'm using a pi to rebuild my temp capture platform, IFTTT just plain quit after the mc upgrades. Other than my issues posted elsewhere here, I am sending 'JSON" equivalent 'ListOfByte' successfully to my pi.

My plan is to use python libraries to captures the subscriptions and push them into PostgreSQL. It's all on my pi with a 128GB SSD. You might consider a middleman to push the data directly to a cloud hosted DB VS a cloud MQTT host and then to a DB.

mc-Studio / Variables for shared event timing
« on: July 08, 2017, 12:28:21 pm »
Looking to do something like this. Possible?

Class mqtt_json
    Shared interval As Byte = 5
    Shared span As String = "Minutes"
    Shared Event json_payload_mqtt() RaiseEvent Every interval span
            Do Stuff
End Event
End Class

Pages: [1] 2 3