// Type definitions for node-hue-api 2.3.0
// Project: https://github.com/peter-murray/node-hue-api
// Definitions by: wind-rider , Frederic Morel
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///
//Not documented because it says it's broken
//export function connect(config) : HueApi;
//TODO: document lightState, scheduledEvent, scene, timer
//export lightState: lightState,
//export scheduledEvent: scheduledEvent,
//export scene: scene,
//export timer: timer,
/**
* Will locate the Philips Hue Devices on the network. Depending upon the speed and size of the network the timeout
* may need to be adjusted to locate the Hue Bridge.
*
* @param timeout The maximum time to wait for Hue Devices to be located. If not specified will use the default of 5 seconds.
* @return A promise that will resolve the Hue Bridges as an Array of {"id": {String}, "ipaddress": {String}} objects.
*/
export function upnpSearch(timeout: number): IUpnpSearchResultItem[];
//Not documented because it's deprecated
//export function searchForBridges(timeout: number): IUpnpSearchResultItem[];
/**
* Uses the http://www.meethue.com/api/nupnp call to search for any bridges locally on the network. This lookup can be
* significantly faster than issuing search requests in the {locateBridges} function.
*
* @param cb An option callback function that will be informed of results.
* @returns {Q.promise} A promise that will resolve the addresses of the bridges, or {null} if a callback was provided.
*/
export function nupnpSearch(): Promise;
//Not documented because it's deprecated
//export function locateBridges(): Promise;
/* An Error Type for API related errors when calling the Philips Hue API.
* @param error The error object returned from the request.
* @constructor
*/
export class ApiError extends Error {
name: string;
message: string;
type: any;
address: string;
constructor(error: Object);
}
export class HueApi {
/*
* Constructor used for searching for bridges and registering users
*/
constructor();
/**
* Creates an instance of HueApi.
* @param {string} host Address of Hue bridge
* @param {string} username Application username for Hue bridge
* @param {number} [timeout]
* @param {number} [port]
*/
constructor(host: string, username: string, timeout?: number, port?: number);
/**
* Gets the version data for the Philips Hue Bridge.
*
* @param cb An optional callback function if you don't want to be informed via a promise.
* @returns {Q.promise} A promise will be provided that will resolve to the version data for the bridge, or {null} if a
* callback was provided.
*/
getVersion(): Promise;
//getVersion(cb: (err: NodeJS.ErrnoException, data: IBridgeVersion) => void): void;
version(): Promise;
//version(cb: (err: NodeJS.ErrnoException, data: IBridgeVersion) => void): void;
/**
* Loads the description for the Philips Hue.
*
* @param cb An optional callback function if you don't want to be informed via a promise.
* @return {Q.promise} A promise that will be provided with a description object, or {null} if a callback was provided.
*/
description(): Promise;
//description(cb: (err: NodeJS.ErrnoException, data: IBridgeDescription) => void): void;
getDescription(): Promise;
//getDescription(cb: (err: NodeJS.ErrnoException, data: IBridgeDescription) => void): void;
/**
* Reads the bridge configuration and returns it as a JSON object.
*
* @param cb An optional callback function to use if you do not want to use the promise for results.
* @return {Q.promise} A promise with the result, or if a callback function was provided.
*/
config(): Promise;
//config(cb: (err: NodeJS.ErrnoException, data: IBridgeConfig) => void): void;
getConfig(): Promise;
//getConfig(cb: (err: NodeJS.ErrnoException, data: IBridgeConfig) => void): void;
/**
* Obtains the complete state for the Bridge. This is considered to be a very expensive operation and should not be invoked
* frequently. The results detail all config, users, groups, schedules and lights for the system.
*
* @param cb An optional callback function if you don't want to be informed via a promise.
* @returns {Q.promise} A promise with the result, or {null} if a callback function was provided
*/
getFullState(): Promise;
//getFullState(cb: (err: NodeJS.ErrnoException, data: IState) => void): void;
fullState(): Promise;
//fullState(cb: (err: NodeJS.ErrnoException, data: IState) => void): void;
/**
* Allows a new user/device to be registered with the Philips Hue Bridge. This will return the name of the user that was
* created by the function call.
*
* This function does not require the HueApi to have been initialized with a host or username. It does however require
* the end user to have pressed the link button on the bridge, before invoking this function.
*
* @param host The hostname or IP Address of the Hue Bridge.
* @param deviceDescription The description for the user/device that is being registered. This is a human readable
* description of the user/device. If one is not provided then a default will be set.
* @param cb An optional callback function to use if you do not want a promise returned.
* @return {Q.promise} A promise with the result, or if a callback was provided.
*/
registerUser(host: string, deviceDescription?: string): Promise;
//registerUser(host: string, deviceDescription?: string, cb: (err: NodeJS.ErrnoException, data: string) => void): void;
createUser(host: string, deviceDescription?: string): Promise;
//createUser(host: string, deviceDescription?: string, cb: (err: NodeJS.ErrnoException, data: string) => void): void;
/**
* Presses the Link Button on the Bridge (without the user actually having to do it). If successful then {true} will be
* returned as the result.
*
* @param cb An optional callback function to use if you do not want to use the promise returned.
* @return {Q.promise} A promise with the result, or if a callback was provided.
*/
pressLinkButton(): Promise;
//pressLinkButton(cb: (err: NodeJS.ErrnoException, data: boolean) => void): void;
/**
* Deletes an existing user from the Phillips Hue Bridge.
*
* @param username The username of the user to delete.
* @param cb An optional callback function to use if you do not want to get the result via a promise chain.
* @returns {Q.promise} A promise with the result of the deletion, or if a callback was provided.
*/
deleteUser(username: string): Promise;
//deleteUser(username: string, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void;
unregisterUser(username: string): Promise;
//unregisterUser(username: string, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void
/**
* Obtain a list of registered "users" or "devices" that can interact with the Philips Hue.
*
* @param cb An optional callback function if you do not want to use the promise to obtain the results.
* @return A promise that will provide the results of registered users, or if a callback was provided.
*/
registeredUsers(): Promise;
//registeredUsers(cb: (err: NodeJS.ErrnoException, data: IRegisteredUser) => void): void;
getRegisteredUsers(): Promise;
//getRegisteredUsers(cb: (err: NodeJS.ErrnoException, data: IRegisteredUser) => void): void;
/**
* Obtains the details of the individual sensors that are attached to the Philips Hue.
*
* @param cb An optional callback function to use if you do not want a promise returned.
* @return A promise that will be provided with the lights object, or {null} if a callback function was provided.
*/
sensors(): Promise;
//sensors(cb: (err: NodeJS.ErrnoException, data: ISensorsApiResponse) => void): void;
getSensors(): Promise;
//getSensors(cb: (err: NodeJS.ErrnoException, data: ISensorsApiResponse) => void): void;
/**
* Obtains the details of the individual lights that are attached to the Philips Hue.
*
* @param cb An optional callback function to use if you do not want a promise returned.
* @return A promise that will be provided with the lights object, or {null} if a callback function was provided.
*/
lights(): Promise;
//lights(cb: (err: NodeJS.ErrnoException, data: ILightsApiResponse) => void): void;
getLights(): Promise;
//getLights(cb: (err: NodeJS.ErrnoException, data: ILightsApiResponse) => void): void;
/**
* Obtains the status of the specified light.
*
* @param id The id of the light as an integer, this value will be parsed into an integer value so can be a {String} or
* {Number} value.
* @param cb An optional callback function to use if you do not want a promise returned.
* @return A promise that will be provided with the light status, or {null} if a callback function was provided.
*/
lightStatus(id: string | number): Promise;
//lightStatus(id: string|number, cb: (err: NodeJS.ErrnoException, data: ILight) => void): void;
getLightStatus(id: string | number): Promise;
//getLightStatus(id: string|number, cb: (err: NodeJS.ErrnoException, data: ILight) => void): void;
lightStatusWithRGB(id: string | number): Promise;
//lightStatusWithRGB(id: string|number, cb: (err: NodeJS.ErrnoException, data: ILight) => void): void;
getLightStatusWithRGB(id: string | number): Promise;
//getLightStatusWithRGB(id: string|number, cb: (err: NodeJS.ErrnoException, data: ILight) => void): void;
/**
* Obtains the new lights found by the bridge, dependant upon the last search.
*
* @param cb An optional callback function to use if you do not want a promise returned.
* @return A promise that will be provided with the new lights search result, or {null} if a callback function was provided.
*/
newLights(): Promise;
//newLights(cb: (err: NodeJS.ErrnoException, data: INewLightsResponse) => void): void;
getNewLights(): Promise;
//getNewLights(cb: (err: NodeJS.ErrnoException, data: INewLightsResponse) => void): void;
/**
* Starts a search for new lights.
*
* @param cb An optional callback function to use if you do not want a promise returned.
* @return A promise that will be provided with the new lights, or {null} if a callback function was provided.
*/
searchForNewLights(): Promise;
//searchForNewLights(cb: (err: NodeJS.ErrnoException, data: boolean) => void): void;
/**
* Sets the name of a light on the Bridge.
*
* @param id The ID of the light to set the name for.
* @param name The name to apply to the light.
* @param cb An optional callback function to use if you do not want a promise returned.
* @return A promise that will be provided with the results of setting the name, or {null} if a callback function was provided.
*/
setLightName(id: string | number, name: string): Promise;
//setLightName(id: string|number, name: string, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void;
/**
* Sets the light state to the provided values.
*
* @param id The id of the light which is an integer or a value that can be parsed into an integer value.
* @param stateValues {lightState.State} containing the properties and values to set on the light.
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @return A promise that will set the specified state on the light, or {null} if a callback was provided.
*/
setLightState(id: string | number, stateValues: lightState.State | Object): Promise;
//setLightState(id: string|number, stateValues: lightState.State | Object, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void;
/**
* Sets the light state to the provided values for an entire group.
*
* @param id The id of the group which is an integer or a value that can be parsed into an integer value.
* @param stateValues {lightState.State} containing the properties and values to set on the light.
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @return {Q.promise} A promise that will set the specified state on the group, or {null} if a callback was provided.
*/
setGroupLightState(id: string | number, stateValues: lightState.State | Object): Promise;
//setGroupLightState(id: string|number, stateValues: lightState.State | Object, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void;
/**
* Obtains all the groups from the Hue Bridge as an Array of {id: {*}, name: {*}} objects.
*
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @return A promise that will obtain the groups, or {null} if a callback was provided.
*/
groups(): Promise;
//groups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void;
getGroups(): Promise;
//getGroups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void;
getAllGroups(): Promise;
//getAllGroups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void;
/**
* Obtains all the Luminaires from the Hue Bridge as an Array of {id: {*}, name: {*}} objects.
*
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @return A promise that will obtain the luminaires, or {null} if a callback was provided.
*/
luminaires(): Promise;
//luminaires(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void;
getLuminaires(): Promise;
//getLuminaires(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void;
/**
* Obtains all the LightSources from the Hue Bridge as an Array of {id: {*}, name: {*}} objects.
*
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @return A promise that will obtain the lightsources, or {null} if a callback was provided.
*/
lightSources(): Promise;
//lightSources(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void;
getLightSources(): Promise;
//getLightSources(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void;
/**
* Obtains all the LightGroups from the Hue Bridge as an Array of {id: {*}, name: {*}} objects.
*
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @return A promise that will obtain the LightGroups, or {null} if a callback was provided.
*/
lightGroups(): Promise;
//lightGroups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void;
getLightGroups(): Promise;
//getLightGroups(cb: (err: NodeJS.ErrnoException, data: ILightGroup) => void): void;
/**
* Obtains the details for a specified group in a format of {id: {*}, name: {*}, lights: [], lastAction: {*}}.
*
* @param id {Number} or {String} which is the id of the group to get the details for.
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @return A promise that will set the specified state on the light, or {null} if a callback was provided.
*/
getGroup(id: string | number): Promise;
group(id: string | number): Promise;
/**
* Updates a light group to the specified name and/or lights ids. The name and light ids can be specified independently or
* together when calling this function.
*
* @param id The id of the group to update the name and/or light ids associated with it.
* @param name {String} The name of the group
* @param lightIds {Array} An array of light ids to be assigned to the group. If any of the ids are not present in the
* bridge the creation will fail with an error being produced.
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @return A promise with a result of if the update was successful, or null if a callback was provided.
*/
updateGroup(id: string | number, name: string, lightIds: string[]): Promise;
updateGroup(id: string | number, name: string, lightIds: string[], cb: (err: NodeJS.ErrnoException, data: boolean) => void): void;
/**
* Creates a new light Group.
*
* @param name The name of the group that we are creating, limited to 16 characters.
* @param lightIds {Array} of ids for the lights to be included in the group.
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @return {*} A promise that will return the id of the group that was created, or null if a callback was provided.
*/
createGroup(name: string, lightIds: string[]): Promise;
//createGroup(name: string, lightIds: string[], cb: (err: NodeJS.ErrnoException, data: string) => void): void;
/**
* Deletes a group with the specified id, returning if the action was successful.
*
* @param id The id of the group to delete.
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @return {*} A promise that will return if the deletion was successful, or null if a callback was provided.
*/
deleteGroup(id: string | number): Promise;
//deleteGroup(id: string|number, cb: (err: NodeJS.ErrnoException, data: boolean) => void): void;
/**
* Gets the schedules on the Bridge, as an array of {"id": {String}, "name": {String}} objects.
*
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @return A promise that will return the results or if a callback was provided.
*/
schedules(): Promise;
//schedules(cb: (err: NodeJS.ErrnoException, data: ISchedule[]) => void): void;
getSchedules(): Promise;
//getSchedules(cb: (err: NodeJS.ErrnoException, data: ISchedule[]) => void): void;
/**
* Gets the specified schedule by id, which is in an identical format the the Hue API documentation, with the addition
* of an "id" value for the schedule.
*
* @param id The id of the schedule to retrieve.
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @returns A promise that will return the results or if a callback was provided.
*/
schedule(id: string | number): Promise;
//schedule(id: string | number, cb: (err: NodeJS.ErrnoException, data: ISchedule) => void): void;
getSchedule(id: string | number): Promise;
//getSchedule(id: string | number, cb: (err: NodeJS.ErrnoException, data: ISchedule) => void): void;
/**
* Creates a one time scheduled event. The results from this function is the id of the created schedule. The bridge only
* supports 100 schedules, so once they are triggered, they are removed from the bridge.
*
* @param schedule {ScheduledEvent}
* @param cb An optional callback function to use if you do not want to use a promise for the results.
* @return A promise that will return the id value of the schedule that was created, or if a callback was provided.
*/
scheduleEvent(schedule: ISchedule): Promise;
//scheduleEvent(schedule: ISchedule, cb: (err: NodeJS.ErrnoException, data: string) => void): void;
createSchedule(schedule: ISchedule): Promise;
//createSchedule(schedule: ISchedule, cb: (err: NodeJS.ErrnoException, data: string) => void): void;
/**
* Deletes a schedule by id, returning {true} if the deletion was successful.
*
* @param id of the schedule
* @param cb An option callback function to use if you do not want to use a promise for the results.
* @return {Q.promise} A promise that will return the result of the deletion, or if a callback was provided.
*/
deleteSchedule(id: string | number): Promise