Plugin "HasSubscribers" Function

In the 3.9.0 release a new HasSubscribers function was added to the Device object allowing you to check if it is actively being used on the current page. This means that any Plugins polling HTTP REST APIs can perform conditional checks to see if it needs to send requests.

The function accepts an optional Attribute argument in case there is a specific attribute you are targeting. By not providing an argument, it’ll check to see if any attributes are referenced.

Attached is a simple example. Toggle between the “Home” & “Test” tabs & watch the Log window.
HasSubscribers.hrp (96.2 KB)

var device = plugin.Devices["0"];
if (device.HasSubscribers()) {
else {

This is pretty cool! Out of curiosity, would it be possible to provide a list of Attributes and if any of them are subscribed, it returns true? I was going to integrate this into my Roku plugin and, as I was thinking it through, I realized that some pages might only wanted to access “MediaCommands”, others might want “InputSource” and/or "“TvChannel”, just as an example.

Perhaps in the future. For now you’d have to split those into separate calls & do something like this:

if (device.HasSubscribers("InputSource")) {
    console.log("poll for input");

if (device.HasSubscribers("TvChannel.Name") || device.HasSubscribers("TvChannel.Number")) {
    console.log("poll for TV channel");

Hi Bill,

I would like to use this feature, however my device is on a specific grid ( hidden when not in use) on a single page, can I use this somehow - the other way I was think was an if statement I’d the grid was visible but not quite worked that out yet.



It might work for that scenario, it might not. I’m not 100% certain. I’d say go ahead & try it. You may end up having to create your own internal logic in the plugin or come up with a different type of layout.