Issue with PurpleAir Group – Sensors Disappeared After API Call

Hi everyone,

I’m facing an issue with a sensor group I’ve been maintaining for years. The group used to contain over 300 sensors, and everything was working fine until today.

This morning, I used the POST /v1/groups/{group_id}/members endpoint to add 10–15 more sensors using a script like this: (this is a script that i have used many times in the pas with no problem!)

params = {"sensor_index": sensor}
urll = f"https://api.purpleair.com/v1/groups/{group_id}/members"
rr = requests.post(urll, params=params, headers=headers_Post)

After that request:

  • The group immediately stopped showing any of the original sensors.
  • The /v1/groups/mygroupid API call returns an empty [] for members.
  • Our database now only receives data from the newly added sensors.
  • Trying to re-add the full set of sensors mostly fails — many return an error saying they already exist in the group, even though they’re not listed when querying group members.

To troubleshoot, I created a new group (ID: xx) and tried to populate it from scratch, but only ~10 sensors appear as members, even after repeated API calls.

This feels like some kind of data corruption or bug in the group system. Has anyone encountered this before? Is there a fix or workaround?

Any help or insights would be appreciated.

2 Likes

Hi @Charalampos_Chatzidi,

We’ve responded to the email request that you sent and will be investigating the issue.

We are also encountering the same issue. One group with several sensors established for years, tried adding a new sensor today, all previous sensors are missing. We did a new group and it only retained the most recently added sensor.

@Charalampos_Chatzidi @ltravis We’ve resolved the issue, and group queries will now return all members as expected. We’ve already relayed some of the details via email, but I’m including them here as well in case others were affected (some jargon is included).

Technical Details

The issue stemmed from how group data was cached after updates. In most cases, adding a new group member caused queries to return only that new member. If multiple members were added in quick succession, the query might return multiple members, though still not the full group.

This also meant that a newly created API instance would return the correct group members until an update occurred, which triggered the caching bug.

Importantly, the full group data remained intact in the database. No group members were ever lost or deleted.

As an often quoted and modified saying goes, there are only two hard things in Computer Science: cache invalidation, naming things, and off-by-one errors.

2 Likes