View Source HueSDK.Discovery behaviour (HueSDK v0.1.1)

Automatic discovery of Hue Bridge devices available on the local network.

See HueSDK.Discovery.discover/2 for examples.

Link to this section Summary

Types

A list of discovered Hue Bridge devices, tagged by the discovery strategy.

Callbacks

Attempts to discover all available Hue Bridge devices on the local network.

Functions

Attempts to discover all available Hue Bridge devices on the local network.

Link to this section Types

@type discovery_result() :: {atom(), [HueSDK.Bridge.t()]}

A list of discovered Hue Bridge devices, tagged by the discovery strategy.

Link to this section Callbacks

@callback do_discovery(keyword()) :: discovery_result()

Attempts to discover all available Hue Bridge devices on the local network.

See HueSDK.Discovery.discover/2 for more information.

Link to this section Functions

Link to this function

discover(strategy, opts \\ [])

View Source

Attempts to discover all available Hue Bridge devices on the local network.

examples

Examples

Discovering a Hue Bridge device via the discovery portal URL:

HueSDK.Discovery.discover(HueSDK.Discovery.NUPNP)

{:nupnp, [%HueSDK.Bridge{}]}

Discovering a Hue Bridge device via multicast DNS:

HueSDK.Discovery.discover(HueSDK.Discovery.MDNS)

{:mdns, [%HueSDK.Bridge{}]}

Discovering a Hue Bridge device via a manually supplied IP address :

HueSDK.Discovery.discover(HueSDK.Discovery.ManualIP, ip_address: "127.0.0.1")

{:manual_ip, [%HueSDK.Bridge{}]}

An empty list is returned if no Hue Bridge devices are found:

HueSDK.Discovery.discover(HueSDK.Discovery.ManualIP, ip_address: "000.0.0.0")

{:mdns, []}

If invalid options are given, a NimbleOptions.ValidationError is raised:

HueSDK.Discovery.discover(HueSDK.Discovery.ManualIP, invalid_opt: :invalid_opt)

** (NimbleOptions.ValidationError) unknown options [:invalid_opt], valid options are: [:ip_address, :mdns_namespace, :max_attempts, :sleep]

options

Options

  • :ip_address - The IP address of the Hue Bridge, required for manual discovery.

  • :mdns_namespace - The multicast DNS namespace to query. The default value is "_hue._tcp.local".

  • :max_attempts - How many discovery attempts are made before giving up. The default value is 10.

  • :sleep - How long to wait in miliseconds between each attempt. The default value is 5000.