adafruitio_12_group_sub: get() not yielding retained values

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Locked
User avatar
jpasqua
 
Posts: 7
Joined: Thu Aug 20, 2020 8:35 pm

adafruitio_12_group_sub: get() not yielding retained values

Post by jpasqua »

In example 12 it subscribes to updates for to a couple of feeds in a group. It then performs the following:

Code: Select all

  // force IO to update our MQTT subscription with the current values of all feeds
  group->get();
When I run this on a Wemos D1 Mini (ESP8266) with the most recent version of the AdafruitIO library I do not get callbacks for the retained values. I do get callbacks for any updates I make after that.

Does this example work for others? I see other places that seem to confirm that a call to group->get() should result in data callbacks for each contained feed.

User avatar
jpasqua
 
Posts: 7
Joined: Thu Aug 20, 2020 8:35 pm

Re: adafruitio_12_group_sub: get() not yielding retained values

Post by jpasqua »

Sorry to reply to my own post, but I don't see a way to edit it to provide more information.

The curl command below works fine to manually get the last value on a feed within a group. In this example the group is "office-weather-station" and the feed within the group is "temp".

Code: Select all

curl -H "X-AIO-Key: KEY" https://io.adafruit.com/api/v2/USER/feeds/office-weather-station.temp/data/previous
As a last resort I can manually loop through the feeds in the group and use the HTTP api directly to get the data, but using group->get() and existing callbacks would be much simpler/cleaner.

User avatar
jpasqua
 
Posts: 7
Joined: Thu Aug 20, 2020 8:35 pm

Re: adafruitio_12_group_sub: get() not yielding retained values

Post by jpasqua »

I'm documenting my findings for others who may run across this.

When you do a group.get(), the feed names returned are fully qualified; e.g. my-group.my-feed
When a "normal" update on a feed occurs, even a feed in a group, the feed name is unqualified; e.g. my-feed

If you do an onMessage() such as:

Code: Select all

group->onMessage("my-feed", cb);
The callback will be invoked for normal feed updates, but not as the result of a group->get() since the feed name returned (my-group.my-feed) does not match the feed name you supplied (my-feed).

This can be avoided by using the variant of onMessage that doesn't take a feed name, OR by performing two calls to onMessage; one with the unqualified feed name and one with the qualified feed name.

Doing this allows me to see the results of a group->get() call, but I'm still not seeing all the values in the group. I think that is a separate issue.

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”