Need input on using PubSub without subscribing to tons of topics

Over the weekend I have built a little device management frontend in Phoenix with LiveView and live updating the frontend would be amazing!

However, I am not sure how to use PubSub properly for the following views:

  1. Group list: all devices are part of a device group. This view lists the groups and how many devices in this group are online/offline.
  2. Group details + device details: Lists all devices of one group (online/offline status and name) with one device being in focus of which more details are listed.

A device going online or offline should change both views and I wonder what a smart way to use PubSub in this case is.

My first thought was:

  1. subscribe to all groups on the group overview (might be hundreds tho, is that a problem?)
  2. subscribe to a single group and a single device on the details view (fine I think).

There is probably a smarter approach than subscribing to all groups on the group overview?

I suggest you look here for either some inspiration on how to mimic or just outright use parts of it:
https://hexdocs.pm/phoenix/Phoenix.Presence.html

Phoenix.Presence has a lot of great oppionated ways to solve exactly waht you ask for in nr 1.
As for nr 2 I would probably just solve that with a separate presence topic that gives higher detail and subscribe to that specific device on demand.