use of . and dot and groups (using circuitpython)

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
slootsky
 
Posts: 6
Joined: Sun Jun 27, 2021 4:13 pm

use of . and dot and groups (using circuitpython)

Post by slootsky »

So, I'm playing with the funhouse, sending feeds for different sensors, and I want to create a group "Test" for my test feeds to go into before deploying it to my Garage, and putting those feeds into the group "Garage"

I created a group Test and a group Garage.

I didn't create any feeds, I was going to let the circuitpython create the feeds as it pushes data.

Then in my circuitpython, I got it to push data to "test.temperature" but what it created was a feed with the name "test.temperature" and the key "test-dot-temperature" :-D

That's not too bad, and kindof understandable, but then it can't continue to push to that feed.

I get the error

Code: Select all

  File "adafruit_portalbase/network.py", line 380, in push_to_io
  File "adafruit_io/adafruit_io.py", line 682, in create_new_feed
  File "adafruit_io/adafruit_io.py", line 518, in _post
  File "adafruit_io/adafruit_io.py", line 498, in _handle_error
AdafruitIO_RequestError: Adafruit IO Error 400: ['Name must be unique within the selected group', 'Key must be unique within the selected group', 'Group feeds is invalid']
So it seems there's an inconsistency between the servercode behind
GET feeds/{0} (called from get_feed in adafruit_io/adafruit_io.py
and the server code behind
POST feeds {"name": feed_key ... } (called from create_new_feed in adafruit_io/adafruit_io.py

looks like create_new_feed replaces the . with -dot- but that same replacement isn't done when get_feed is called.


I worked around it by pre-creating my feeds in the group, and then the code behaves as expected.

User avatar
brubell
Learn User Page
 
Posts: 2010
Joined: Fri Jul 17, 2015 10:33 pm

Re: use of . and dot and groups (using circuitpython)

Post by brubell »

Hi, this looks like a bug, could you please submit this as an issue on:
https://github.com/adafruit/Adafruit_Ci ... tIO/issues

and we'll take a look

User avatar
slootsky
 
Posts: 6
Joined: Sun Jun 27, 2021 4:13 pm

Re: use of . and dot and groups (using circuitpython)

Post by slootsky »

I created the issue as you requested https://github.com/adafruit/Adafruit_Ci ... /issues/76

But I just found a similar issue using python on a Raspberry Pi

creating a group and then attempting to create a feed in that group creates the feed in the Default group with the groupname.feedname but the key is groupname-dot-feedname

Expected behaviour would be for the feed to be created in the group.

Code: Select all

import time,random
from secrets import secrets
random.seed(time.time()*256)

aio = Adafruit_IO.Client(secrets['aio_username'], secrets['aio_key'])

groupName='g'+str(int(random.random()*100000))
feedName='f'+str(int(random.random()*100000))
try:
    g=Adafruit_IO.Group(name=groupName)
    aio.create_group(g)

    f=Adafruit_IO.Feed(name=groupName+'.'+feedName)
    aio.create_feed(f)
except Adafruit_IO.AdafruitIOError as e:
    print(f"AdafruitIOError: {str(e)}")

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”