Device Discovery

An important capability of Hobson is that of device discovery. Whenever possible, plugins should automatically detect smart devices to eliminate (or at least minimize) manual user configuration.

To support this, Hobson has a special manager – the DiscoManager – and an associated DeviceAdvertisement class. The relationship is as follows:

Plugins can provide a DeviceAdvertisement object to the DiscoManager which will, in turn, publish it as a DeviceAdvertisementEvent. Other plugins can indicate interest in receiving DeviceAdvertisementEvents (by returning a protocol-specific topic name from the getEventTopics() method – see EventTopics.createDiscoTopic()). There is also a mechanism for plugins to request all device advertisements that occurred before the plugin became active. This decoupling is useful because often plugins that know how to generate DeviceAdvertisement objects are not the same plugins that can make use of them.

A DeviceAdvertisement, among other things, has both a protocolId and rawData:

The protocolId attribute indicates the channel from which the device advertisement originated. This might be a network protocol, local hardware, etc. The rawData attribute is the advertisement data in its raw form. The object property is the device advertisement data in a more useful, structured form if applicable.

An example will help illustrate the concept.

Many devices broadcast their availability as SSDP services. The knowledge of which SSDP services are useful is likely distributed across multiple Hub plugins – for example, a Sonos plugin would only care about Sonos-related services while a Roku plugin would only care about Roku ones. However, it would be inefficient (and possibly cause network congestion) for each plugin to send out its own SSDP discovery packets. It is better for a single "gatekeeper" to be in charge of sending/receiving SSDP service information and pass it along to objects that know how to analyze it. In this example, an SSDP plugin would create DeviceAdvertisement objects (with a protocolId of "ssdp") and provide them to the DiscoManager. Plugins that care about SSDP advertisements would listen for DeviceAdvertisementEvents that contain SSDP DeviceAdvertisement objects.