Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group data is never cleared #122

Open
phord opened this issue Jun 5, 2020 · 0 comments
Open

Group data is never cleared #122

phord opened this issue Jun 5, 2020 · 0 comments

Comments

@phord
Copy link
Contributor

phord commented Jun 5, 2020

I have some code like this where I have a single AdafruitIO_Group object that I use to interact with a feed group.

AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
AdafruitIO_Group *grp = io.group("mygroup");

void setup() {
  grp->onMessage(handleMessage);
  grp->set("FOREVER", "never-comes");
  grp->save();
}

void loop() {
  if (something_happened) {
      grp->set("Temperature", get_temp());
      grp->save();
  }
}

void handleMessage(AdafruitIO_Data *data) { }

Every time I call grp->save(), I find that the AdafruitIO_Data object has all the different feeds in it that it has ever touched, and they all get sent to IO again. It seems like it also has the data received and sent to handleMessage(). Sometimes the data is duplicated, like this:

FOREVER = never-comes
Temperature = 72
forever = never-comes
temperature = 71

One problem is that I don't want to publish every value that I've already sent before when I save. Another is that there are duplicated feeds here. It's not clear to me what will be "saved" when I publish a feed with both "Temperature=72" and (keyname) "temperature=71" in the data collection.

It's important to me that I don't Publish old values that might now be stale. This scenario would create a race between my Published updates and the dashboard updates I could receive, but it doesn't give me any clear option to avoid this race.

I can work around this by creating a new Group object every time I want to publish, but it wasn't clear to me that this was required from the docs, and this behavior is unexpected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant