### Manage Scenes Source: https://context7.com/peter-murray/node-hue-api/llms.txt Create, retrieve, update, and activate scenes. Includes examples for getting all scenes, getting a scene by name, creating a new scene, updating light states within a scene, activating a scene, and deleting a scene. ```javascript const { v3 } = require('node-hue-api'); const SceneLightState = v3.lightStates.SceneLightState; async function manageScenes(api) { // Get all scenes const scenes = await api.scenes.getAll(); scenes.forEach(scene => { console.log(`[${scene.id}] ${scene.name} - Lights: ${scene.lights.join(', ')}`); }); // Get scene by name const concentrateScenes = await api.scenes.getSceneByName('Concentrate'); // Create a new scene const scene = v3.model.createLightScene(); scene.name = 'Movie Time'; scene.lights = [1, 2, 3]; const created = await api.scenes.createScene(scene); console.log(`Created scene: ${created.id}`); // Update scene light state const lightState = new SceneLightState() .on() .brightness(30) .ct(400); // Warm white await api.scenes.updateLightState(created.id, 1, lightState); // Light ID 1 await api.scenes.updateLightState(created.id, 2, lightState); // Light ID 2 // Activate a scene const activated = await api.scenes.activateScene(created.id); console.log(`Scene activated: ${activated}`); // Alternative: activate via groups API (allows targeting specific groups) const GroupLightState = v3.lightStates.GroupLightState; await api.groups.setGroupState(0, new GroupLightState().scene(created.id)); // Delete scene await api.scenes.deleteScene(created.id); } ``` -------------------------------- ### Install node-hue-api with npm Source: https://github.com/peter-murray/node-hue-api/blob/typescript/README.md Use npm to install the node-hue-api library for your Node.js project. ```bash $ npm install node-hue-api ``` -------------------------------- ### Supported States Array Examples Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/light.md Examples of supported state arrays for different light types. ```javascript [ "on", "bri", "hue", "sat", "effect", "xy", "ct", "alert", "colormode", "mode", "reachable", "transitiontime", "bri_inc", "sat_inc", "hue_inc", "ct_inc", "xy_inc" ] ``` ```javascript [ "on", "bri", "alert", "mode", "reachable", "transitiontime", "bri_inc" ] ``` -------------------------------- ### Software Update Object Examples Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/light.md Examples of the software update object structure for lights that support updates versus those that do not. ```json { "state": "noupdates", "lastinstall": "2019-09-23T22:12:54" } ``` ```json { "state": "notupdatable", "lastinstall": null } ``` -------------------------------- ### Light toString Output Example Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/light.md A simple string representation of a Light instance. ```text Light id: 10 ``` -------------------------------- ### Manage Sensors Source: https://context7.com/peter-murray/node-hue-api/llms.txt Interact with physical and CLIP sensors. Includes examples for getting all sensors, getting a specific sensor, searching for new sensors, creating CLIP sensors, updating sensor states, renaming sensors, and deleting sensors. ```javascript const { v3 } = require('node-hue-api'); async function manageSensors(api) { // Get all sensors const sensors = await api.sensors.getAll(); sensors.forEach(sensor => { console.log(`[${sensor.id}] ${sensor.name} (${sensor.type})`); console.log(` State: ${JSON.stringify(sensor.state)}`); }); // Get specific sensor (daylight sensor is always ID 1) const daylight = await api.sensors.getSensor(1); console.log(daylight.toStringDetailed()); // Search for new sensors await api.sensors.searchForNew(); const newSensors = await api.sensors.getNew(); console.log(`Last scan: ${newSensors.lastscan}`); // Create a CLIP sensor (software sensor) const clipSensor = v3.model.createCLIPGenericFlagSensor(); clipSensor.name = 'My Flag Sensor'; clipSensor.modelid = 'flag-sensor-v1'; clipSensor.swversion = '1.0'; clipSensor.uniqueid = 'my-unique-id-001'; clipSensor.manufacturername = 'My App'; const created = await api.sensors.createSensor(clipSensor); console.log(`Created sensor ID: ${created.id}`); // Update CLIP sensor state created.flag = true; await api.sensors.updateSensorState(created); // Rename sensor created.name = 'Renamed Sensor'; await api.sensors.renameSensor(created); // Delete sensor await api.sensors.deleteSensor(created.id); } ``` -------------------------------- ### New Lights Discovery Payload Example Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lights.md Example JSON payload structure for newly discovered lights, including the timestamp of the last scan and details of found lights. ```json { "lastscan": "2019-07-13T09:58:20", "7": { "name": "Hue Lamp 7" } } ``` -------------------------------- ### Install node-hue-api with yarn Source: https://github.com/peter-murray/node-hue-api/blob/typescript/README.md Use yarn to add the node-hue-api library to your Node.js project. ```bash $ yarn add node-hue-api ``` -------------------------------- ### GET /configuration Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/configuration.md Obtains the specific configuration settings of the Hue Bridge. ```APIDOC ## GET /configuration ### Description Obtains just the configuration of the Hue Bridge. ### Method GET ### Response #### Success Response (200) - **config** (Object) - An object containing all configuration options of the Bridge. ``` -------------------------------- ### GET /rules Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/rules.md Retrieves all rules defined in the Hue Bridge. ```APIDOC ## GET /rules ### Description Obtains all rules currently defined in the Hue Bridge. ### Method GET ### Response - **Success Response (200)** - **Array** - A list of Rule objects. ``` -------------------------------- ### GET /api/lights/all Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lights.md Retrieves all lights registered with the Hue Bridge. ```APIDOC ## getAll() The `getAll()` function allows you to get all the lights that the Hue Bridge has registered with it. ### Method GET ### Endpoint /api/lights/all ### Description Retrieves all lights registered with the Hue Bridge. ### Request Example ```js api.lights.getAll() .then(allLights => { // Display the lights from the bridge console.log(JSON.stringify(allLights, null, 2)); }); ``` ### Response #### Success Response (200) - **lights** (Array) - An array of Light objects. ### Response Example ```json [ { "id": "1", "name": "Living Room Lamp", "type": "Dimmable light", "modelid": "LWB004", "manufacturername": "Philips", "state": { "on": true, "bri": 254, "hue": 14898, "sat": 211, "effect": "none", "xy": [0.313, 0.329], "ct": 366, "alert": "none", "colormode": "xy", "reachable": true }, "capabilities": { "certified": true, "control": [ "on", "bri", "hue", "sat", "xy", "ct", "effect", "colorloop" ], "streaming": { "proxy": false, "renderer": false } }, "config": { "archetype": "sultanbulb", "name": "Living Room Lamp", "function": "mixed", "direction": "UNKNOWN" }, "uniqueid": "00:17:88:01:04:7c:1b:a1-0b", "swversion": "5.127.1.21214" } ] ``` ``` -------------------------------- ### GET /scenes Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/scenes.md Retrieves all scenes registered with the Hue Bridge. ```APIDOC ## GET /scenes ### Description Retrieves all scenes that the Hue Bridge has registered. ### Method GET ### Endpoint /scenes ### Response #### Success Response (200) - **scenes** (Array) - An array of Scene objects. ``` -------------------------------- ### Example Credentials Object Structure Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/remote.md Represents the structure of the object returned by getRemoteAccessCredentials. ```js { clientId: 'FSzJeGkrC6hJzPlDjC9bfxEMAQxXOvAY', clientSecret: 'YPI9z67Qh9Fjjh59', username: 'WkdWmGYI5tYVoy36ImLuLwXBwPoqxgakRnj5S0jL', tokens: { access: { value: 'AYZXfqbJXzSXetwcg9HS7V3ZmyAA', expiresAt: '1568298222137' }, refresh: { value: 'NeeoF9HkPS50xAUJX8R8q2kMxUOGBGsb', expiresAt: '1577370222137' } } } ``` -------------------------------- ### GET /configuration/all Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/configuration.md Retrieves the complete configuration and state of the Hue Bridge, including lights, sensors, rules, schedules, and resource links. ```APIDOC ## GET /configuration/all ### Description Retrieves the complete configuration and state of the Hue Bridge. ### Method GET ### Response #### Success Response (200) - **config** (Object) - The full configuration object containing lights, sensors, rules, schedules, resourcelinks, and bridge config. ``` -------------------------------- ### GET /capabilities/getAll Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/capabilities.md Retrieves the complete set of capabilities from the Hue Bridge, returning a Capabilities object. ```APIDOC ## GET /capabilities/getAll ### Description Retrieves the complete capabilities data from the Hue Bridge, detailing the total capacity and available slots for various resources. ### Method GET ### Endpoint api.capabilities.getAll() ### Response #### Success Response (200) - **Capabilities Object** (Object) - An object containing capacity details for lights, sensors, groups, scenes, schedules, rules, resourcelinks, streaming, and timezones. ``` -------------------------------- ### Result Object Format Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/scenes.md Example of the result object returned after updating scene light states. ```json { "on": true, "bri": true } ``` -------------------------------- ### Extended Color Light Capabilities Example Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/light.md A sample JSON structure representing the capabilities of an Extended Color Light. ```json "capabilities": { "certified": true, "control": { "mindimlevel": 5000, "maxlumen": 250, "colorgamuttype": "B", "colorgamut": [ [ 0.675, 0.322 ], [ 0.409, 0.518 ], [ 0.167, 0.04 ] ], "ct": { "min": 153, "max": 500 } }, "streaming": { "renderer": true, "proxy": true } } ``` -------------------------------- ### GET /api/lights/new Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lights.md Retrieves the list of newly discovered lights from the last search. ```APIDOC ## getNew() The `getNew()` function obtains the list of Lights that were discovered from the last time a search was performed (via `searchForNew()`). Note, the lights that are provided in this API call will be cleared when a new search is initiated on the Hue Bridge. ### Method GET ### Endpoint /api/lights/new ### Description Retrieves the list of newly discovered lights from the last search performed by `searchForNew()`. ### Request Example ```js api.lights.getNew() .then(results => { // Display the details of the search results console.log(JSON.stringify(results, null, 2)); }); ``` ### Response #### Success Response (200) - **results** (Object) - A JSON payload containing `lastscan` timestamp and discovered lights. ### Response Example ```json { "lastscan": "2019-07-13T09:58:20", "7": { "name": "Hue Lamp 7" } } ``` ``` -------------------------------- ### Populate LightState from Payload Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lightState.md Copy an existing LightState's configuration by getting its payload and populating a new LightState object with it. ```javascript const myLightState = new LightState().on.ct(200); // Create a copy of myLightState const copiedLightState = new LightState(); copiedLightState.populate(myLightState.getPayload()); ``` -------------------------------- ### Color Gamut Object Example Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/light.md The structure of the color gamut object returned for lights that support color. ```javascript { red: {x: 0.692, y: 0.308}, green: {x: 0.17, y: 0.7}, blue: {x: 0.153, y: 0.048} } ``` -------------------------------- ### Configure Timer with Minutes and Random Seconds Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/timePatterns.md Chain `minutes()` and `randomSeconds()` to set the timer's trigger time and randomness. This example creates a timer for 1 minute with 5 seconds of randomness. ```javascript // Create a timer that will trigger in 60 seconds / 1 minute with 5 seconds of randomness (PT00:01:00A00:00:05) const minuteTimer = timePatterns.createTimer().minutes(1).randomSeconds(5); ``` -------------------------------- ### Get User by Name Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/users.md Finds user accounts by specifying an application name and device name, or a general name. ```APIDOC ## GET /api/users ### Description Retrieves user accounts that match the provided application name and device name, or a general name. ### Method GET ### Endpoint /api/users ### Parameters #### Query Parameters - **appName** (string) - Optional - The name of the application. - **deviceName** (string) - Optional - The name of the device. - **name** (string) - Optional - A general name to search for users. ### Response #### Success Response (200) - **username** (string) - The username used for authentication. - **name** (string) - The name used to create the user account. - **create date** (string) - The date the user account was created. - **last use date** (string) - The date the user account was last used. ### Request Example ```js api.users.getByName('appName', 'deviceName') .then(allUsers => { console.log(JSON.stringify(allUsers, null, 2)); }); ``` ### Response Example ```json [ { "username": "a1b2c3d4e5f678901234567890abcdef", "name": "MyHueApp#MyDevice", "create date": "2023-01-01T10:00:00Z", "last use date": "2023-10-26T15:30:00Z" } ] ``` ``` -------------------------------- ### Configure Timer with Hours and Random Minutes Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/timePatterns.md Use `hours()` and `randomMinutes()` to define a timer that triggers in an hour with a random minute offset. This example sets up a 1-hour timer with up to 2 minutes of randomness. ```javascript // Create a timer that will trigger in 1 hour with randomness of 2 minutes (PT01:00:00A00:02:00) const hourTimer = timePatterns.createTimer().hours(1).randomMinutes(2); ``` -------------------------------- ### Create Timer instances Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/timePatterns.md Demonstrates creating default and string-initialized Timer objects. ```js // A Defaulted Timer "PT00:00:00" const timer = timePatterns.createTimer(); // A Timer for 1 hour const timerFromString = timePatterns.createTimer('PT01:00:00'); ``` -------------------------------- ### Create and Configure a LightState Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lightState.md Instantiate a LightState object and chain methods to set desired light properties like on/off state and color temperature. ```javascript const LightState = require('node-hue-api').v3.lightStates.LightState; const myLightState = new LightState(); // Do stuff with myLightState myLightState .on() .white(153, 100); ``` -------------------------------- ### Get All Lights Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lights.md Retrieves all lights registered with the Hue Bridge. Use this to get a list of all available lights. ```javascript api.lights.getAll() .then(allLights => { // Display the lights from the bridge console.log(JSON.stringify(allLights, null, 2)); }); ``` -------------------------------- ### Create RemoteBootstrap Instance Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/remoteBootstrap.md Instantiate RemoteBootstrap with your ClientId and ClientSecret obtained from the Hue Development Portal. ```javascript const v3 = require('node-hue-api').v3; const remoteBootstrap = v3.api.createRemote(clientId, clientSecret); ``` -------------------------------- ### GET /scenes/search Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/scenes.md Finds scenes by their name. ```APIDOC ## GET /scenes/search ### Description Finds all scenes stored in the bridge with the specified name. ### Method GET ### Endpoint /scenes/search ### Parameters #### Query Parameters - **name** (String) - Required - The name of the scenes to find. ### Response #### Success Response (200) - **results** (Array) - An array of Scene objects matching the name. ``` -------------------------------- ### GET /rules/name/{name} Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/rules.md Retrieves rules by their name. ```APIDOC ## GET /rules/name/{name} ### Description Obtains all Rules from the bridge that have the specified name. ### Method GET ### Parameters #### Path Parameters - **name** (string) - Required - The name of the Rule to search for. ``` -------------------------------- ### Configure Timer instances Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/timePatterns.md Shows how to chain configuration methods to set specific durations for a Timer. ```js // Create a timer that will trigger in 60 seconds / 1 minute (PT00:01:00) const minuteTimer = timePatterns.createTimer().minutes(1); // Create a timer that will trigger in 1 hour (PT01:00:00) const hourTimer = timePatterns.createTimer().hours(1); // Create a timer that will trigger in 1 hour 20 minutes and 30 seconds const timer = timePatterns.createTimer().hours(1).minutes(20).seconds(30); ``` -------------------------------- ### Light State Transition Methods Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lightState.md Methods to configure the transition time for light state changes. ```APIDOC ## Transition Methods ### Description Functions to set the transition duration for light state changes. ### Methods - **transitionSlow()**: Sets transition to 800ms. - **transtionFast()**: Sets transition to 200ms. - **transtionInstant()**: Sets transition to 0ms. - **transitionDefault()**: Sets transition to 400ms. ``` -------------------------------- ### GET /api/lights/name/:name Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lights.md Retrieves lights by their name. ```APIDOC ## getLightByName(name) The `getLightByName(name)` function allows you to retrieve a specific light by its associated name value. It is possible to have multiple lights with the same names, so this will return an array of lights that match the specified name. ### Method GET ### Endpoint /api/lights/name/:name ### Parameters #### Path Parameters - **name** (string) - Required - The name of the light to retrieve. ### Description Retrieves lights by their name. Returns an array of lights that match the specified name. ### Request Example ```js api.lights.getLightByName(name) .then(lights => { // Display the details of the first light match console.log(lights[0].toStringDetailed()); }); ``` ### Response #### Success Response (200) - **lights** (Array) - An array of Light instances that match the specified name. ### Response Example ```json [ { "id": "1", "name": "Living Room Lamp", "type": "Dimmable light", "modelid": "LWB004", "manufacturername": "Philips", "state": { "on": true, "bri": 254, "hue": 14898, "sat": 211, "effect": "none", "xy": [0.313, 0.329], "ct": 366, "alert": "none", "colormode": "xy", "reachable": true }, "capabilities": { "certified": true, "control": [ "on", "bri", "hue", "sat", "xy", "ct", "effect", "colorloop" ], "streaming": { "proxy": false, "renderer": false } }, "config": { "archetype": "sultanbulb", "name": "Living Room Lamp", "function": "mixed", "direction": "UNKNOWN" }, "uniqueid": "00:17:88:01:04:7c:1b:a1-0b", "swversion": "5.127.1.21214" } ] ``` ``` -------------------------------- ### Get Group Name Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/group.md Retrieve the name of the group. ```javascript group.name ``` -------------------------------- ### Import LightState Implementations Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lightState.md Import the necessary LightState implementations for interacting with Lights, Scene Lights, and Group Lights. ```javascript const LightState = require('node-hue-api').v3.lightStates.LightState; // LightState for interacting with Scene Lights const SceneLightState = require('node-hue-api').v3.lightStates.GroupLightState; // LightState for interacting with Group Lights const GroupLightState = require('node-hue-api').v3.lightStates.GroupLightState; ``` -------------------------------- ### Configure TimeInterval instances Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/timePatterns.md Shows how to chain configuration methods to set specific weekdays and times for a TimeInterval. ```js const time = timePatterns.createTimeInterval(); // Monday from 23:12:00 to 23:59:59 time.weekdays(timePatterns.weekdays.MONDAY) .fromHours(23).fromMinutes(12) .toHours(23).toMinutes(12).toSeconds(59) ; console.log(time.toString()); // Will print "W064/T23:12:00/T23:59:59" ``` -------------------------------- ### GET /sensors/new Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/sensors.md Retrieves sensors discovered in the previous search. ```APIDOC ## GET /sensors/new ### Description Returns the new sensors that were discovered in the previous search. ### Method GET ### Endpoint api.sensors.getNew() ### Response #### Success Response (200) - **lastscan** (String) - The timestamp of the last search. - **sensors** (Array) - An array of discovered sensors. ``` -------------------------------- ### Create a CLIPLightLevel Sensor Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/sensor.md Initializes a new CLIPLightlevel sensor instance and configures its identification and light level properties. ```javascript const model = require('node-hue-api').v3.model; const mySensor = model.createCLIPLightlevelSensor(); mySensor.modelid = 'software'; mySensor.swversion = '1.0'; mySensor.uniqueid = '00:00:00:01'; mySensor.manufacturername = 'node-hue-api'; // Set the name of the sensor mySensor.name = 'Lounge LightLevel'; // Set the light level mySensor.lightlevel = 1000; ``` -------------------------------- ### GET /sensors/{id} Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/sensors.md Retrieves a specific sensor by its ID. ```APIDOC ## GET /sensors/{id} ### Description Obtains the sensor identified by the specified ID value. ### Method GET ### Endpoint api.sensors.getSensor(id) ### Parameters #### Path Parameters - **id** (Number) - Required - The unique identifier of the sensor. ### Response #### Success Response (200) - **sensor** (Object) - An instance of a Sensor or its specialization. ``` -------------------------------- ### Build a Chained LightState Configuration Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lightState.md Create and populate a LightState object by chaining multiple configuration methods for brightness, saturation, and alert status. ```javascript myLightState = new LightState() .on(true) .brightness(50) .saturation(65) .alertShort(); ``` -------------------------------- ### GET /sensors Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/sensors.md Retrieves all sensors stored in the Hue Bridge. ```APIDOC ## GET /sensors ### Description Retrieves all sensors currently stored in the Hue Bridge. ### Method GET ### Endpoint api.sensors.getAll() ### Response #### Success Response (200) - **sensors** (Array) - An array of Sensor objects. ``` -------------------------------- ### Absolute Time Creation and Usage Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/timePatterns.md Demonstrates how to create and configure Absolute Time objects using the `timePatterns.createAbsoluteTime` method and its fluent setters. ```APIDOC ## Absolute Time ### Description An absolute time represents an exact date and time in the format `[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]`. ### Method `timePatterns.createAbsoluteTime(value)` ### Parameters - **value** (String | Date | AbsoluteTime) - Optional - The initial value to set for the AbsoluteTime. If not provided, defaults to today's date with time 00:00:00. ### Request Example ```js // Defaulted time using today's date and 00:00:00 for the time const myTime = timePatterns.createAbsoluteTime(); // Time built from a date object const timeFromDate = timePatterns.createAbsoluteTime(new Date()); const timeFromDate_2 = timePatterns.createAbsoluteTime(new Date('4 August 1977 00:00:00 GMT')); // Time from a compatible string const timeFromString = timePatterns.createAbsoluteTime('2019-11-01T12:30:00'); ``` ### Available Setters - `year(value)`: Sets the 4-digit year. - `month(value)`: Sets the month (1-12). - `day(value)`: Sets the day of the month (1-31). - `hours(value)`: Sets the hour (0-23). - `minutes(value)`: Sets the minute (0-59). - `seconds(value)`: Sets the second (0-59). - `toString()`: Returns the AbsoluteTime in the bridge format `[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]`. All setters return the `AbsoluteTime` instance for chaining. ### Request Example (Fluent) ```js // Create an AbsoluteTime using fluent functions const myTime = timePatterns.createAbsoluteTime().year(2019).month(11).day(24); console.log(myTime.toString()); // Outputs: 2019-11-24T00:00:00 ``` ### Response Example ```js // The toString() method returns a string representation "2019-11-24T00:00:00" ``` ``` -------------------------------- ### GET /rules/{id} Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/rules.md Retrieves a specific rule by its ID. ```APIDOC ## GET /rules/{id} ### Description Obtains the specified Rule with the given ID. ### Method GET ### Parameters #### Path Parameters - **id** (number/Rule) - Required - The ID for the rule or a Rule instance. ``` -------------------------------- ### Create RemoteBootstrap Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/remoteBootstrap.md Initializes the RemoteBootstrap object using credentials from the Hue Development Portal. ```APIDOC ## v3.api.createRemote ### Description Creates a RemoteBootstrap object to manage connection and configuration for the Hue Remote API. ### Parameters #### Request Body - **clientId** (String) - Required - The ClientId from the Hue Remote API application. - **clientSecret** (String) - Required - The ClientSecret from the Hue Remote API application. ### Request Example ```js const remoteBootstrap = v3.api.createRemote(clientId, clientSecret); ``` ``` -------------------------------- ### GET /api/lights/:id Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lights.md Retrieves a specific light by its ID. ```APIDOC ## getLight(id) The `getLight(id)` function allows you to retrieve a specific light. ### Method GET ### Endpoint /api/lights/:id ### Parameters #### Path Parameters - **id** (string | Light) - Required - The `id` number or a `Light` instance to retrieve from the bridge. ### Description Retrieves a specific light by its ID. ### Request Example ```js api.lights.getLight(id) .then(light => { // Display the details of the light console.log(light.toStringDetailed()); }); ``` ### Response #### Success Response (200) - **light** (Light) - A single Light instance. ### Response Example ```json { "id": "1", "name": "Living Room Lamp", "type": "Dimmable light", "modelid": "LWB004", "manufacturername": "Philips", "state": { "on": true, "bri": 254, "hue": 14898, "sat": 211, "effect": "none", "xy": [0.313, 0.329], "ct": 366, "alert": "none", "colormode": "xy", "reachable": true }, "capabilities": { "certified": true, "control": [ "on", "bri", "hue", "sat", "xy", "ct", "effect", "colorloop" ], "streaming": { "proxy": false, "renderer": false } }, "config": { "archetype": "sultanbulb", "name": "Living Room Lamp", "function": "mixed", "direction": "UNKNOWN" }, "uniqueid": "00:17:88:01:04:7c:1b:a1-0b", "swversion": "5.127.1.21214" } ``` ``` -------------------------------- ### Effect and Transition Methods Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lightState.md Methods for setting light effects and transition timing. ```APIDOC ## effect(value) ### Description Sets the effect on the light. ### Parameters - **value** (string) - Required - 'colorloop' or 'none'. ## transitiontime(value) ### Description Sets transition duration in multiples of 100ms. ### Parameters - **value** (number) - Required - Integer value. ## transition(value) ### Description Sets transition duration in milliseconds. ### Parameters - **value** (number) - Required - Duration in ms. ``` -------------------------------- ### Get Group ID Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/group.md Retrieve the unique identifier for a group. ```javascript group.id ``` -------------------------------- ### Create a CLIPPresence Sensor Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/sensor.md Initializes a new CLIPPresence sensor instance to track occupancy at a specific location. ```javascript const model = require('node-hue-api').v3.model; const mySensor = model.createCLIPPresenceSensor(); mySensor.modelid = 'software'; mySensor.swversion = '1.0'; mySensor.uniqueid = '00:00:00:01'; mySensor.manufacturername = 'node-hue-api'; // Set the name of the sensor mySensor.name = 'Lounge Presence'; // Set the presence state mySensor.presence = true; ``` -------------------------------- ### Creating a Rule Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/rule.md How to instantiate a new Rule object using the node-hue-api library. ```APIDOC ## Creating a Rule ### Description Instantiate a new Rule object. Note that a Rule must have at least one RuleCondition and one RuleAction to be valid. ### Request Example ```js const Rule = require('node-hue-api').v3.rules.Rule; const myRule = new Rule(); ``` ``` -------------------------------- ### GET /resourceLinks?name={name} Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/resourcelinks.md Retrieves ResourceLinks by their name. ```APIDOC ## GET /resourceLinks?name={name} ### Description Retrieves all `ResourceLink` instances that match the provided name from the Hue Bridge. ### Method GET ### Endpoint /api/resourceLinks?name={name} ### Parameters #### Query Parameters - **name** (String) - Required - The name of the `ResourceLink` to retrieve. ### Request Example ```javascript api.resourceLinks.getResourceLinkByName('My Resource Link') ``` ### Response #### Success Response (200) - **Array** (`ResourceLink` objects) - A list of `ResourceLink` objects matching the provided name. #### Response Example ```json [ { "id": "string", "name": "string", "description": "string", "recycle": true, "classid": 100, "links": { "groups": [0], "lights": [0], "sensors": [0], "rules": [0] } } ] ``` #### Error Response (404) - **ApiError** - An `ApiError` with `getHueErrorType()` value of `3` if no `ResourceLink` with the specified name is found. ``` -------------------------------- ### GET /resourceLinks/{id} Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/resourcelinks.md Retrieves a specific ResourceLink by its ID. ```APIDOC ## GET /resourceLinks/{id} ### Description Retrieves a specific `ResourceLink` from the Hue Bridge using its unique ID. ### Method GET ### Endpoint /api/resourceLinks/{id} ### Parameters #### Path Parameters - **id** (String) - Required - The ID of the `ResourceLink` to retrieve. ### Request Example ```javascript api.resourceLinks.getResourceLink('62738') ``` ### Response #### Success Response (200) - **ResourceLink** object - The `ResourceLink` object corresponding to the provided ID. #### Response Example ```json { "id": "string", "name": "string", "description": "string", "recycle": true, "classid": 100, "links": { "groups": [0], "lights": [0], "sensors": [0], "rules": [0] } } ``` #### Error Response (404) - **ApiError** - An `ApiError` with `getHueErrorType()` value of `3` if the `ResourceLink` is not found. ``` -------------------------------- ### Import SceneLightState Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/scenes.md Import the SceneLightState class required for defining light states within a scene. ```javascript const SceneLightState = require('node-hue-api').v3.lightStates.SceneLightState; ``` -------------------------------- ### GET /resourceLinks Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/resourcelinks.md Retrieves all ResourceLinks registered with the Hue Bridge. ```APIDOC ## GET /resourceLinks ### Description Retrieves all `ResourceLinks` that the Hue Bridge has registered with it. ### Method GET ### Endpoint /api/resourceLinks ### Parameters None ### Request Example ```javascript api.resourceLinks.getAll() ``` ### Response #### Success Response (200) - **Array** (`ResourceLink` objects) - A list of all ResourceLink objects. #### Response Example ```json [ { "id": "string", "name": "string", "description": "string", "recycle": true, "classid": 100, "links": { "groups": [0], "lights": [0], "sensors": [0], "rules": [0] } } ] ``` ``` -------------------------------- ### Initialize a SensorCondition Builder Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/ruleCondition.md Create a builder instance for a specific sensor retrieved from the Hue Bridge. ```javascript const v3 = require('node-hue-api').v3 , conditions = v3.model.ruleConditions; const mySensor = await v3.sensors.get(sesnorId); const mySensorCondition = conditions.sensor(mySensor); // Then build the condition using the functions/properties on the SensorConditions ``` -------------------------------- ### GET /scenes/{id} Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/scenes.md Retrieves a specific scene by its unique identifier. ```APIDOC ## GET /scenes/{id} ### Description Retrieves a specific scene from the Hue Bridge. ### Method GET ### Endpoint /scenes/{id} ### Parameters #### Path Parameters - **id** (String) - Required - The unique identifier of the scene. ### Response #### Success Response (200) - **scene** (Object) - The requested Scene object. ``` -------------------------------- ### Get a specific sensor Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/sensors.md Retrieves a sensor object by its unique identifier. ```js // Get the daylight sensor for the bridge, at id 1 api.sensors.getSensor(1) .then(sensor => { console.log(sensor.toStringDetailed()); }) ; ``` -------------------------------- ### Create Room Instance Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/group.md Use v3.model.createRoom() to create a new instance of a Room. ```javascript v3.model.createRoom() ``` -------------------------------- ### GET /schedules Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/schedules.md Retrieves all registered Schedule objects from the Hue Bridge. ```APIDOC ## getAll() The `getAll()` function allows you to get all the `Schedule`s that the Hue Bridge has registered with it. ### Method GET ### Endpoint /api/schedules ### Parameters None ### Request Example ```js api.schedules.getAll() .then(allSchedules => { // Display the Schedules from the bridge allSchedules.forEach(schedule => { console.log(schedule.toStringDetailed()); }); }); ``` ### Response #### Success Response (200) - **schedules** (Array) - An array of Schedule objects. #### Response Example ```json [ { "id": "1", "name": "My Schedule", "description": "A test schedule.", "command": { "address": "/api/groups/0/action", "method": "PUT", "body": { "on": false } }, "localtime": "2023-10-27T10:00:00", "status": "enabled", "autodelete": false } ] ``` ``` -------------------------------- ### Get Entertainment Stream Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/group.md Retrieve the 'stream' property of an Entertainment group. ```javascript entertainment.stream ``` -------------------------------- ### Get Entertainment Locations Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/group.md Retrieve the 'locations' property of an Entertainment group. ```javascript entertainment.locations ``` -------------------------------- ### Create a CLIPHumidity Sensor Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/sensor.md Initializes a new CLIPHumidity sensor instance and sets its basic properties and initial humidity level. ```javascript const model = require('node-hue-api').v3.model; const mySensor = model.createCLIPHumiditySensor(); mySensor.modelid = 'software'; mySensor.swversion = '1.0'; mySensor.uniqueid = '00:00:00:01'; mySensor.manufacturername = 'node-hue-api'; // Set the name of the sensor mySensor.name = 'Lounge Humidity'; // Set the humidity level mySensor.humidity = 1000; // 10% ``` -------------------------------- ### GET getLightState Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lights.md Obtains the current state values for a specific light. ```APIDOC ## GET getLightState ### Description Obtains the current state values for a light identified by the provided ID. ### Parameters #### Path Parameters - **id** (string/number) - Required - The unique identifier of the light. ### Response #### Success Response (200) - **state** (Object) - The current state values of the light. #### Response Example { "on": false, "bri": 0, "hue": 38191, "reachable": true } ``` -------------------------------- ### Create a CLIPOpenClose Sensor Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/sensor.md Initializes a new CLIPOpenClose sensor instance for monitoring door or window states. ```javascript const model = require('node-hue-api').v3.model; const mySensor = model.createCLIPOpenCloseSensor(); mySensor.modelid = 'software'; mySensor.swversion = '1.0'; mySensor.uniqueid = '00:00:00:01'; mySensor.manufacturername = 'node-hue-api'; // Set the name of the sensor mySensor.name = 'Lounge Door'; // Set the open state mySensor.open = false; ``` -------------------------------- ### Get Entertainment Class Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/group.md Retrieve the 'class' property of an Entertainment group. ```javascript entertainment.class ``` -------------------------------- ### Create TimeInterval instances Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/timePatterns.md Demonstrates creating default and string-parsed TimeInterval objects. ```js // A defaulted time interval, ALL weekdays with a from and to time of 00:00:00 const myRandomTime = timePatterns.createTimeInterval(); // A string that is compatible with the time interval format (ALL weekdays from 12:30:00 to 12:40:00) const timeFromString = timePatterns.createTimeInterval('W127/T12:30:00/T12:40:00') ``` -------------------------------- ### GET getLightAttributesAndState Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/lights.md Retrieves all attributes and the current state of a specific light. ```APIDOC ## GET getLightAttributesAndState ### Description Retrieves all attributes and the current state of a particular light from the Hue Bridge. ### Parameters #### Path Parameters - **id** (string/number) - Required - The unique identifier of the light. ### Response #### Success Response (200) - **attributesAndState** (Object) - An object containing light attributes, state, configuration, and capabilities. #### Response Example { "id": 1, "state": { "on": false, "bri": 0, "hue": 38191, "sat": 94, "reachable": true }, "name": "Living Colour Floor", "manufacturername": "Philips" } ``` -------------------------------- ### Get Recycle Flag Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/group.md Check if the bridge can automatically remove the group. ```javascript group.recycle ``` -------------------------------- ### LightState Builder Source: https://context7.com/peter-murray/node-hue-api/llms.txt Reference for constructing light state payloads including power, color, effects, and transitions. ```APIDOC ## POST /lights/{id}/state ### Description Updates the state of a light using the LightState builder payload. ### Method POST ### Endpoint /lights/{id}/state ### Request Body - **on** (boolean) - Optional - Power state - **bri** (number) - Optional - Brightness (1-254) - **ct** (number) - Optional - Color temperature in mireds - **hue** (number) - Optional - Hue value (0-65535) - **sat** (number) - Optional - Saturation (0-254) - **xy** (array) - Optional - CIE xy coordinates - **effect** (string) - Optional - Effect type ('colorloop', 'none') - **alert** (string) - Optional - Alert type ('select', 'lselect', 'none') - **transitiontime** (number) - Optional - Transition time in 100ms units ``` -------------------------------- ### POST /scenes Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/scenes.md Creates a new scene in the Hue Bridge. ```APIDOC ## POST /scenes ### Description Allows for the creation of new scenes in the Hue Bridge. ### Method POST ### Endpoint /scenes ### Parameters #### Request Body - **scene** (Object) - Required - A Scene object configured with desired settings. ### Response #### Success Response (200) - **scene** (Object) - The created GroupScene or LightScene object. ``` -------------------------------- ### Users API - Get All Users Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/users.md Returns all whitelisted users from the Hue bridge. ```APIDOC ## GET /api/users ### Description Retrieves a list of all whitelisted user accounts from the Hue Bridge. ### Method GET ### Endpoint /api/users ### Response #### Success Response (200) - **Array of User Objects** - **username** (string) - The username for authentication. - **name** (string) - The name used to create the user account (e.g., 'appName#deviceName'). - **create date** (string) - The date of user account creation. - **last use date** (string) - The date the user account was last used. #### Response Example ```json [ { "username": "user1_username", "name": "myApp#myDevice", "create date": "2023-01-01T10:00:00", "last use date": "2023-10-26T15:30:00" } ] ``` ``` -------------------------------- ### GET /api/groups/{id}/state Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/groups.md Retrieves the current state of a specified group. ```APIDOC ## GET /api/groups/{id}/state ### Description Retrieves the current state of a specified group. ### Method GET ### Endpoint `/api/groups/{id}/state` ### Parameters #### Path Parameters - **id** (integer | Group Object) - Required - The ID of the group to get the state for. ### Response #### Success Response (200) - **state** (Object) - An object containing the current state values for the Group. ### Request Example ```js api.groups.getGroupState(id) .then(state => { console.log(JSON.stringify(state, null, 2)); }); ``` ``` -------------------------------- ### Configure RecurringTime with Chained Methods Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/timePatterns.md Shows how to use setter methods to configure time and weekdays, utilizing method chaining to return the instance. ```javascript const time = timePatterns.createRecurringTime(); time.hours(23).minutes(12).seconds(31).weekdays(timePatterns.weekdays.MONDAY); console.log(time.toString()); // Will print "W064/T23:12:31" ``` -------------------------------- ### Get Zone Class Source: https://github.com/peter-murray/node-hue-api/blob/typescript/docs/group.md Retrieve the 'class' property of a Zone, representing its category. ```javascript zone.class ```