0

IO Blog Post - IO+ yearly billing option, MQTT /get topics
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

IO Blog Post - IO+ yearly billing option, MQTT /get topics

by abachman on Mon Apr 23, 2018 1:24 pm

We published a new blog post at https://io.adafruit.com/blog/notebook/2018/04/22/new-io-plus-and-mqtt-features/ with some details about two recent updates to IO.

First, IO+ is now available as a $99 per year billing plan in addition to the $10 per month. You can save a few bucks if you're going to be subscribed for that long anyways. A big reason we added the option is to support the new IO+ Subscription Pass in the Adafruit store. If you'd prefer to purchase the subscription from the Adafruit shop, you can do that now. You can also purchase a subscription for someone else, which we didn't support before.

---

Second, we added a new MQTT topic to help with the last value problem (new subscriptions don't update until a new value is published) and lack of MQTT PUBLISH retain flag support on IO. The blog post goes into more detail, but the gist is this: if you subscribe to a feed topic--for example, abachman/feeds/temperature--then publish to the feed topic with "/get" added to the end--in this case, abachman/feeds/temperature/get--you'll immediately receive the last value stored on the feed over the subscription you just set up. It will work for {username}/feeds/{feed_key}, {username}/feeds/{feed_key}/json, and {username}/feeds/{feed_key}/csv topics and with "feeds" or "f", as long as you're consistent between the feed topic and feed+/get topic.

We haven't automated the feature in any way, since there may be cases where you don't want it, but we've added support to the Adafruit IO Arduino library and added `feed->get()` calls to the example sketches where it's relevant so you can see it in action. Adding support to your project is just an extra line of code for each feed you're subscribing to. Behind the scenes, the Adafruit IO library is using {username}/f/{feed_key}/csv, so the `get()` method is publishing '\0' (the null character) to {username}/f/{feed_key}/csv/get.

We're very open to feedback on this feature, so please let us know how it works for you.

abachman
 
Posts: 212
Joined: Mon Feb 01, 2010 12:48 pm

Re: IO Blog Post - IO+ yearly billing option, MQTT /get topi

by LucianR on Wed Apr 25, 2018 10:20 pm

Adam,

The new retain flag equivalent looks great. I'm looking forward to using it with one of my Feather Huzzahs.

In the meantime, I am hoping that there is a way or there will be a way soon to publish to a /f/example/get feed through a dashboard button or IFTTT applet. Either would be a watershed moment for remotely triggered IoT projects that are on deep sleep cycles to conserve battery life.

Lucian

LucianR
 
Posts: 5
Joined: Tue Mar 22, 2016 6:27 pm

Re: IO Blog Post - IO+ yearly billing option, MQTT /get topi

by abachman on Fri Apr 27, 2018 12:57 pm

Hi Lucian,


I'm curious about the interaction you're interested in. It's incredibly useful for us to hear about new use cases for IO.

The way /get works, your deep sleeping device could wake up, subscribe to {username}/f/example and publish to {username}/f/example/get to get the latest value, but your device could also call feed->lastValue() from the Adafruit_IO_Arduino library to retrieve a Data object via HTTP. In fact, any HTTP-capable lib and the "allData" endpoint with limit=1 will also work to get a most-recent value. For example, this cURL command will always return the most recent value on one of my public feeds:
Code: Select all | TOGGLE FULL SIZE
$ curl https://io.adafruit.com/api/v2/abachman/feeds/active.temperature/data?limit=1

returns:
Code: Select all | TOGGLE FULL SIZE
[{"id":"0DVS80A3FTDSZ8DKQKKJT8YME1","value":"69.80","feed_id":606108,"feed_key":"active.temperature","created_at":"2018-04-27T16:47:20Z","location":null,"lat":null,"lon":null,"ele":null,"created_epoch":1524847640,"expiration":"2018-06-26T16:47:20Z"}]


Would the dashboard button be triggering the wake cycle or forcing IO to publish the last value to the device?


- adam b.

abachman
 
Posts: 212
Joined: Mon Feb 01, 2010 12:48 pm

Re: IO Blog Post - IO+ yearly billing option, MQTT /get topi

by LucianR on Fri Apr 27, 2018 9:46 pm

Adam,

Thanks for your limitless patience! I tried the HTTP command, which is quite clear:

Code: Select all | TOGGLE FULL SIZE
https://io.adafruit.com/api/v2/LucianR/feeds/intercom-toggle/data?limit=1

which gets me

Code: Select all | TOGGLE FULL SIZE
[{"id":"0DVSG74V019X4CMDP0T992JH8G","value":"ON","feed_id":789572,"feed_key":"intercom-toggle","created_at":"2018-04-28T00:26:41Z","location":null,"lat":null,"lon":null,"ele":null,"created_epoch":1524875201,"expiration":"2018-05-28T00:26:41Z"}]

which gives me hope that it all works!

I am still having trouble following your instructions for using /get with micropython on an Feather Huzzah 8266.

I am putting together a system to remotely open a door by using my huzzah to "press" the door button on the intercom with a relay. The huzzah is battery powered and cycles in and out of deep sleep to conserve power. At the end of every cycle before it goes back into deep sleep it will publish a marker value to the feed as a time stamp. The user will activate the door by publishing an "ON" message to the intercom feed with an mqtt client, an IFTTT applet, or an IO widget. When the huzzah wakes up it will get the last value and compare it with the marker value to see if someone has left an "ON" value since the last cycle.

To put it another way:

1. wake up
2. connect to wifi network <--works
3. connect to mqtt server (IO) <--works
4. subscribe to intercom feed and get last value <--getting stuck here
5. subscribe to marker feed and get last value <--getting stuck here
6. If value is "ON", compare with last published marker value
7. If "ON" is newer than marker, fire relay
8. disconnect and deep sleep

Here is where I'm getting hung up/confused. Above you wrote:

The way /get works, your deep sleeping device could wake up, subscribe to {username}/f/example and publish to {username}/f/example/get to get the latest value


I am not getting this to give me the last value when I subscribe to the feed. I have tried every permutation I can think to do but I am missing something simple. Does one have to publish to a feed with the /get or subscribe to a feed with the /get? I even tried testing it with the HiveMQ's MQTTInspector app on iOS to test publishing and subscribing with and without the /get modified.

When you describe it, the process seems simple and I know that's how adafruit rolls so I'm chalking all of this up to my inexperience with mqtt and micropython.

I wrote a script that puts DHT22 data up on IO by way of two feeds and then goes to sleep, so I know I can do some of the basic stuff.

LucianR
 
Posts: 5
Joined: Tue Mar 22, 2016 6:27 pm

Please be positive and constructive with your questions and comments.