Is there a tutorial on how to make feeds go to a specific group vs "default?
I used a tutorial created by BRubell to make and send data to IO and it works fine except that I want to target the feeds to a particular group. Whenever I run the program the feeds get created but they get targeted to what is the default group, named default.
Creating IO feeds programmatically to specific group
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.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
- wsquared58
- Posts: 229
- Joined: Sun Jun 09, 2019 9:13 pm
- brubell
- Learn User Page
- Posts: 2010
- Joined: Fri Jul 17, 2015 10:33 pm
Re: Creating IO feeds programmatically to specific group
Hi wsquared58,
Could you post the example code you're using?
Could you post the example code you're using?
- wsquared58
- Posts: 229
- Joined: Sun Jun 09, 2019 9:13 pm
Re: Creating IO feeds programmatically to specific group
It is this, from your "Build an environmental Monitor for Feather or Raspberry Pi. I'm in middle of redoing some stuff but this is what I will base it off of. I've run it seeral times even creating a group called "Weather" but every time I run the code it creates the feeds under "default".
I assume I need to explicitly tell it what group but I have not seen anything that addresses that. Since this is my first project it is somewhat moot but if I do other things with sensors that are unrelated I would put them in a different group. I see a group as akin to a folder and the feeds as files in that folder.
Also, don't worry about the sensors as in your code. I'm changing some of them and adding some others so that is different but I understand the creation part, just not the targeting to a specific group idea.
I assume I need to explicitly tell it what group but I have not seen anything that addresses that. Since this is my first project it is somewhat moot but if I do other things with sensors that are unrelated I would put them in a different group. I see a group as akin to a folder and the feeds as files in that folder.
Also, don't worry about the sensors as in your code. I'm changing some of them and adding some others so that is different but I understand the creation part, just not the targeting to a specific group idea.
Code: Select all
try: # if we already have the feeds, assign them.
tvoc_feed = aio.feeds('tvoc')
eCO2_feed = aio.feeds('eco2')
uv_feed = aio.feeds('uv')
temperature_feed = aio.feeds('temperature')
humidity_feed = aio.feeds('humidity')
pressure_feed = aio.feeds('pressure')
altitude_feed = aio.feeds('altitude')
except RequestError: # if we don't, create and assign them.
tvoc_feed = aio.create_feed(Feed(name='tvoc'))
eCO2_feed = aio.create_feed(Feed(name='eco2'))
uv_feed = aio.create_feed(Feed(name='uv'))
temperature_feed = aio.create_feed(Feed(name='temperature'))
humidity_feed = aio.create_feed(Feed(name='humidity'))
pressure_feed = aio.create_feed(Feed(name='pressure'))
altitude_feed = aio.create_feed(Feed(name='altitude'))
- brubell
- Learn User Page
- Posts: 2010
- Joined: Fri Jul 17, 2015 10:33 pm
Re: Creating IO feeds programmatically to specific group
Instead of using create_feed, there's some group functionality in Adafruit IO Python's HTTP Client:
https://github.com/adafruit/Adafruit_IO ... nt.py#L290
However, there's a chance that the `.feeds.` method may need to be modified to take in a group so a call would be something like:
I use the above method call in Adafruit IO CircuitPython which was developed after Adafruit IO Python - AIO Python may not have the updated methods.
If you're interested in adding (or I can add) this type of feature - please file an issue for a feature here: https://github.com/adafruit/Adafruit_IO_Python/issues
https://github.com/adafruit/Adafruit_IO ... nt.py#L290
However, there's a chance that the `.feeds.` method may need to be modified to take in a group so a call would be something like:
Code: Select all
pressure_feed = aio.feeds('pressure', group='weatherstation')
If you're interested in adding (or I can add) this type of feature - please file an issue for a feature here: https://github.com/adafruit/Adafruit_IO_Python/issues
- wsquared58
- Posts: 229
- Joined: Sun Jun 09, 2019 9:13 pm
Re: Creating IO feeds programmatically to specific group
Code: Select all
pressure_feed = aio.feeds('pressure')
then becomes
Code: Select all
pressure_feed = aio.feeds('pressure', group='weatherstation')
Code: Select all
pressure_feed = aio.create_feed(Feed(name='pressure'))
Code: Select all
pressure_feed = aio.create_feed((Feed(name='pressure')), group='weatherstation')
- brubell
- Learn User Page
- Posts: 2010
- Joined: Fri Jul 17, 2015 10:33 pm
Re: Creating IO feeds programmatically to specific group
I added an issue for the Python library and will patch/release this week:
https://github.com/adafruit/Adafruit_IO ... issues/104
https://github.com/adafruit/Adafruit_IO ... issues/104
- wsquared58
- Posts: 229
- Joined: Sun Jun 09, 2019 9:13 pm
Re: Creating IO feeds programmatically to specific group
Thank You very much.
- brubell
- Learn User Page
- Posts: 2010
- Joined: Fri Jul 17, 2015 10:33 pm
Re: Creating IO feeds programmatically to specific group
This issue has been fixed on https://github.com/adafruit/Adafruit_IO_Python/pull/125
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.