0

Creating IO feeds programmatically to specific group
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Creating IO feeds programmatically to specific group

by wsquared58 on Mon Sep 23, 2019 10:08 am

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.

wsquared58
 
Posts: 150
Joined: Sun Jun 09, 2019 9:13 pm

Re: Creating IO feeds programmatically to specific group

by brubell on Mon Sep 23, 2019 10:25 am

Hi wsquared58,

Could you post the example code you're using?

brubell
 
Posts: 528
Joined: Fri Jul 17, 2015 10:33 pm

Re: Creating IO feeds programmatically to specific group

by wsquared58 on Mon Sep 23, 2019 11:20 am

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.

Code: Select all | TOGGLE FULL SIZE
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'))
 

wsquared58
 
Posts: 150
Joined: Sun Jun 09, 2019 9:13 pm

Re: Creating IO feeds programmatically to specific group

by brubell on Mon Sep 23, 2019 11:31 am

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:

Code: Select all | TOGGLE FULL SIZE
pressure_feed = aio.feeds('pressure', group='weatherstation')


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

brubell
 
Posts: 528
Joined: Fri Jul 17, 2015 10:33 pm

Re: Creating IO feeds programmatically to specific group

by wsquared58 on Mon Sep 23, 2019 12:13 pm

Code: Select all | TOGGLE FULL SIZE
pressure_feed = aio.feeds('pressure')


then becomes

Code: Select all | TOGGLE FULL SIZE
pressure_feed = aio.feeds('pressure', group='weatherstation')


Code: Select all | TOGGLE FULL SIZE
pressure_feed = aio.create_feed(Feed(name='pressure'))


then becomes??

Code: Select all | TOGGLE FULL SIZE
pressure_feed = aio.create_feed((Feed(name='pressure')), group='weatherstation')


That's my likely horrible attempt at creating a feed and parking it in the weatherstation group.

wsquared58
 
Posts: 150
Joined: Sun Jun 09, 2019 9:13 pm

Re: Creating IO feeds programmatically to specific group

by brubell on Tue Sep 24, 2019 10:22 am

I added an issue for the Python library and will patch/release this week:
https://github.com/adafruit/Adafruit_IO ... issues/104

brubell
 
Posts: 528
Joined: Fri Jul 17, 2015 10:33 pm

Re: Creating IO feeds programmatically to specific group

by wsquared58 on Tue Sep 24, 2019 11:12 am

Thank You very much.

wsquared58
 
Posts: 150
Joined: Sun Jun 09, 2019 9:13 pm

Please be positive and constructive with your questions and comments.


cron