Black Lives Matter - Action and Equality. ... Adafruit joins the Stop Hate for Profit campaign.
0

Dynamic group names
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.
Please be positive and constructive with your questions and comments.

Dynamic group names

by daemach on Tue Dec 15, 2015 9:06 pm

Here's how I got dynamic group names to work, based on the group_sensor sketch.

Code: Select all | TOGGLE FULL SIZE
...


  /****************************** Feeds ***************************************/

// Setup a group called 'weather' for publishing changes.
// Notice MQTT group CSV paths for AIO follow the form: <username>/groups/<groupname>/csv
// const char WEATHER_FEED[] PROGMEM = AIO_USERNAME "/groups/weather/csv";

char CUREOMATIC[100];
Adafruit_MQTT_Publish cureomatic = Adafruit_MQTT_Publish(&mqtt, CUREOMATIC);

/*************************** Sketch Code ************************************/


void setup() {
 
  String macAdx = WiFi.macAddress();
  macAdx.replace(":","");
  String groupName = "CureOMatic_" + String(ESP.getChipId()) + macAdx;
  String feedName = String(AIO_USERNAME) + "/groups/" + groupName + "/csv";
 
  feedName.toCharArray(CUREOMATIC, feedName.length());

....
}

daemach
 
Posts: 143
Joined: Fri Feb 13, 2009 2:07 pm

Re: Dynamic group names

by jwcooper on Thu Dec 17, 2015 11:09 pm

Thank you for sharing this code. This is surely going to help other people trying to do the same things. We'll try to get something similar into our repository as an example as well.

jwcooper
 
Posts: 677
Joined: Tue May 01, 2012 9:08 pm

Re: Dynamic group names

by daemach on Sun Dec 20, 2015 3:21 pm

I'm looking forward to seeing a more elegant solution ;) This is just a hack to get it working!

daemach
 
Posts: 143
Joined: Fri Feb 13, 2009 2:07 pm

Please be positive and constructive with your questions and comments.