neeo-sdk (master) doxdox documentation

NEEO Brain SDK. For examples see https://github.com/NEEOInc/neeo-sdk-examples.

# addQueueDirectory()

# addRootDirectory()

# Models.ButtonHandler(controller)

Do not break the SDK. This is a deprecated typo.

Parameters

Name Types Description
controller The button handler controller.

# buildBrowseList(configuration, configuration.title, configuration.totalMatchingItems, configuration.limit, configuration.offset, configuration.browseIdentifier)

Create new list factory, builds a browsable list which can be used for a specific device, for example to browse a playlist

Parameters

Name Types Description
configuration Object JSON Configuration Object
configuration.title String title of the list
configuration.totalMatchingItems Number how many results the query included in total (used for pagination)
configuration.limit Number optional, how many items should be queried per page (used for pagination). The default and maximum is 64.
configuration.offset Number optional, default starting offset (used for pagination)
configuration.browseIdentifier String optional, identifier that is passed with a browse request to identify which "path" should be browsed

Returns

ListBuilder

factory methods to build list

# buildDevice(DeviceName)

Create new device factory, builds a searchable device for the NEEO Brain

Parameters

Name Types Description
DeviceName String The device name

Returns

DeviceBuilder

factory methods to build device

# buildDeviceState(cacheTimeMs)

This function builds a new DeviceState Object which helps organise client states, cache states and reachability

Parameters

Name Types Description
cacheTimeMs integer how long should a devicestate be cached (optional, default is 2000ms)

Returns

DeviceState

a new DeviceState instance

# stopServer(configuration, configuration.brain, configuration.name)

Stops the internal REST server and unregister this adapter on the NEEO Brain

Parameters

Name Types Description
configuration Object JSON Configuration Object
configuration.brain NEEOBrain NEEOBrain object
configuration.name String device name

Returns

Promise

will be resolved when adapter is unregistered and REST server is stopped

# array(array)

This function applies the list limit and offset to a given list.

Parameters

Name Types Description
array Prepared files that might be wrong according to offset and limit

Returns

Items that can be added to the list according to the given offset and limit

# discoverOneBrain(multiInterface)

Returns a promise to the first NEEO Brain discovered on the local network.

Parameters

Name Types Description
multiInterface Boolean to allow to search for a brain on all interfaces (optional, default is false). If you have a mdns discovery service e.g. Bonjour, it must be turned off in advance.

Returns

promise

promise contains the found NEEOBrain.

# getPublicKey()

Returns the public key (or generates one if not yet generated) and returns the result in a promise.

# startServer(configuration, configuration.brain, configuration.port, configuration.name, configuration.devices)

Starts the internal REST server (based on Express.js) and register this adapter on the NEEO Brain - so the Brain can find this adapter

Parameters

Name Types Description
configuration Object JSON Configuration Object
configuration.brain NEEOBrain NEEOBrain object
configuration.port Number listening port
configuration.name String device name
configuration.devices Array all associated devices for this driver Optionally you can add baseurl to define the listening ip - handy if you have multiple IP's or running in a docker container.

Returns

Promise

will be resolved when adapter is registered and REST server is started

# addAdditionalSearchToken(token)

Parameters

Name Types Description
token string additional search keyword

Returns

DeviceBuilder

DeviceBuilder for chaining.

# addButton(configuration, configuration.name, configuration.label)

Parameters

Name Types Description
configuration Object JSON Configuration Object
configuration.name String identifier of this element
configuration.label String optional, visible label in the mobile app or on the NEEO Remote

Returns

DeviceBuilder

DeviceBuilder for chaining.

# addButtonGroup(name)

Parameters

Name Types Description
name String A button name group, see validation/buttongroup.js for valid options

Returns

DeviceBuilder

DeviceBuilder for chaining.

# addButtonHandler(controller)

Parameters

Name Types Description
controller function Callback function which will be called one of the registered button triggered from the Brain.

Returns

DeviceBuilder

DeviceBuilder for chaining.

# addCapability(capability)

Parameters

Name Types Description
capability String

Returns

object

DeviceBuilder

# addDirectory(configuration, configuration.name, configuration.label, configuration.role, controller, controller.getter, controller.action)

Parameters

Name Types Description
configuration Object JSON Configuration Object.
configuration.name String identifier of this element.
configuration.label String optional, visible label in the mobile app or on the NEEO Remote.
configuration.role String optional, specific role of the directory (supported roles are 'ROOT' or 'QUEUE')
controller Object Controller callbacks Object
controller.getter Function should return a list built by listBuilder so the App/NEEO Remote can display the browse result as a list. If the getter callback encounters an error, you can build a list with a 'ListInfoItem' to inform the user about the error
controller.action Function will be called when an item is clicked

Returns

Object

DeviceBuilder

# addQueueDirectory(configuration, controller)

Parameters

Name Types Description
configuration Object JSON Configuration Object, see addDirectory() for details.
controller Object Controller callbacks Object, see addDirectory() for details.

Returns

Object

DeviceBuilder

# addRootDirectory(configuration, controller)

Parameters

Name Types Description
configuration Object JSON Configuration Object, see addDirectory() for details.
controller Object Controller callbacks Object, see addDirectory() for details.

Returns

Object

DeviceBuilder

# defineTiming(configuration, configuration.powerOnDelayMs, configuration.sourceSwitchDelayMs, configuration.shutdownDelayMs)

Parameters

Name Types Description
configuration Object JSON Configuration Object
configuration.powerOnDelayMs Number how long does it take (in ms) until the device is powered on and is ready to accept new commands
configuration.sourceSwitchDelayMs Number how long does it take (in ms) until the device switched input and is ready to accept new commands
configuration.shutdownDelayMs Number how long does it take (in ms) until the device is powered off and is ready to accept new commands

Returns

DeviceBuilder

DeviceBuilder for chaining.

# DeviceSubscriptionHandler.Controller(controller, controller.deviceAdded, controller.deviceRemoved, controller.initializeDeviceList)

Parameters

Name Types Description
controller Object Controller callbacks Object
controller.deviceAdded Function Callback function used when a device from this SDK is added on the Brain. Can be used to start listening to updates for that device. The callback has one parameter: deviceId: string identifying the device.
controller.deviceRemoved Function Callback function used when a device from this SDK is removed from the Brain. Can be used to stop listening to updates for that device. The callback has one parameter: deviceId: string identifying the device.
controller.initializeDeviceList Function Callback function used on startup once the SDK can reach the Brain, this is called on startup with the current subscriptions removing the need to save them in the SDK. The callback has one parameter: deviceIds: Array of deviceId string for all devices of this SDK currently on the Brain.

Returns

DeviceBuilder

DeviceBuilder for chaining.

# enableDiscovery(configuration, configuration.headerText, configuration.description, configuration.enableDynamicDeviceBuilder, discoverFunction)

Parameters

Name Types Description
configuration Object A configuration object
configuration.headerText String this text will be displayed before the user starts the discovery process
configuration.description String this text will be displayed before the user starts the discovery process
configuration.enableDynamicDeviceBuilder Boolean if set to true, the discovery itself will return a devices itself (as .device attribute). This is handy if you have a Hub device which returns different devices with different capabilities. No additional capabilities on the device must be enabled. If set to false the driver returns one static device definition. (optional, default: false)
discoverFunction Function Callback function which will return the discovered devices as Array. This Array contains JSON Objects with this content: * id unique device identifier, for example mac address * name display name which is visible in the frontend * reachable true: device is reachable, false: device is not reachable (optional) * device if enableDynamicDeviceBuilder is set to true, return the dynamic disovered and build device using the ".buildDevice" function NOTE: if you set enableDynamicDeviceBuilder to true - then the NEEO Brain will query your discovery function with a specific device Id the first time this device is requested. You can either * ignore this option completly and return the discovered devices (might not be the ideal solution as potentially unused devices are build) * or build only the requested device and return that device * You can also use the .registerDeviceSubscriptionHandler function and prebuild the needed devices

Returns

DeviceBuilder

DeviceBuilder for chaining.

# FavoritesHandler.Controller(controller, controller.execute)

Parameters

Name Types Description
controller FavoritesHandler.Controller Controller callbacks Object
controller.execute Function This callback is executed when a favorite channel is triggered on the Brain The callback has two parameters: deviceId: string identifying the device. favoriteId: string identifying the favorite channel to execute

Returns

DeviceBuilder

DeviceBuilder for chaining.

# Image.Descriptor(configuration, configuration.name, configuration.label, configuration.uri, configuration.size, controller)

Parameters

Name Types Description
configuration Object JSON Configuration Object.
configuration.name String identifier of this element.
configuration.label String optional, visible label in the mobile app or on the NEEO Remote.
configuration.uri String HTTP URI pointing to an image resource. JPG and PNG images are supported.
configuration.size String image size in the ui, either 'small' or 'large'. The small image has the size of a button while the large image is a square image using full width of the client.
controller Function A function which returns the address (URL) to the current image.

Returns

Object

DeviceBuilder

# PlayerWidget.Controller(controller)

Parameters

Name Types Description
controller PlayerWidget.Controller Controller and player settings definition.

Returns

DeviceBuilder

DeviceBuilder for chaining.

# registerInitialiseFunction(controller)

Parameters

Name Types Description
controller Function Callback function which will be called when the device should be initialised.

Returns

DeviceBuilder

DeviceBuilder for chaining.

# Registration.Options(options, options.type, options.headerText, options.description, controller, controller.register, controller.isRegistered)

Parameters

Name Types Description
options object An object which contains
options.type String Defines the type of registration. The currently supported registration types are: * SECURITY_CODE * ACCOUNT
options.headerText String This header will be displayed when the user starts the register process
options.description String Text displayed during registration, should guide the user through how to find and enter the credentials needed.
controller Object Controller callbacks Object
controller.register Function Callback function which will be called when the user starts the registration. The callback has one parameter, credentials which either contains: * securityCode for the registration type of SECURITY_CODE * username, password for the registration type of ACCOUNT
controller.isRegistered Function Callback function that must resolve true if valid credentials already exists, so the user does not need to register again. Note: if you always return false, the user can provide credentials each time a new device is added.

Returns

DeviceBuilder

DeviceBuilder for chaining.

# Sensor.Descriptor(configuration, configuration.name, configuration.label, configuration.type, configuration.range, configuration.unit, controller, controller.getter)

Parameters

Name Types Description
configuration Object JSON Configuration Object
configuration.name String Identifier of this element
configuration.label String Optional, visible label in the mobile app or on the NEEO Remote
configuration.type String Type of sensor, the available types are binary, range, power (should be done using addPowerStateSensor), string, array
configuration.range Array Optional, custom range of sensor, default 0..100
configuration.unit String Optional, user readable label, default %
controller Object Controller callbacks Object
controller.getter Function A Function that returns the current sensor value

Returns

DeviceBuilder

DeviceBuilder for chaining.

# Sensor.PowerStateController(controller, controller.getter, controller.setter)

Parameters

Name Types Description
controller Object Controller callbacks Object
controller.getter Function return current value of the power sensor
controller.setter Function update current value of the power sensor

Returns

DeviceBuilder

DeviceBuilder for chaining.

# setDriverVersion(version)

Parameters

Name Types Description
version Number Integer identifying current driver version, used by NEEO Brain to detect a newer version of your device.

Returns

DeviceBuilder

DeviceBuilder for chaining.

# setIcon(icon)

Parameters

Name Types Description
icon string string identifying the icon, the following icons are currently available: 'sonos', 'neeo-brain'

Returns

DeviceBuilder

DeviceBuilder for chaining.

# setManufacturer(manufacturerName)

Parameters

Name Types Description
manufacturerName string used to find and add the device in the NEEO app.

Returns

DeviceBuilder

DeviceBuilder for chaining.

# setSpecificName(specificname)

Parameters

Name Types Description
specificname string Optional name to use when adding the device to a room (a name based on the type will be used by default, for example: 'Accessory'). Note this does not apply to devices using discovery.

Returns

DeviceBuilder

DeviceBuilder for chaining.

# setType(type)

Parameters

Name Types Description
type string supported device classes: * ACCESSORY * AUDIO * AVRECEIVER * DVB (aka. satellite receiver) * DVD (aka. disc player) * GAMECONSOLE * HDMISWITCH * LIGHT * MEDIAPLAYER * MUSICPLAYER * PROJECTOR * TUNER * TV * VOD (aka. Video-On-Demand box like Apple TV, Fire TV...) * SOUNDBAR

Returns

DeviceBuilder

DeviceBuilder for chaining.

# Slider.Descriptor(configuration, configuration.name, configuration.label, configuration.range, configuration.unit, controller, controller.getter, controller.action)

Parameters

Name Types Description
configuration Object JSON Configuration Object
configuration.name String identifier of this element
configuration.label String optional, visible label in the mobile app or on the NEEO Remote
configuration.range Array optional, custom range of slider, default 0..100
configuration.unit String optional, user readable label, default %
controller Object Controller callbacks Object
controller.getter Function return the current slider value
controller.action Function update the current slider value

Returns

DeviceBuilder

DeviceBuilder for chaining.

# Subscription.Controller(controller)

Parameters

Name Types Description
controller Function Called with the notification and optional power state callback functions: - The first argument is the component update callback updateCallback(options) - The Second argument contains optional power state callbacks: if the device supports power state (see addPowerStateSensor) 2 additional callbacks are present: - powerOnNotificationFunction, usage: powerOnNotificationFunction(deviceId) - powerOffNotificationFunction, usage: powerOffNotificationFunction(deviceId)

Returns

DeviceBuilder

DeviceBuilder for chaining.

# supportsFavorites()

Returns

Boolean

Whether favorites are supported or not for this device type.

# supportsTiming()

Returns

Boolean

Whether timing is supported or not

# Switch.Controller(configuration, configuration.name, configuration.label, controller, controller.getter, controller.setter)

Parameters

Name Types Description
configuration Object JSON Configuration Object
configuration.name String identifier of this element
configuration.label String optional, visible label in the mobile app or on the NEEO Remote
controller Object Controller callbacks Object
controller.getter Function return current value of the Switch
controller.setter Function update current value of the Switch

Returns

DeviceBuilder

DeviceBuilder for chaining.

# TextLabel.Descriptor(configuration, configuration.name, configuration.label, configuration.isLabelVisible, controller)

Parameters

Name Types Description
configuration Object JSON Configuration Object
configuration.name String identifier of this element
configuration.label String optional, visible label in the mobile app or on the NEEO Remote
configuration.isLabelVisible Boolean should the label be visible
controller Function A function which returns the content of the text label.

Returns

Object

DeviceBuilder

# addDevice(id, clientobject, reachable)

Parameters

Name Types Description
id integer a unique key to identify an entry
clientobject object any object which is linked to this unique identifier.
reachable boolean this optional parameter defines if this device is currently reachable. Defaults to true.

# getAllDevices()

Returns

Array

Returns all devices (client object, id, reachable state) this instance knows..

# getCachePromise(id)

Parameters

Name Types Description
id integer a unique key to identify an entry.

Returns

Object

A cachedPromise object, you can call the getValue function which either returns the cached state or fetches a new state.

# getClientObjectIfReachable(id)

Parameters

Name Types Description
id integer a unique key to identify an entry.

Returns

Object

The stored device state if the device is reachable OR undefined when device is NOT reachable.

# registerStateUpdate(callback)

Parameters

Name Types Description
callback function function

# updateReachable(id, reachable)

Parameters

Name Types Description
id integer a unique key to identify an entry.
reachable boolean this parameter defines if this device is online (true) or offline (false).

# addListButtons(configuration, configuration.iconName, configuration.title, configuration.actionIdentifier, configuration.inverse)

Parameters

Name Types Description
configuration Array Configuration Array
configuration.iconName String icon that will be shown on the list item entry instead of the text - available icons: 'Shuffle', 'Repeat'. Note: either iconName or title must be defined
configuration.title String title that will be shown on the list item entry. Note: either iconName or title must be defined
configuration.actionIdentifier String optional, string passed back to handling function when button is clicked
configuration.inverse Boolean optional, removes the background color of the button

Returns

ListBuilder

ListBuilder for chaining.

# addListHeader(configuration, configuration.title)

Parameters

Name Types Description
configuration Object JSON Configuration Object
configuration.title String title that will be shown on the list item entry

Returns

ListBuilder

ListBuilder for chaining.

# addListInfoItem(configuration, configuration.title, configuration.text, configuration.affirmativeButtonText, configuration.negativeButtonText, configuration.actionIdentifier)

Parameters

Name Types Description
configuration Object JSON Configuration Object
configuration.title String title that will be shown on the list item entry
configuration.text String text that will be shown in the resulting popup. This is the only text that will be shown on the NEEO remote.
configuration.affirmativeButtonText String optional, will be shown on the OK popup button
configuration.negativeButtonText String optional, will be shown on the CANCEL popup button
configuration.actionIdentifier String optional, passed back to handling function when item is clicked

Returns

ListBuilder

ListBuilder for chaining.

# addListItem(configuration, configuration.title, configuration.label, configuration.thumbnailUri, configuration.browseIdentifier, configuration.actionIdentifier, configuration.uiAction)

Parameters

Name Types Description
configuration Object JSON Configuration Object
configuration.title String title that will be shown on the list item entry
configuration.label String optional, additional label
configuration.thumbnailUri String optional, URL that points to an image that will be displayed on the list item
configuration.browseIdentifier String optional, identifier that is passed with a browse request to identify which "path" should be browsed
configuration.actionIdentifier String optional, string passed back to handling function when item is clicked
configuration.uiAction ListUIAction optional, string representing action GUI should take after item is clicked, can be any of "goToRoot" (going back to the root of the directory), "goBack" (going back one step in history), "close" (closing the modal), "reload" (reloading the current view with same browseIdentifier)

Returns

ListBuilder

ListBuilder for chaining.

# addListItems(Array)

Parameters

Name Types Description
Array Array of ListItem JSON elements

Returns

ListBuilder

ListBuilder for chaining.

# addListTiles(configuration, configuration.thumbnailUri, configuration.actionIdentifier, configuration.uiAction)

Parameters

Name Types Description
configuration Array Configuration Array
configuration.thumbnailUri String optional, URL that points to an image that will be displayed on the list item
configuration.actionIdentifier String optional, string passed back to handling function when item is clicked
configuration.uiAction ListUIAction optional, string representing action GUI should take after the tile is clicked, can be any of "goToRoot" (going back to the root of the directory), "goBack" (going back one step in history), "close" (closing the modal), "reload" (reloading the current view with same browseIdentifier)

Returns

ListBuilder

ListBuilder for chaining.

# setListTitle(name)

Parameters

Name Types Description
name String the list name

Returns

ListBuilder

ListBuilder for chaining.

# setTotalMatchingItems(totalMatchingItems)

Parameters

Name Types Description
totalMatchingItems Integer the total length of the list

Returns

ListBuilder

ListBuilder for chaining.

# getActiveRecipes(NEEOBrain)

Get all powered on recipes of a NEEO Brain

Parameters

Name Types Description
NEEOBrain Object String

Returns

Promise

promise contains an array with powerKey's of the powered on recipes.

# getRecipes(NEEOBrain)

Get all existing recipes of a NEEO Brain

Parameters

Name Types Description
NEEOBrain Object String

Returns

promise

promise contains an array of all recipes of the selected NEEO Brain.

# getRecipesPowerState(NEEOBrain)

Deprecated: For backwards compatibility only, use getActiveRecipes() instead.

Parameters

Name Types Description
NEEOBrain Object String

Returns

Promise

promise contains an array with powerKey's of the powered on recipes.