Showing preview only (381K chars total). Download the full file or copy to clipboard to get everything.
Repository: sqmk/huejay
Branch: master
Commit: 92be1ebb960c
Files: 303
Total size: 318.8 KB
Directory structure:
gitextract_9a1zhf9_/
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── examples/
│ ├── .gitignore
│ ├── bridge/
│ │ ├── get-bridge.js
│ │ ├── is-authenticated.js
│ │ ├── lamp-stealer.js
│ │ ├── link-button.js
│ │ ├── ping.js
│ │ └── save-bridge.js
│ ├── capabilities/
│ │ ├── get-groups.js
│ │ ├── get-lights.js
│ │ ├── get-resource-links.js
│ │ ├── get-rules.js
│ │ ├── get-scenes.js
│ │ ├── get-schedules.js
│ │ ├── get-sensors.js
│ │ └── get-time-zones.js
│ ├── discover.js
│ ├── groups/
│ │ ├── get-groups.js
│ │ ├── increase-group-hs.js
│ │ ├── manage-group.js
│ │ └── manage-room-group.js
│ ├── init-client.js
│ ├── internet-services/
│ │ └── get-internet-services.js
│ ├── lights/
│ │ ├── get-light.js
│ │ ├── get-lights.js
│ │ ├── get-new-lights.js
│ │ ├── increase-light-hs.js
│ │ ├── save-light.js
│ │ └── start-light-scan.js
│ ├── portal/
│ │ └── get-portal.js
│ ├── resource-links/
│ │ ├── get-resource-link.js
│ │ ├── get-resource-links.js
│ │ └── manage-resource-link.js
│ ├── rules/
│ │ ├── get-rules.js
│ │ └── manage-rule.js
│ ├── scenes/
│ │ ├── get-scenes.js
│ │ ├── manage-scene.js
│ │ ├── recall-scene.js
│ │ └── save-scene.js
│ ├── schedules/
│ │ ├── get-schedules.js
│ │ └── manage-schedule.js
│ ├── sensors/
│ │ ├── create-switch.js
│ │ ├── get-sensors.js
│ │ ├── manage-sensor.js
│ │ └── update-switch.js
│ ├── software-update/
│ │ ├── check-for-software-updates.js
│ │ ├── disable-install-notification.js
│ │ ├── get-software-update.js
│ │ └── install-software-updates.js
│ ├── time-zones/
│ │ └── get-time-zones.js
│ └── users/
│ ├── create-user.js
│ ├── delete-user.js
│ ├── get-user.js
│ └── get-users.js
├── lib/
│ ├── Accessor/
│ │ ├── AbstractAccessor.js
│ │ ├── Actions.js
│ │ ├── Bridge.js
│ │ ├── Capabilities.js
│ │ ├── Groups.js
│ │ ├── InternetServices.js
│ │ ├── Lights.js
│ │ ├── Portal.js
│ │ ├── ResourceLinks.js
│ │ ├── Rules.js
│ │ ├── Scenes.js
│ │ ├── Schedules.js
│ │ ├── Sensors.js
│ │ ├── SoftwareUpdate.js
│ │ ├── TimePatterns.js
│ │ ├── TimeZones.js
│ │ └── Users.js
│ ├── Action/
│ │ ├── AbstractAction.js
│ │ ├── ChangeGroupAction.js
│ │ ├── ChangeLightState.js
│ │ └── ChangeSensorState.js
│ ├── BridgeModel/
│ │ ├── AbstractBridgeModel.js
│ │ ├── BSB001.js
│ │ ├── BSB002.js
│ │ ├── Factory.js
│ │ └── Unknown.js
│ ├── CapabilityModel/
│ │ ├── AbstractCapabilityModel.js
│ │ ├── Groups.js
│ │ ├── Lights.js
│ │ ├── ResourceLinks.js
│ │ ├── Rules.js
│ │ ├── Scenes.js
│ │ ├── Schedules.js
│ │ └── Sensors.js
│ ├── Client.js
│ ├── Command/
│ │ ├── Bridge/
│ │ │ ├── EnableLinkButton.js
│ │ │ ├── EnableTouchlink.js
│ │ │ ├── GetBridge.js
│ │ │ ├── IsAuthenticated.js
│ │ │ ├── Ping.js
│ │ │ ├── SaveBridge.js
│ │ │ └── Utils.js
│ │ ├── Capability/
│ │ │ ├── GetGroups.js
│ │ │ ├── GetLights.js
│ │ │ ├── GetResourceLinks.js
│ │ │ ├── GetRules.js
│ │ │ ├── GetScenes.js
│ │ │ ├── GetSchedules.js
│ │ │ ├── GetSensors.js
│ │ │ └── GetTimeZones.js
│ │ ├── Group/
│ │ │ ├── CreateGroup.js
│ │ │ ├── DeleteGroup.js
│ │ │ ├── GetGroup.js
│ │ │ ├── GetGroups.js
│ │ │ ├── SaveGroup.js
│ │ │ ├── SaveGroupAction.js
│ │ │ └── Utils.js
│ │ ├── InternetServices/
│ │ │ ├── GetInternetServices.js
│ │ │ └── Utils.js
│ │ ├── Light/
│ │ │ ├── DeleteLight.js
│ │ │ ├── GetLight.js
│ │ │ ├── GetLights.js
│ │ │ ├── GetNewLights.js
│ │ │ ├── SaveLight.js
│ │ │ ├── SaveLightState.js
│ │ │ ├── StartLightScan.js
│ │ │ └── Utils.js
│ │ ├── Portal/
│ │ │ ├── GetPortal.js
│ │ │ └── Utils.js
│ │ ├── ResourceLinks/
│ │ │ ├── CreateResourceLink.js
│ │ │ ├── DeleteResourceLink.js
│ │ │ ├── GetResourceLink.js
│ │ │ ├── GetResourceLinks.js
│ │ │ ├── SaveResourceLink.js
│ │ │ └── Utils.js
│ │ ├── Rule/
│ │ │ ├── CreateRule.js
│ │ │ ├── DeleteRule.js
│ │ │ ├── GetRule.js
│ │ │ ├── GetRules.js
│ │ │ ├── SaveRule.js
│ │ │ └── Utils.js
│ │ ├── Scene/
│ │ │ ├── CreateScene.js
│ │ │ ├── DeleteScene.js
│ │ │ ├── GetSceneById.js
│ │ │ ├── GetScenes.js
│ │ │ ├── RecallScene.js
│ │ │ ├── SaveScene.js
│ │ │ ├── SaveSceneLightState.js
│ │ │ └── Utils.js
│ │ ├── Schedule/
│ │ │ ├── CreateSchedule.js
│ │ │ ├── DeleteSchedule.js
│ │ │ ├── GetSchedule.js
│ │ │ ├── GetSchedules.js
│ │ │ ├── SaveSchedule.js
│ │ │ └── Utils.js
│ │ ├── Sensor/
│ │ │ ├── CreateSensor.js
│ │ │ ├── DeleteSensor.js
│ │ │ ├── GetNewSensors.js
│ │ │ ├── GetSensor.js
│ │ │ ├── GetSensors.js
│ │ │ ├── SaveSensor.js
│ │ │ ├── SaveSensorConfig.js
│ │ │ ├── SaveSensorState.js
│ │ │ ├── StartSensorScan.js
│ │ │ └── Utils.js
│ │ ├── SoftwareUpdate/
│ │ │ ├── CheckForSoftwareUpdates.js
│ │ │ ├── DisableInstallNotification.js
│ │ │ ├── GetSoftwareUpdate.js
│ │ │ ├── InstallSoftwareUpdates.js
│ │ │ └── Utils.js
│ │ ├── TimeZone/
│ │ │ └── GetTimeZones.js
│ │ └── User/
│ │ ├── CreateUser.js
│ │ ├── DeleteUser.js
│ │ ├── GetUser.js
│ │ ├── GetUsers.js
│ │ └── Utils.js
│ ├── Discovery.js
│ ├── DiscoveryStrategy/
│ │ ├── Nupnp.js
│ │ └── Upnp.js
│ ├── Error.js
│ ├── GroupModel/
│ │ ├── AbstractGroupModel.js
│ │ ├── Factory.js
│ │ ├── HBL001.js
│ │ ├── HBL002.js
│ │ ├── HBL003.js
│ │ ├── HEL001.js
│ │ ├── HEL002.js
│ │ ├── HIL001.js
│ │ ├── HIL002.js
│ │ ├── HML001.js
│ │ ├── HML002.js
│ │ ├── HML003.js
│ │ ├── HML004.js
│ │ ├── HML005.js
│ │ ├── HML006.js
│ │ ├── HML007.js
│ │ └── Unknown.js
│ ├── Huejay.js
│ ├── LightModel/
│ │ ├── AbstractLightModel.js
│ │ ├── Factory.js
│ │ ├── LCT001.js
│ │ ├── LCT002.js
│ │ ├── LCT003.js
│ │ ├── LCT007.js
│ │ ├── LCT010.js
│ │ ├── LCT011.js
│ │ ├── LCT012.js
│ │ ├── LCT014.js
│ │ ├── LLC006.js
│ │ ├── LLC007.js
│ │ ├── LLC010.js
│ │ ├── LLC011.js
│ │ ├── LLC012.js
│ │ ├── LLC013.js
│ │ ├── LLC014.js
│ │ ├── LLC020.js
│ │ ├── LLM001.js
│ │ ├── LLM010.js
│ │ ├── LLM011.js
│ │ ├── LLM012.js
│ │ ├── LST001.js
│ │ ├── LST002.js
│ │ ├── LTW001.js
│ │ ├── LTW004.js
│ │ ├── LTW010.js
│ │ ├── LTW011.js
│ │ ├── LTW012.js
│ │ ├── LTW013.js
│ │ ├── LTW014.js
│ │ ├── LTW015.js
│ │ ├── LWB004.js
│ │ ├── LWB006.js
│ │ ├── LWB007.js
│ │ ├── LWB010.js
│ │ ├── LWB014.js
│ │ └── Unknown.js
│ ├── Model/
│ │ ├── Attributes.js
│ │ ├── Bridge.js
│ │ ├── Condition.js
│ │ ├── Group.js
│ │ ├── InternetServices.js
│ │ ├── Light.js
│ │ ├── Portal.js
│ │ ├── ResourceLink.js
│ │ ├── Rule.js
│ │ ├── Scene.js
│ │ ├── Schedule.js
│ │ ├── Sensor.js
│ │ ├── SoftwareUpdate.js
│ │ └── User.js
│ ├── SensorModel/
│ │ ├── AbstractSensorModel.js
│ │ ├── Factory.js
│ │ ├── PHDL00.js
│ │ ├── RWL020.js
│ │ ├── RWL021.js
│ │ ├── SML001.js
│ │ ├── Unknown.js
│ │ └── ZGPSWITCH.js
│ ├── SensorType/
│ │ ├── AbstractClipSensorConfig.js
│ │ ├── AbstractSensorConfig.js
│ │ ├── AbstractSensorState.js
│ │ ├── AbstractZLLSensorConfig.js
│ │ ├── CLIPGenericFlag/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPGenericStatus/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPHumidity/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPLightLevel/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPOpenClose/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPPresence/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPSwitch/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPTemperature/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── Daylight/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── Factory.js
│ │ ├── Unknown/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── ZGPSwitch/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── ZLLLightLevel/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── ZLLPresence/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── ZLLSwitch/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ └── ZLLTemperature/
│ │ ├── Config.js
│ │ └── State.js
│ ├── TimePattern/
│ │ ├── AbsoluteTime.js
│ │ ├── RandomizedTime.js
│ │ ├── RecurringTime.js
│ │ └── Timer.js
│ └── Transport.js
├── package.json
└── test/
├── Discovery.spec.js
├── Huejay.spec.js
├── TimePattern/
│ ├── AbsoluteTime.spec.js
│ ├── RandomizedTime.spec.js
│ ├── RecurringTime.spec.js
│ └── Timer.spec.js
└── mocha.opts
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
/node_modules
/npm-debug.log
/package-lock.json
/benchmark
================================================
FILE: .travis.yml
================================================
language: node_js
node_js:
- "6.14.4"
- "8.12.0"
- "10.10.0"
script:
- npm run test
notifications:
email: false
sudo: false
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2015, 2016 Michael K. Squires
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
<p align="center">
<img src="https://cdn.rawgit.com/sqmk/huejay/db9081ee1a22acf77abc93cbd3f2e8f6d20ee16b/media/huejay.svg" alt="Huejay" />
</p>
# Huejay - Philips Hue client for Node.js
[](https://www.npmjs.com/package/huejay)
[](https://travis-ci.org/sqmk/huejay)
[](https://david-dm.org/sqmk/huejay)
[](https://greenkeeper.io/)
Huejay is the most in-depth Node.js client for the Philips Hue home lighting system.
Use Huejay to interact with Philips Hue in the following ways:
- [Discover bridges](#bridge-discovery)
- [Manage bridge settings](#bridge)
- [Manage portal settings](#portal)
- [Manage software updates](#software-update)
- [Manage users](#users)
- [Manage lights](#lights)
- [Manage groups](#groups)
- [Manage schedules](#schedules)
- [Manage scenes](#scenes)
- [Manage sensors](#sensors)
- [Manage rules](#rules)
- [Manage resource links](#resource-links)
- [Retrieve capabilities](#capabilities)
- [Retrieve internet services](#internet-services)
Philips Hue API version supported: **1.19.0**
## Documentation
- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Bridge Discovery](#bridge-discovery)
- [Errors](#errors)
- [Client Usage](#client-usage)
- [Users](#users)
- [Bridge](#bridge)
- [Portal](#portal)
- [Software Update](#software-update)
- [Internet Services](#internet-services)
- [Lights](#lights)
- [Groups](#groups)
- [Schedules](#schedules)
- [Time Patterns](#time-patterns)
- [Actions](#actions)
- [Scenes](#scenes)
- [Sensors](#sensors)
- [Rules](#rules)
- [Resource Links](#resource-links)
- [Capabilities](#capabilities)
- [Time Zones](#time-zones)
## Installation
Huejay was written for **Node.js 4+**.
`npm install --save huejay`
## Basic Usage
Requiring the library is simple:
```js
let huejay = require('huejay');
```
Most methods return a `Promise` as a result. These are native Node.js promises.
## Bridge Discovery
Before interacting with your Hue system, you may want to know the availability
and IP addresses of your bridges. You can use Huejay's `discover` method to find
them.
```js
huejay.discover()
.then(bridges => {
for (let bridge of bridges) {
console.log(`Id: ${bridge.id}, IP: ${bridge.ip}`);
}
})
.catch(error => {
console.log(`An error occurred: ${error.message}`);
});
```
Huejay offers several strategies for bridge discovery:
* **nupnp**: Default option, uses Meethue's public API to discover local bridges
* **upnp**: Uses SSDP to discover local bridges
* **all**: Uses all available strategies for discovery
To use a specific discovery strategy:
```js
huejay.discover({strategy: 'upnp'})
.then(bridges => {
console.log(bridges);
});
```
## Errors
Nearly all errors returned by Huejay are of type `huejay.Error`. Use this to
check Huejay specific errors.
Errors originating from the bridge return an additional `type` property.
This value is the error number as returned by the Philips Hue API.
## Client Usage
You can use Huejay to retrieve and manipulate resources on your preferred bridge.
Resources include users, lights, groups, scenes, and others.
To start, you must instantiate a client. The `Client` class is available for
convenience via Huejay;
```js
let client = new huejay.Client({
host: '123.0.12.34',
port: 80, // Optional
username: 'bridgeusername', // Optional
timeout: 15000, // Optional, timeout in milliseconds (15000 is the default)
});
```
If a *username* is not provided, nearly all commands will fail due to failure to
authenticate with the bridge. Be sure to provide a valid *username* to use all
client commands.
The *timeout* option applies to bridge commands. The default value is 15000
milliseconds (or 15 seconds).
### Users
Huejay provides several commands for managing users on Philips Hue bridges.
#### client.users.create - Create user
You can use Huejay to create users on the bridge. Creating a user requires the
bridge's link button to be pressed. The link button is activated for roughly
30 seconds.
To create a user, instantiate a `User` object and pass it to `client.users.create`.
On successful creation, a brand new `User` object is returned by way of a `Promise`.
The `User` object will contain a username generated by the bridge. You can use
this username to authenticate against the bridge going forward.
```js
let user = new client.users.User;
// Optionally configure a device type / agent on the user
user.deviceType = 'my_device_type'; // Default is 'huejay'
client.users.create(user)
.then(user => {
console.log(`New user created - Username: ${user.username}`);
})
.catch(error => {
if (error instanceof huejay.Error && error.type === 101) {
return console.log(`Link button not pressed. Try again...`);
}
console.log(error.stack);
});
```
*Note: The bridge does not permit supplying your own username.*
*Note: It is possible to use Huejay to toggle the link button if you are already
authenticated with the bridge. This may save you from walking over to the bridge
to physically press the link button. See `client.bridge.save` and `Bridge`
`linkButtonEnabled`.*
#### client.users.get - Get authenticated user
If the username assigned to the client is legitimate, you can get the details for
this user by calling `client.users.get`.
```js
client.users.get()
.then(user => {
console.log('Username:', user.username);
console.log('Device type:', user.deviceType);
console.log('Create date:', user.created);
console.log('Last use date:', user.lastUsed);
});
```
#### client.users.getByUsername - Get user by username
Although the bridge does not provide an equivalent API for retrieving a user
by username, Huejay provides a means to do so.
Simply pass in a string containing username to `client.users.getByUsername` to
look up the user.
```js
client.users.getByUsername('usernamehere')
.then(user => {
console.log(`Username: ${user.username}`);
});
.catch(error => {
console.log(error.stack);
});
```
If a user is not found with the provided username, a `huejay.Error` is thrown.
#### client.users.getAll - Get all users
Want to retrieve all users assigned to the bridge? You can use
`client.users.getAll` to do so. This method will return an array of `User`
objects.
```js
client.users.getAll()
.then(users => {
for (let user of users) {
console.log(`Username: ${user.username}`);
}
});
```
#### client.users.delete - Delete a user
Deleting users using Huejay is simple. Provide either a username or `User`
object to `client.users.delete` to delete a user.
```js
client.users.delete('usernamehere')
.then(() => {
console.log('User was deleted');
})
.catch(error => {
console.log(error.stack);
});
```
### Bridge
Huejay supports retrieving and configuring the Philips Hue bridge. It supports
testing connection and authentication to the bridge as well.
#### client.bridge.ping - Test connection to the bridge
Use `client.bridge.ping` to test connection to your preferred bridge. Failed
connection results in a thrown `huejay.Error`.
```js
client.bridge.ping()
.then(() => {
console.log('Successful connection');
})
.catch(error => {
console.log('Could not connect');
});
```
#### client.bridge.isAuthenticated - Test authentication to the bridge
To ensure your supplied client username can authenticate to the bridge, use
`client.bridge.isAuthenticated`. Authentication or connection failure will
result `huejay.Error` being thrown.
```js
client.bridge.isAuthenticated()
.then(() => {
console.log('Successful authentication');
})
.catch(error => {
console.log('Could not authenticate');
});
```
#### client.bridge.get - Get bridge details and configuration
Want to get bridge details? Use Huejay's `client.bridge.get`
method. This will return a `Bridge` object, which can be used for reading
and saving configuration.
```js
client.bridge.get()
.then(bridge => {
console.log(`Retrieved bridge ${bridge.name}`);
console.log(' Id:', bridge.id);
console.log(' Model Id:', bridge.modelId);
console.log(' Model Name:', bridge.model.name);
});
```
Attributes available on the `Bridge` object:
- `id` - Unique
- `name` - Name of the bridge
- `modelId` - Model Id
- `model` - A `BridgeModel` object, containing details about the model
- `factoryNew` - Whether or not the bridge is factory new
- `replacesBridgeId` - Replaces bridge id (for migrating from old bridges)
- `dataStoreVersion` - Data store version
- `starterKitId` - Name of the starterkit created in the factory
- `softwareVersion` - Software version of the bridge
- `apiVersion` - API version of the bridge
- `zigbeeChannel` - ZigBee channel (for communicating with lights)
- `macAddress` - MAC address
- `ipAddress` - IP address
- `dhcpEnabled` - Whether or not DHCP is enabled
- `netmask` - Netmask
- `gateway` - Gateway
- `proxyAddress` - Proxy address
- `proxyPort` - Proxy port
- `utcTime` - UTC time of the bridge
- `timeZone` - Time zone
- `localTime` - Local time of the bridge
- `portalServicesEnabled` - Whether or not portal services are enabled
- `portalConnected` - Whether or not portal is connected
- `linkButtonEnabled` - Whether or not link button is enabled
- `touchlinkEnabled` - Whether or not Touchlink is enabled
The `Bridge` `model` attribute returns a `BridgeModel` object which contains
additional details about the model:
- `id` - Model Id, typically the same value as `Bridge` `modelId`
- `manufacturer` - Manufacturer (e.g. Philips)
- `name` - Name of the model / product (e.g. Hue v1, Hue v2)
#### client.bridge.save - Save bridge configuration
You can configure the bridge by changing values on the `Bridge` object and
passing to the `client.bridge.save` method. This method will return the same
`Bridge` for further manipulation.
```js
client.bridge.get()
.then(bridge => {
// Change bridge's name
bridge.name = 'New bridge name';
return client.bridge.save(bridge);
})
.then(bridge => {
console.log(`Bridge is now named ${bridge.name}`);
});
```
The following `Bridge` attributes are configurable:
- `name` - Name of the bridge
- `zigbeeChannel` - Preferred ZigBee channel
- `ipAddress` - IP address
- `dhcpEnabled` - `true` to enable, `false` to disable
- `netmask` - Netmask
- `gateway` - Gateway
- `proxyPort` - Proxy port
- `proxyAddress` - Proxy address
- `timeZone` - Any value available in `client.timeZones.getAll`
- `linkButtonEnabled` - `true` to toggle on temporarily
- `touchlinkEnabled` - `true` to toggle on temporarily
#### client.bridge.linkButton - Simulate link button press
Use this command with an authenticated user to simulate pressing the link
button. No need to physically press the button on your bridge for creating users
and other actions.
```js
client.bridge.linkButton()
.then(() => {
console.log('Link button was pressed');
});
```
#### client.bridge.touchlink - Enable Touchlink
Having issues pairing new lights to your bridge? Reset your bridge and can't
seem to find your existing lights? Use Huejay to enable Touchlink and steal
those lights back. This is commonly known in the community as "Lamp stealer".
Touchlink is enabled for roughly 30 seconds.
```js
client.bridge.touchlink()
.then(() => {
console.log('Touchlink is enabled');
});
```
You can set `touchlinkEnabled` on the `Bridge` object and save to achieve
the same effect as this command.
### Portal
The Philips Hue bridge allows connection to Philips' Meethue.com portal
services. You can use Meethue.com to remotely configure numerous resources
on your bridge, including lights, devices, and scenes.
Huejay provides a way to retrieve Meethue's portal connectivity details.
#### client.portal.get - Get portal details
Use `client.portal.get` to retrieve connectivity details. This method will
return a `Portal` object.
```js
client.portal.get()
.then(portal => {
console.log('Is signed on:', portal.signedOn);
console.log('Incoming:', portal.incoming);
console.log('Outgoing:', portal.outgoing);
console.log('Communication:', portal.communication);
});
```
### Software Update
Occasionally, Philips releases new updates for the bridge, lights, and devices.
You can use Huejay to facilitate downloading and installation of updates.
#### client.softwareUpdate.get - Get software update details
To get software update details, use the `client.softwareUpdate.get` method to
retrieve a `SoftwareUpdate` object. This object provides details about any
pending updates to the bridge or other resources.
```js
client.softwareUpdate.get()
.then(softwareUpdate => {
console.log('State:', softwareUpdate.state);
console.log('Release URL:', softwareUpdate.releaseUrl);
console.log('Release notes:', softwareUpdate.releaseNotes);
});
```
The following attributes are available on the `SoftwareUpdate` object:
- `state` - Update state, see below for values
- `checkingEnabled` - `true` if bridge is checking for updates, `false` if not
- `bridge` - `true` if updates are available for the bridge, `false` if not
- `lights` - An array of light ids with available updates
- `sensors` - An array of sensor ids with available updates
- `releaseUrl` - Release URL
- `releaseNotes` - Release notes
- `installNotificationEnabled` - Whether or not the install notification is enabled
The following are possible `state` values:
- `NO_UPDATE` - There are no updates available
- `DOWNLOADING` - Updates are being downloaded
- `READY_TO_INSTALL` - Updates are ready to be installed
- `INSTALLING` - Updates are installing
#### client.softwareUpdate.check - Make bridge check for software updates
You can request the bridge to check for software updates. Call the
`client.softwareUpdate.check` method to have the bridge start checking for
updates. A `huejay.Error` is thrown if the bridge is already checking.
```js
client.softwareUpdate.check()
.then(() => {
console.log('Bridge is checking for software updates');
});
```
#### client.softwareUpdate.install - Start installation of pending updates
If there are any pending software updates, you can use `client.softwareUpdate.install`
to install them. A `huejay.Error` is thrown if there are no updates to install.
```js
client.softwareUpdate.install()
.then(() => {
console.log('Installation has begun');
});
```
#### client.softwareUpdate.disableInstallNotification - Disables install notification
To disable the install notification (useful for mobile apps),
`client.softwareUpdate.disableInstallNotification` will allow you to turn off the
notification. This only works when the notification is enabled.
```js
client.softwareUpdate.disableInstallNotification()
.then(() => {
console.log('Install notification is now disabled');
});
```
### Internet Services
Interested in finding out what internet services are connected and functioning on your bridge?
#### client.internetServices.get - Get internet services details
Use this command for retrieving information about what internet services are connected.
```js
client.internetServices.get()
.then(internetServices => {
console.log(`Internet: ${internetServices.internetConnected}`);
console.log(`Remote access: ${internetServices.remoteAccessConnected}`);
console.log(`Time sync: ${internetServices.timeSyncConnected}`);
console.log(`Software update: ${internetServices.softwareUpdateConnected}`);
})
.catch(error => {
console.log(error.stack);
});
```
### Lights
The Philips Hue API exposes numerous endpoints for managing your lights. Huejay
supports it all, from searching and installing new lights, to changing light
attributes and state.
#### client.lights.scan - Scan for new lights
Hooked up a fresh Philips Hue bridge? Plugged in brand new bulbs or a fixture?
Before you can interact with your new lights, you'll need to add them to your
preferred bridge.
Huejay's `client.lights.scan` will get your bridge to start scanning for new,
unregistered lights. Scans last roughly 30 seconds. New bulbs can then be
retrieved by using `client.lights.getNew`.
```js
client.lights.scan()
.then(() => {
console.log('Started new light scan');
});
```
*Note: Make sure your bulbs are powered on for your bridge to find them.*
#### client.lights.getNew - Get new lights
When bulbs are freshly registered on the bridge, you can retrieve them using
`client.lights.getNew`. This command will ultimately return an array of `Light` objects.
```js
client.lights.getNew()
.then(lights => {
console.log('Found new lights:');
for (let light of lights) {
console.log(`Light [${light.id}]:`);
console.log(' Unique Id:', light.uniqueId);
console.log(' Model:', light.model.name);
console.log(' Reachable:', light.reachable);
}
});
```
More information on `Light` objects is available in the following commands below.
#### client.lights.getAll - Get all registered lights
Huejay's `client.lights.getAll` will return a list of all registered lights on
the bridge. Like `client.lights.getNew`, the result from the completed `Promise`
will be an array of `Light` objects.
```js
client.lights.getAll()
.then(lights => {
for (let light of lights) {
console.log(`Light [${light.id}]: ${light.name}`);
console.log(` Type: ${light.type}`);
console.log(` Unique ID: ${light.uniqueId}`);
console.log(` Manufacturer: ${light.manufacturer}`);
console.log(` Model Id: ${light.modelId}`);
console.log(' Model:');
console.log(` Id: ${light.model.id}`);
console.log(` Manufacturer: ${light.model.manufacturer}`);
console.log(` Name: ${light.model.name}`);
console.log(` Type: ${light.model.type}`);
console.log(` Color Gamut: ${light.model.colorGamut}`);
console.log(` Friends of Hue: ${light.model.friendsOfHue}`);
console.log(` Software Version: ${light.softwareVersion}`);
console.log(' State:');
console.log(` On: ${light.on}`);
console.log(` Reachable: ${light.reachable}`);
console.log(` Brightness: ${light.brightness}`);
console.log(` Color mode: ${light.colorMode}`);
console.log(` Hue: ${light.hue}`);
console.log(` Saturation: ${light.saturation}`);
console.log(` X/Y: ${light.xy[0]}, ${light.xy[1]}`);
console.log(` Color Temp: ${light.colorTemp}`);
console.log(` Alert: ${light.alert}`);
console.log(` Effect: ${light.effect}`);
console.log();
}
});
```
The following `Light` attributes are available:
- `id` - Numerical id of the light as registered on the bridge
- `name` - Configurable name for the light
- `type` - Type of light (e.g. Extended Color Light, Dimmable Light)
- `uniqueId` - Unique Id of the light
- `manufacturer` - Name of the manufacturer
- `modelId` - Model Id of the light, used for determining `LightModel`
- `model` - A `LightModel` object, containing details about the model (not available in other Node.js clients!)
- `productId` - Unique identifying hardware model (*Note: Not available for all lights*)
- `softwareVersion` - Software version of the light
- `softwareConfigId` - Software config id of the light (*Note: Not available for all lights*)
The following `Light` state is available:
- `on` - `true` if the light is on, `false` if not, configurable
- `reachable` - `true` if the light can be communicated with, `false` if not
- `brightness` - Configurable brightness of the light (value from 0 to 254)
- `colorMode` - Color mode light is respecting (e.g. ct, xy, hs)
- `hue` - Configurable hue of the light (value from 0 to 65535)
- `saturation` - Configurable saturation of the light, compliments `hue` (value from 0 to 254)
- `xy` - Configurable CIE x and y coordinates (value is an array containing x and y values)
- `colorTemp` - Configurable Mired Color temperature of the light (value from 153 to 500)
- `transitionTime` - Configurable temporary value which eases transition of an effect (value in seconds, 0 for instant, 5 for five seconds)
- `alert` - Configurable alert effect (e.g. none, select, lselect)
- `effect` - Configurable effect (e.g. none, colorloop)
There are additional `Light` state properties available for incrementing and
decrementing values:
- `incrementBrightness` - Increment or decrement brightness value
- `incrementHue` - Increment or decrement hue value
- `incrementSaturation` - Increment or decrement saturation value
- `incrementXy` - Increment or decrement xy values
- `incrementColorTemp` - Increment or decrement color temperature value
Huejay is the only Node.js client that maintains a list of Philips Hue supported
models. The `Light` `model` attribute returns a `LightModel` object which contains
additional details about the model:
- `id` - Model Id, typically the same value as `Light` `modelId`
- `manufacturer` - Manufacturer, typically the same value as `Light` `manufacturer`
- `name` - Name of the model / product (e.g. Hue Spot GU10)
- `type` - Type of light, typically the same value as `Light` `type`
- `colorGamut` - The supported color gamut of the light
- `friendsOfHue` - `true` if Friends of Hue, `false` if not
#### client.lights.getById - Get light by id
If only a single light is needed, `client.lights.getById` can be used to fetch
a light by its bridge assigned id. A `Light` object is returned if the light is
found, else a `huejay.Error` is thrown.
```js
client.lights.getById(1)
.then(light => {
console.log('Found light:');
console.log(` Light [${light.id}]: ${light.name}`);
})
.catch(error => {
console.log('Could not find light');
console.log(error.stack);
});
```
#### client.lights.save - Save a light's attributes and state
After retrieving a `Light` object through previous commands, you can configure
the light and save its attributes and state. This allows you to change a
light's name, color, effect, and so on. You can set various properties on a
`Light` object, and save them via `client.lights.save`.
Huejay is smart and keeps track of changed attributes and state. The client
will only send updated values to the Philips Hue bridge, as sending all
configurable attributes and state can affect bridge and light performance.
To save a light, pass a `Light` object to `client.lights.save`. The light is
returned after saving for convenient chaining.
```js
client.lights.getById(3)
.then(light => {
light.name = 'New light name';
light.brightness = 254;
light.hue = 32554;
light.saturation = 254;
return client.lights.save(light);
})
.then(light => {
console.log(`Updated light [${light.id}]`);
})
.catch(error => {
console.log('Something went wrong');
console.log(error.stack);
});
```
The following `Light` object attributes and state are configurable:
- `name`
- `on`
- `brightness`
- `hue`
- `saturation`
- `xy`
- `colorTemp`
- `transitionTime`
- `alert`
- `effect`
- `incrementBrightness`
- `incrementHue`
- `incrementSaturation`
- `incrementXy`
- `incrementColorTemp`
*Note: See further above for details on `Light` attributes and state*
#### client.lights.delete - Delete a light
Remove a light from the bridge with `client.lights.delete`. This will accept
either an id or a `Light` object.
```js
client.lights.delete(4)
.then(() => {
console.log('Light was deleted');
})
.catch(error => {
console.log('Light may have been removed already, or does not exist');
console.log(error.stack);
});
```
### Groups
The Philips Hue bridge offers the convenience of grouping lights. Rather than
setting individual light brightness, color, and other options, you can apply the
same changes on a group and have it applied to all linked lights. Huejay
provides a complete interface for managing groups on the bridge.
Groups may also represent multisource luminaires. Philips offers several products
which consist of several color changing lights. Upon registering one of these
products with the bridge, a new group is created which represents the logical
grouping of the included lights. Huejay offers a simple means of retrieving
luminaire production information, as well as configuration of these high-end
fixtures.
#### client.groups.getAll - Get all groups
Use `client.groups.getAll` to retrieve all groups created on the bridge. This
command eventually returns an array of `Group` objects. See further below for
`Group` object information.
```js
client.groups.getAll()
.then(groups => {
for (let group of groups) {
console.log(`Group [${group.id}]: ${group.name}`);
console.log(` Type: ${group.type}`);
console.log(` Class: ${group.class}`);
console.log(' Light Ids: ' + group.lightIds.join(', '));
console.log(' State:');
console.log(` Any on: ${group.anyOn}`);
console.log(` All on: ${group.allOn}`);
console.log(' Action:');
console.log(` On: ${group.on}`);
console.log(` Brightness: ${group.brightness}`);
console.log(` Color mode: ${group.colorMode}`);
console.log(` Hue: ${group.hue}`);
console.log(` Saturation: ${group.saturation}`);
console.log(` X/Y: ${group.xy[0]}, ${group.xy[1]}`);
console.log(` Color Temp: ${group.colorTemp}`);
console.log(` Alert: ${group.alert}`);
console.log(` Effect: ${group.effect}`);
if (group.modelId !== undefined) {
console.log(` Model Id: ${group.modelId}`);
console.log(` Unique Id: ${group.uniqueId}`);
console.log(' Model:');
console.log(` Id: ${group.model.id}`);
console.log(` Manufacturer: ${group.model.manufacturer}`);
console.log(` Name: ${group.model.name}`);
console.log(` Type: ${group.model.type}`);
}
console.log();
}
});
```
As demonstrated in the example above, group attributes, state, and actions are available
via `Group` objects.
Here are the following attributes and state available on `Group`:
- `id` - Group Id, generated automatically by the bridge
- `name` - Configurable name for the group
- `type` - Configurable type of group (e.g. LightGroup, Luminaire, LightSource, Room)
- `class` - When `type` is set to `Room`, a class (see below) is available and configurable (e.g. Living room, Office)
- `lightIds` - An array of light ids associated with the group
- `modelId` - Available only for multisource luminaires, this is the model id of the fixture
- `uniqueId` - Available only for multisource luminaires, this is the unique id of the fixture
- `model` - Available when `modelId` is present, a `GroupModel` object that contains details about the model
- `anyOn` - True if any lights in the group are on, false if none are on
- `allOn` - True if all lights in the group are on, false if not
Similar to `Light` objects, `Group` objects provide action options for
the lights associated with the group:
- `on` - `true` for lights on, `false` if not, configurable
- `brightness` - Configurable brightness for the lights (value from 0 to 254)
- `colorMode` - Color mode group is respecting (e.g. ct, xy, hs)
- `hue` - Configurable hue of the lights (value from 0 to 65535)
- `saturation` - Configurable saturation of the lights, compliments `hue` (value from 0 to 254)
- `xy` - Configurable CIE x and y coordinates (value is an array containing x and y values)
- `colorTemp` - Configurable Mired Color temperature of the lights (value from 153 to 500)
- `transitionTime` - Configurable temporary value which eases transition of an effect (value in seconds, 0 for instant, 5 for five seconds)
- `alert` - Configurable alert effect (e.g. none, select, lselect)
- `effect` - Configurable effect (e.g. none, colorloop)
- `scene` - Configurable scene
Like `Light` objects, `Group` action properties are available for incrementing and
decrementing values:
- `incrementBrightness` - Increment or decrement brightness value
- `incrementHue` - Increment or decrement hue value
- `incrementSaturation` - Increment or decrement saturation value
- `incrementXy` - Increment or decrement xy values
- `incrementColorTemp` - Increment or decrement color temperature value
Huejay maintains a list of Philips Hue supported luminaire models. The `Group`
`model` attribute returns a `GroupModel` object. This object contains more
information about the model:
- `id` - Model Id, typically the same value as `Group` `modelId`
- `manufacturer` - Manufacturer of the model (e.g. Philips)
- `name` - Name of the model / product (e.g. Hue Beyond Table)
- `type` - Type of group, typically the same value as `Group` `type`
When a `Group`'s `type` is `Room`, the following classes can be associated with the group:
Class | ...
------------ | ------------
Living room | Gym
Kitchen | Hallway
Dining | Toilet
Bathroom | Front door
Bedroom | Garage
Kids bedroom | Terrace
Nursery | Garden
Recreation | Driveway
Office | Other
Carport |
*Note: The `client.groups.getAll` command does not return special group 0.
See `client.groups.getById` for instructions on retrieving this special group.*
#### client.groups.getById - Get group by id
Need a specific group? `client.groups.getById` accepts a group id. If a group
exists with that id, a `Group` object is returned, else a `huejay.Error` is
thrown.
```js
client.groups.getById(3)
.then(group => {
console.log('Found group:');
console.log(` Group [${group.id}]: ${group.name}`);
})
.catch(error => {
console.log('Could not find group');
console.log(error.stack);
});
```
A **special group** is available which is accessible via group id **0**. This
group always contains all light ids registered on the bridge. Use this group
to control all lights at once.
```js
client.groups.getById(0)
.then(group => {
console.log('Special group 0');
console.log(' Light Ids:', group.lightIds.join(', '));
});
```
#### client.groups.create - Create a group
Creating a group is easy using Huejay. Instantiate a new `client.groups.Group`
object and set both a name and list of light ids.
```js
let group = new client.groups.Group;
group.name = 'New group';
group.lightIds = [2, 4, 5];
client.groups.create(group)
.then(group => {
console.log(`Group [${group.id}] created`);
})
.catch(error => {
console.log(error.stack);
});
```
*Note: Action is not saved on group creation. You must save the group after
creation if action is configured.*
#### client.groups.save - Save a group's attributes and action
You can modify a `Group`'s attributes and action after creation/retrieval, and
then apply the changes on the bridge. Like `Light` objects, Huejay will only
apply deltas when saving groups.
To apply changes, use `client.groups.save`. The `Group` object is returned upon
save completion.
```js
client.groups.getById(6)
.then(group => {
group.name = 'Brand new name';
group.lightIds = [4, 6, 8];
group.on = true;
group.brightness = 254;
group.effect = 'colorloop';
return client.groups.save(group);
})
.then(group => {
console.log(`Group [${group.id}] was saved`);
})
.catch(error => {
console.log(error.stack);
});
```
The following `Group` object attributes and action are configurable:
- `name`
- `lightIds`
- `on`
- `brightness`
- `hue`
- `saturation`
- `xy`
- `colorTemp`
- `transitionTime`
- `alert`
- `effect`
- `incrementBrightness`
- `incrementHue`
- `incrementSaturation`
- `incrementXy`
- `incrementColorTemp`
#### client.groups.delete - Delete a group
To delete a group from the bridge, pass a group id or `Group` object to
`client.groups.delete`.
```js
client.groups.delete(3)
.then(() => {
console.log('Group was deleted');
})
.catch(error => {
console.log('Group may have been removed already, or does not exist');
console.log(error.stack);
});
```
*Note: It is not possible to delete multisource groups. Expect a `huejay.Error`
to be thrown if attempting to do so.*
### Schedules
Huejay makes it extremely simple to add scheduling to your bridge. Huejay is
the only client that abstracts the complicated bits of configuring commands and
timers for scheduled operations.
#### client.schedules.getAll - Retrieve all schedules
Retrieve all registered schedules on the bridge with `client.schedules.getAll`.
This command eventually returns a list of `Schedule` objects.
```js
client.schedules.getAll()
.then(schedules => {
for (let schedule of schedules) {
console.log(`Schedule [${schedule.id}]: ${schedule.name}`);
console.log(` Description: ${schedule.description}`);
console.log(` Created: ${schedule.created}`);
console.log(` Local time: ${schedule.localTime}`);
console.log(` Status: ${schedule.status}`);
console.log(` Auto delete: ${Boolean(schedule.autoDelete)}`);
console.log(` Action:`);
console.log(` Method: ${schedule.action.method}`);
console.log(` Address: ${schedule.action.address}`);
console.log(` Body: ${JSON.stringify(schedule.action.body)}`);
console.log();
}
});
```
`Schedule` objects are composed of the following attributes:
- `id` - Schedule Id, generated and assigned by the bridge on creation
- `name` - Name for the schedule, configurable
- `description` - Description for the schedule, configurable
- `created` - Date when schedule was created
- `localTime` - Configurable scheduled time, configurable, behavior differs by pattern
- `status` - `enabled` or `disabled`, configurable
- `autoDelete` - `true` or `false`, schedule is automatically deleted on expiration when `true`, configurable
- `action` - Hue native object representing the action to fire for the schedule, configurable
#### client.schedules.getById - Retrieve schedule by id
Use `client.schedules.getById` to retrieve a single schedule by id. A `Schedule`
object is eventually returned if found.
```js
client.schedules.getById(12)
.then(schedule => {
console.log(`Found schedule [${schedule.id}]: ${schedule.name}`);
})
.catch(error => {
console.log('Could not find schedule');
console.log(error.stack);
});
```
#### client.schedules.create - Create a schedule
Huejay is the only Hue client that takes a lot of the guesswork out of manual
schedule creation. Other clients require you to know how the Philips Hue
schedules API works in order to create them.
```js
client.lights.getById(1)
.then(light => {
light.brightness = 1;
let schedule = new client.schedules.Schedule;
schedule.name = 'Schedule name';
schedule.description = 'Sets light brightness to 1 on December 25, 2016 09:00pm';
schedule.localTime = new client.timePatterns.AbsoluteTime('2016-12-25 21:00:00');
schedule.action = new client.actions.ChangeLightState(light);
return client.schedules.create(schedule);
})
.then(schedule => {
console.log(`Schedule [${schedule.id}] created`);
})
.then(error => console.log(error.stack));
```
To simplify configuring `localTime` and `action` attributes on `Schedule`
objects, use Huejay's provided time patterns and actions.
##### Time Patterns
Huejay provides a way to easily generating Hue compatible time patterns for
scheduling. Use these time pattern helpers for generating a compatible `localTime`
to `Schedule` objects. Be sure to configure your preferred *time zone* of choice
on the bridge.
Here are the time patterns available in Huejay:
###### Time Pattern: Absolute Time
Generate a specific date. When the bridge reaches this date, the scheduled action
is invoked.
```js
schedule.localTime = new client.timePatterns.AbsoluteTime('2016-12-30 12:00:00');
```
###### Time Pattern: Randomized Time
Generate a specific date with a random element. When the bridge reaches this date,
the scheduled action is invoked randomly between 0 and X seconds.
```js
schedule.localTime = new client.timePatterns.RandomizedTime(
'2016-12-30 12:00:00',
3600 // Seconds (3600 is one hour)
);
```
###### Time Pattern: Recurring Time
Generate a recurring weekly date. The bridge will invoke the action on each day
configured, at the specific time set.
This time pattern accepts a list of days as a combined integer. Huejay provides
human readable equivalents which can be combined via *bitwise or*.
```js
// Run action on Mondays, Saturdays, Sundays at 09:00:00
schedule.localTime = new client.timePatterns.RecurringTime(
client.timePatterns.RecurringTime.MONDAY | client.timePatterns.RecurringTime.WEEKEND,
'09:00:00'
);
// Available days (these values may move in the future)
client.timePatterns.RecurringTime.MONDAY; // Monday
client.timePatterns.RecurringTime.TUESDAY; // Tuesday
client.timePatterns.RecurringTime.WEDNESDAY; // Wednesday
client.timePatterns.RecurringTime.THURSDAY; // Thursday
client.timePatterns.RecurringTime.FRIDAY; // Friday
client.timePatterns.RecurringTime.SATURDAY; // Saturday
client.timePatterns.RecurringTime.SUNDAY; // Sunday
client.timePatterns.RecurringTime.WEEKDAY; // Monday through Friday
client.timePatterns.RecurringTime.WEEKEND; // Saturday and Sunday
```
###### Time Pattern: Timer
Generate a timer with the option to repeat.
```js
// Run action in 1 minute
schedule.localTime = new client.timePatterns.Timer(60);
// Run action in 30 seconds, cycling through timer 5 times
schedule.localTime = new client.timePatterns.Timer(30, 5);
```
##### Actions
Huejay assists in building actions for scheduling and rules. You can access
these actions via `client.actions`.
The following are actions available in Huejay:
###### Action: Change Light State
This action builds the necessary command for changing light state.
```js
// Retrieve a Light object and change state
light.brightness = 254;
light.colorTemp = 160;
light.transitionTime = 0.5;
// Instantiate action for use with Schedule or Rule objects
// This will determine changed state for the action
schedule.action = new client.actions.ChangeLightState(light);
// Instantiate with optional argument to force retrieve state
schedule.action = new client.actions.ChangeLightState(light, ['brightness']);
```
###### Action: Change Group Action
This action helps build command for changing group action.
```js
// Retrieve a Group object and change action
group.scene = '123456abc';
// Instantiate action for use with Schedule or Rule objects
// This will determine changed action for the action
schedule.action = new client.actions.ChangeGroupAction(group);
// Instantiate with optional argument to force retrieve action
schedule.action = new client.actions.ChangeGroupAction(group, ['scene', 'brightness']);
```
###### Action: Change Sensor State
This action assists with changing sensor state.
```js
// Retrieve a Sensor object and change state
sensor.state.status = 1;
// Instantiate action for use with Schedule or Rule objects
// This will determine changed action for the action
schedule.action = new client.actions.ChangeSensorState(sensor);
// Instantiate with optional argument to force retrieve state
schedule.action = new client.actions.ChangeSensorState(sensor, ['status']);
```
#### client.schedules.save - Save schedule
Schedules can be modified and saved. Pass a `Schedule` object to
`client.schedules.save` to update schedule attributes.
```js
client.schedules.getById(12)
.then(schedule => {
schedule.name = 'New schedule name';
schedule.localTime = new client.timePatterns.Timer(3600);
return client.groups.getById(5)
.then(group => {
group.scene = '123456abcd';
schedule.action = new client.actions.ChangeGroupAction(group);
return client.schedules.save(schedule);
});
})
.catch(error => console.log(error.stack));
```
The following attributes are modifiable:
- name
- description
- localTime
- status
- autoDelete
- action
#### client.schedules.delete - Delete a schedule
All it takes to delete a schedule from the bridge is to provide either a
schedule id or a `Schedule` object to the `client.schedules.delete` command.
```js
client.schedules.delete('12')
.then(() => {
console.log('Schedule was deleted');
})
.catch(error => {
console.log('Schedule may have been removed already, or does not exist');
console.log(error.stack);
});
```
*Note: Schedules may be auto-deleted by the bridge. You can see which schedules
are configured to auto-delete via `Schedule` object `autoDelete` flag.*
### Scenes
Huejay supports managing scenes on the Philips Hue. Scenes are the best way of
storing and recalling commonly used light configurations in your home.
*Note: To recall a scene, set the `scene` attribute on a `Group` object and save.
Alternatively, use the `client.scenes.recall` command.*
#### client.scenes.getAll - Retrieve all scenes
Retrieves all scenes from the bridge. This command returns an array of `Scene`
objects.
```js
client.scenes.getAll()
.then(scenes => {
for (let scene of scenes) {
console.log(`Scene [${scene.id}]: ${scene.name}`);
console.log(' Lights:', scene.lightIds.join(', '));
console.log();
}
});
```
`Scene` objects are composed of the following attributes:
- `id` - User/application defined scene id (e.g. my-scene-id)
- `name` - Configurable name
- `lightIds` - Configurable array of associated light ids
- `owner` - User who created the scene
- `recycle` - Configurable option which will auto delete the scene
- `locked` - If `true`, scene is not deletable as it is being used by another resource
- `appData` - A configurable object consisting of `version` and `data` properties
- `picture` - Future field, probably storing picture URL
- `lastUpdated` - Date when scene was last updated
- `captureLightState` - Set to `true` to capture current light state for the scene
- `transitionTime` - Always `null` on access, but can be configured
The following methods are available on `Scene` objects:
- `getLightState(lightId)` - Get light state by light id. Values only available by `getById`.
- `setLightState(lightId, {property: 'value'})` - Set light state by light id.
#### client.scenes.getById - Retrieve scene by id
Retrieve a single scene by id. If the scene is not available, a `huejay.Error`
is thrown.
```js
client.scenes.getById('123456abcdef')
.then(scene => {
console.log(`Scene [${scene.id}]: ${scene.name}`);
console.log(' Lights:', scene.lightIds.join(', '));
console.log();
})
.catch(error => {
console.log(error.stack);
});
```
#### client.scenes.create - Create a scene
Scene creation is a breeze. Instantiate a new `client.scenes.Scene`, set a name,
lightIds, other attributes, and pass to `client.scenes.create`.
```js
let scene = new client.scenes.Scene;
scene.name = 'Scene name';
scene.lightIds = [1, 2, 3];
scene.recycle = false;
scene.appData = {version: 1, data: 'optional app data'};
scene.transitionTime = 2;
client.scenes.create(scene)
.then(scene => {
console.log(`Scene [${scene.id}] created...`);
console.log(' Name:', scene.name);
console.log(' Lights:', scene.lightIds.join(', '));
console.log(' Owner:', scene.owner);
console.log(' Recycle:', scene.recycle);
console.log(' Locked:', scene.locked);
console.log(' App data:', scene.appData);
console.log(' Picture:', scene.picture);
console.log(' Last Updated:', scene.lastUpdated);
console.log(' Version:', scene.version);
})
.catch(error => {
console.log(error.stack);
});
```
These `Scene` object attributes can be configured for creation:
- `name`
- `lightIds`
- `recycle`
- `appData`
- `captureLightState`
#### client.scenes.save - Save a scene
`Scene` objects can be reconfigured and saved using `client.scenes.save`. Light
states can be configured with this command.
```js
client.scenes.getById('123456abcdef')
.then(scene => {
scene.name = 'New scene name';
scene.lightIds = [9, 10];
// Set light state for light id 9
scene.setLightState(9, {
brightness: 254,
colorTemp: 250,
});
// Set light state for light id 10
scene.setLightState(10, {
brightness: 128,
colorTemp: 300,
effect: 'colorloop',
});
return client.scenes.save(scene)
})
.then(scene => {
console.log(`Scene saved...`);
})
.catch(error => {
console.log(error.stack);
});
```
#### client.scenes.recall - Recall a scene
Recall a scene using the convenience command `client.scenes.recall`. Pass a
`Scene` object or scene id to recall the scene.
```js
client.scenes.recall('123456abcdef')
.then(() => {
console.log('Scene was recalled');
})
.catch(error => {
console.log(error.stack);
});
```
#### client.scenes.delete - Delete a scene
To delete a scene, provide a scene id or `Scene` object to
`client.scenes.delete`.
```js
client.scenes.delete('123456abcdef')
.then(() => {
console.log('Scene was deleted');
})
.catch(error => {
console.log('Scene may have been removed already, or does not exist');
console.log(error.stack);
});
```
*Note: Scenes being used or referenced by other resources may not be deleted.*
### Sensors
Buy a Hue Tap or Dimmer Switch and want to configure these add-ons without the
Philips Hue app? Want to create your own virtual sensors for customizable flags
and values to invoke light effects? Use Huejay's set of sensor commands to do
so.
#### client.sensors.scan - Scan for new sensors
This command is useful for finding new sensors/devices not yet registered with
your bridge. Remember to enable pairing mode on the device before calling
`client.sensors.scan`.
The bridge scans for new sensors for 30 seconds before stopping.
```js
client.sensors.scan()
.then(() => {
console.log('Started new sensor scan');
});
```
#### client.sensors.getNew - Get new sensors
After running `client.sensors.scan`, you can use `client.sensors.getNew` to
retrieve a list of newly registered sensors. An array of `Sensor` objects is
returned.
```js
client.sensors.getNew()
.then(sensors => {
console.log('Found new sensors:');
for (let sensor of sensors) {
console.log(`Sensor [${sensor.id}]:`);
console.log(' Unique Id:', sensor.uniqueId);
console.log(' Model:', sensor.model.name);
}
});
```
See below for more information on `Sensor` objects.
#### client.sensors.getAll - Get all sensors
Retrieve all sensors registered to the bridge with `client.sensors.getAll`. This
command will eventually return an array of `Sensor` objects.
```js
client.sensors.getAll()
.then(sensors => {
for (let sensor of sensors) {
console.log(`Sensor [${sensor.id}]: ${sensor.name}`);
console.log(` Type: ${sensor.type}`);
console.log(` Manufacturer: ${sensor.manufacturer}`);
console.log(` Model Id: ${sensor.modelId}`);
console.log(' Model:');
console.log(` Id: ${sensor.model.id}`);
console.log(` Manufacturer: ${sensor.model.manufacturer}`);
console.log(` Name: ${sensor.model.name}`);
console.log(` Type: ${sensor.model.type}`);
console.log(` Software Version: ${sensor.softwareVersion}`);
console.log(` Unique Id: ${sensor.uniqueId}`);
console.log(` Config:`);
console.log(` On: ${sensor.config.on}`);
console.log(` State:`);
console.log(` Last Updated: ${sensor.state.lastUpdated}`);
console.log();
}
})
.catch(error => {
console.log(error.stack);
});
```
`Sensor` objects consist of the following attributes:
- `id` - Numerical id of the sensor as registered on the bridge
- `name` - Configurable name for the sensor
- `type` - Sensor type (e.g. Daylight, CLIPTemperature, ZGPSwitch)
- `modelId` - Model Id of the sensor, used for determining `SensorModel`
- `model` - A `SensorModel` object, containing details about the model
- `productId` - Unique identifying hardware model (*Note: Not available for all sensors*)
- `softwareVersion` - Software version of the sensor
- `softwareConfigId` - Software config id of the light (*Note: Not available for all sensors*)
- `uniqueId` - Unique Id of the sensor (typically hardware id)
- `config` - An object with configurable attributes (dependent on sensor type)
- `state` An object with state attributes (dependent on sensor type)
The `model` attribute on `Sensor` objects include:
- `id` - Model Id, typically the same value as `Sensor` `modelId`
- `manufacturer` - Manufacturer, typically the same value as `Sensor` `manufacturer`
- `name` - Name of the model / product
- `type` - Type of the sensor, typically the same value as `Sensor` `type`
Support values for `Sensor` `type` includes the following:
- CLIPGenericFlag
- CLIPGenericStatus
- CLIPHumidity
- CLIPOpenClose
- CLIPPresence
- CLIPSwitch
- CLIPTemperature
Configuration for `Sensor` objects is available via the `config` attribute.
This object contains configurable attributes for the sensor, and may be different
for each `Sensor` `type`. See [sensor types](lib/SensorType) for available
configuration for each sensor type.
The following `config` attributes are available for all sensor types:
- `on` - `true` to enable the sensor, `false` to not, configurable
State for the `Sensor` objects is accessible via the `state` attribute. Like
configuration, the contents of the `state` object may be different for each
`Sensor` `type`. Rules can be configured to react to sensor state changes.
See [sensor types](lib/SensorType) for available state for all supported sensor
types.
The following `state` attributes are available for all sensor types:
- `lastUpdated` - Time the sensor state last changed
#### client.sensors.getById - Get sensor by id
A single sensor can be fetched by way of `client.sensors.getById`. If the sensor
is available A `Sensor` object is returned if one matching the id is found,
otherwise a `huejay.Error` is thrown.
```js
client.sensors.getById(1)
.then(sensor => {
console.log('Found sensor:');
console.log(` Sensor [${sensor.id}]: ${sensor.name}`);
})
.catch(error => {
console.log('Could not find sensor');
console.log(error.stack);
});
```
#### client.sensors.create - Create a sensor
Want to register your own virtual sensor with the bridge? Use the
`client.sensors.create` command to create a custom sensor.
```js
let sensor = new client.sensors.Sensor;
// Set base sensor attributes
sensor.name = 'My temp sensor';
sensor.modelId = 'Custom model id';
sensor.softwareVersion = '0.0.1';
sensor.type = 'CLIPTemperature';
sensor.uniqueId = '00:11:22';
sensor.manufacturer = 'Huejay';
// Set sensor configuration
sensor.config.on = true;
// Set sensor state
sensor.state.temperature = 10.2; // Temperature in Celsius
// Create the sensor
client.sensors.create(sensor)
.then(sensor => {
console.log(`New sensor [${sensor.id}] created`);
})
.catch(error => {
console.log('Issue creating sensor');
console.log(error.stack);
});
```
`config` and `state` attributes differ for each `Sensor` `type`. See above
for more details.
#### client.sensors.save - Save a sensor
Sensor attributes, configuration, and state can be changed after registration
with the bridge (either through `client.sensors.scan` or `client.sensors.create`).
To save changes made to a `Sensor` object, pass the `Sensor` to `client.sensors.save`.
Huejay is intelligent enough to save only changed attributes, config, and state.
```js
client.sensors.getById(8)
.then(sensor => {
sensor.name = 'My updated sensor';
// Set sensor configuration
sensor.config.on = false;
// Set state
sensor.state.temperature = 28.5; // Temperature in Celsius
return client.sensors.save(sensor);
})
.then(sensor => {
console.log(`Sensor [${sensor.id}] was saved`);
})
.catch(error => {
console.log(error.stack);
});
```
#### client.sensors.delete - Delete a sensor
Delete a sensor from the bridge by passing an id or `Sensor` object to
`client.sensors.delete`.
```js
client.sensors.delete(8)
.then(() => {
console.log('Sensor was deleted');
})
.catch(error => {
console.log('Sensor may have been removed already, or does not exist');
console.log(error.stack);
});
```
### Rules
After sensors are registered with the bridge, rules may be created to react
to sensor state changes. For example, if the temperature changes on a sensor,
or a button is pressed, you may want a light (or even a group of lights) to
change color. Rules satisfy this.
#### client.rules.getAll - Get all rules
Use `client.rules.getAll` to retrieve all rules. This will eventually return
an array of `Rule` objects.
```js
client.rules.getAll()
.then(rules => {
for (let rule of rules) {
console.log(`Rule [${rule.id}]: ${rule.name}`);
console.log(` Created: ${rule.created}`);
console.log(` Last Triggered: ${rule.lastTriggered}`);
console.log(` Times Triggered: ${rule.timesTriggered}`);
console.log(` Owner: ${rule.owner}`);
console.log(` Status: ${rule.status}`);
console.log(` Conditions:`);
for (let condition of rule.conditions) {
console.log(` Address: ${condition.address}`);
console.log(` Operator: ${condition.operator}`);
console.log(` Value: ${condition.value}`);
console.log();
}
console.log(` Actions:`);
for (let action of rule.actions) {
console.log(` Address: ${action.address}`);
console.log(` Method: ${action.method}`);
console.log(` Body: ${JSON.stringify(action.body)}`);
console.log();
}
console.log();
}
});
```
`Rule` objects contain the following attributes:
- `id` - Numerical id of the rule, assigned by the bridge on creation
- `name` - Name of the rule, configurable
- `lastTriggered` - Date last time rule was triggered
- `timesTriggered` - Number of times rule was triggered
- `owner` - User who created the rule
- `status` - `enabled` or `disabled`, rule is triggerable on `enabled`, configurable
- `conditions` - An array of objects representing conditions, configurable
- `actions` - An array of objects representing actions, configurable
`Rule` `conditions` have the following attributes:
- `address` - The sensor resource/state location for the condition
- `operator` - The operator for the condition, described below
- `value` - The value used in conjunction with `operator`
`Rule` `actions` attributes:
- `address` - The actionable resource location
- `method` - Type of method for the action (e.g. GET, PUT)
- `body` - The body of the action, an object
There are several operators available for use with conditions:
- `gt` - Greater than: condition is satisfied when sensor state is greater than condition's `value`
- `lt` - Less than: condition is satisfied when sensor state is less than condition's `value`
- `eq` - Equal to: condition is satisfied when sensor state equals the condition's `value`
- `dx` - Changed: condition is satisfied when sensor state changes to a different value
- `ddx` - Delayed changed: condition is satisfied when sensor delayed state changes to a different value
- `stable` - Stable: condition is satisfied when sensor state is stable for condition's `value`
- `not stable` - Not stable: condition is satisfied when sensor state is not stable for condition's `value`
- `in` - In: Condition is satisfied when time is within start/end time
- `not in` - Not in: Condition is satisfied when time is not within start/end time
*Note: Huejay abstracts the raw operator values on creating conditions.*
#### client.rules.getById - Get by id
Get a single rule with `client.rules.getById`. A `Rule` object is eventually
returned if one is found with the provided id.
```js
client.rules.getById(3)
.then(rule => {
console.log(`Found: Rule [${rule.id}] - ${rule.name}`);
})
.catch(error => console.log(error.stack));
```
#### client.rules.create - Create a rule
Unlike other clients, Huejay reduces the complexity of creating rules on the
bridge. Supply a `Rule` object to `client.rules.create` to create a brand new
rule.
A rule must contain at least 1 condition and 1 action to be created. Use the
`addCondition` method for adding conditions, and the `addAction` method to add
actions (using the same actions available for schedules).
```js
// Retrieve sensor and group for configuring rule
Promise.all([
client.sensors.getById(31),
client.groups.getById(0),
])
.then(results => {
let sensor = results[0];
let group = results[1];
// Configure group light state to off (this will be used for rule action)
group.on = false;
// Build rule
let rule = new client.rules.Rule;
rule.name = 'My rule: All lights off on 42';
rule.status = 'enabled'; // Optional, defaults to 'enabled'
// Add 2 conditions to the rule (both must be satisfied to trigger rule)
rule.addCondition(sensor).when('buttonEvent').equals(42);
rule.addCondition(sensor).when('lastUpdated').changes();
// Add an action to invoke when rule is triggered
rule.addAction(new client.actions.ChangeGroupAction(group));
return client.rules.create(rule);
})
.then(rule => {
console.log(`Rule [${rule.id}] created...`);
})
.catch(error => console.log(error.stack));
```
The `addCondition` helper method makes adding conditions to rules easy. This
method returns a `Condition` object, which includes several chainable
methods for configuring a condition. A `Sensor` object is required to use
this helper due to the state field needing to be translated to the type's native
field format.
```js
// Greater than (gt) operator
rule.addCondition(sensor).when('state1').greaterThan(10);
// Less than (lt) operator
rule.addCondition(sensor).when('state2').lessThan(5);
// Equals (eq) operator
rule.addCondition(sensor).when('state3').equals(true);
// Changes (dx) operator
rule.addCondition(sensor).when('state4').changes();
```
*Note: Rules support a maximum of 8 conditions, and a maximum of 8 actions.
A minimum of 1 condition and 1 action is required for creating and saving
a rule.*
#### client.rules.save - Save a rule
Need to make a modification to an existing rule? Use the `client.rules.save`
command to save a rule. More conditions and actions can be added to a rule
prior to saving as well.
```js
client.rules.getById(4)
.then(rule => {
// Change rule name and disable
rule.name = 'New rule name';
rule.status = 'disabled';
return client.rules.save(rule);
})
.catch(error => console.log(error.stack));
```
The following `Rule` object attributes can be saved:
- `name`
- `status`
- `conditions`
- `actions`
It is possible to clear existing conditions and actions on a rule for providing
a new set of conditions and actions.
```js
client.rules.getById(4)
.then(rule => {
// Clears conditions on the rule
rule.clearConditions();
// Clears actions on the rule
rule.clearActions();
// Add conditions and actions here.
});
```
#### client.rules.delete - Delete a rule
To remove a rule, pass either a `Rule` object or a rule id to the
`client.rules.delete` command.
```js
client.rules.delete(3)
.then(() => {
console.log('Rule was deleted');
})
.catch(error => {
console.log('Rule may have been removed already, or does not exist');
console.log(error.stack);
});
```
### Resource Links
Want a way to group together various resources on the bridge? Resource Links
are used to combine various resources (lights, groups, schedules, etc).
*Note: Huejay's API for managing resource links is not yet finalized.*
#### client.resourceLinks.getAll - Get all resource links
`client.resourceLinks.getAll` can be used to retrieve all resource links from
the bridge, which will return a list of `ResourceLink` objects via a promise.
```js
client.resourceLinks.getAll()
.then(resourceLinks => {
for (let resourceLink of resourceLinks) {
console.log(`Resource Link [${resourceLink.id}]:`, resourceLink.name);
console.log(` Description: ${resourceLink.description}`);
console.log(` Type: ${resourceLink.type}`);
console.log(` Class Id: ${resourceLink.classId}`);
console.log(` Owner: ${resourceLink.owner}`);
console.log(` Recycle: ${resourceLink.recycle}`);
console.log(` Links: ${resourceLink.links}`);
console.log();
}
})
.catch(error => {
console.log(error.stack);
});
```
#### client.resourceLinks.getById - Get by id
To retrieve a single resource link, use `client.resourceLinks.getById`. This command
will eventually a return a `ResourceLink` object if found by provided resource
link id.
```js
client.resourceLinks.getById(12345)
.then(resourceLink => {
console.log(`Found: Resource Link [${resourceLink.id}] - ${resourceLink.name}`);
})
.catch(error => console.log(error.stack));
```
#### client.resourceLinks.create - Create a resource link
Create resource links using the `client.resourceLinks.create` command.
```js
let resourceLink = new client.resourceLinks.ResourceLink;
// Set resource link attributes
resourceLink.name = 'Resource link name here';
resourceLink.description = 'Resource link description here';
resourceLink.classId = 1;
resourceLink.links = ['/groups/1'];
// Create the resource link
client.resourceLinks.create(resourceLink)
.then(sensor => {
console.log(`New resource link [${resourceLink.id}] created`);
})
.catch(error => {
console.log('Issue creating resource link');
console.log(error.stack);
});
```
#### client.resourceLinks.save - Save a resource link
Resource links can be modified. There is a limited set of attributes that
can be saved on these objects. Use `client.resourceLinks.save` to save an
existing resource link.
```js
client.resourceLinks.getById(12345)
.then(resourceLink => {
// Change resource link name, description, and link set
resourceLink.name = 'New resource link name';
resourceLink.description = 'New description';
resourceLink.links = ['/groups/1', '/groups/2'];
return client.resourceLinks.save(resourceLink);
})
.catch(error => console.log(error.stack));
```
The following `ResourceLink` object attributes can be saved:
- `name`
- `description`
- `links`
#### client.resourceLinks.delete - Delete a resource link
Resource links can be deleted using the `client.resourceLinks.delete` command.
```js
client.resourceLinks.delete(12345)
.then(() => {
console.log('Resource link was deleted');
})
.catch(error => {
console.log('Resource link may have been removed already, or does not exist');
console.log(error.stack);
});
```
### Capabilities
Get bridge resource limits and timezones.
#### client.capabilities.lights
Retrieve bridge light limits with the command `client.capabilities.lights`.
This command will eventually return an object describe the limits of the bridge
around the light resource.
```js
client.capabilities.lights()
.then(lights => {
console.log('Lights:');
console.log(` Available light slots: ${lights.available}`);
})
.catch(error => {
console.log(error.stack);
});
```
You can retrieve additional information about other bridge capabilities with
the following commands:
- `client.capabilities.sensors`
- `client.capabilities.groups`
- `client.capabilities.scenes`
- `client.capabilities.schedules`
- `client.capabilities.rules`
- `client.capabilities.resourceLinks`
#### client.capabilities.getTimeZones
Retrieve a list of supported time zones by calling `client.capabilities.getTimeZones`.
```js
client.capabilities.getAll()
.then(timeZones => {
for (let timeZone of timeZones) {
console.log(timeZone);
}
});
```
### Time Zones
The Philips Hue bridge supports configuring a local time zone. This is useful
for scheduling functions. Numerous time zones are registered on the bridge for
retrieval.
#### client.timeZones.getAll - Get all time zones
You can retrieve a list of supported time zones by calling
`client.timeZones.getAll`. This will return an array of string values.
```js
client.timeZones.getAll()
.then(timeZones => {
for (let timeZone of timeZones) {
console.log(timeZone);
}
});
```
## Examples
Want to see more examples? View them in the [examples](examples) directory included
in this repository.
## Logo
Huejay's initial logo was designed by scorpion6 on Fiverr. Font used is Lato Bold.
## Additional Resources
Looking for more Philips Hue resources?
- [Philips Hue Product Page](http://www2.meethue.com/en-us/)
- [Philips Hue Store](https://www.store.meethue.com/us)
- [Hue Portal](https://my.meethue.com/en-us/)
- [Philips Hue Official Documentation](http://www.developers.meethue.com)
- [Philips Hue Release Notes](http://www2.meethue.com/en-us/release-notes/)
- [Reddit Hue Subreddit](https://www.reddit.com/r/hue)
- [SqMK's Philips Hue client for PHP](https://github.com/sqmk/Phue)
## License
This software is licensed under the MIT License. [View the license](LICENSE).
Copyright © 2015-2016 [Michael K. Squires](http://sqmk.com)
================================================
FILE: examples/.gitignore
================================================
/.credentials.json
================================================
FILE: examples/bridge/get-bridge.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Retrieving bridge (${client.host})...`);
client.bridge.get()
.then(bridge => {
console.log(`Bridge:`);
console.log(` Id: ${bridge.id}`);
console.log(` Name: ${bridge.name}`);
console.log(` Model Id: ${bridge.modelId}`);
console.log(` Factory new: ${bridge.factoryNew}`);
console.log(` Replaces bridge: ${bridge.replacesBridgeId}`);
console.log(` Date Store Version: ${bridge.dataStoreVersion}`);
console.log(` Starter Kit Id: ${bridge.starterKitId}`);
console.log();
console.log(`Model:`);
console.log(` Id: ${bridge.model.id}`);
console.log(` Manufacturer: ${bridge.model.manufacturer}`);
console.log(` Name: ${bridge.model.name}`);
console.log();
console.log(`Versions:`);
console.log(` Software Version: ${bridge.softwareVersion}`);
console.log(` API Version: ${bridge.apiVersion}`);
console.log();
console.log(`Zigbee:`);
console.log(` Channel: ${bridge.zigbeeChannel}`);
console.log();
console.log(`Network details:`);
console.log(` MAC Address: ${bridge.macAddress}`);
console.log(` IP Address: ${bridge.ipAddress}`);
console.log(` DHCP enabled: ${bridge.dhcpEnabled}`);
console.log(` Netmask: ${bridge.netmask}`);
console.log(` Gateway: ${bridge.gateway}`);
console.log();
console.log(`Proxy:`);
console.log(` Address: ${bridge.proxyAddress}`);
console.log(` Port: ${bridge.proxyPort}`);
console.log();
console.log(`Time:`);
console.log(` UTC: ${bridge.utcTime}`);
console.log(` Time zone: ${bridge.timeZone}`);
console.log(` Local time: ${bridge.localTime}`);
console.log();
console.log(`Portal:`);
console.log(` Services enabled: ${bridge.portalServicesEnabled}`);
console.log(` Connected: ${bridge.portalConnected}`);
console.log();
console.log(`Functions:`);
console.log(` Link button enabled: ${bridge.linkButtonEnabled}`);
console.log(` Touchlink enabled: ${bridge.touchlinkEnabled}`);
console.log();
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/bridge/is-authenticated.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Testing authentication...');
client.bridge.isAuthenticated()
.then(() => {
console.log('Success');
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/bridge/lamp-stealer.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Starting lamp stealer...`);
client.bridge.touchlink()
.then(() => console.log('Touchlink enabled...'))
.catch(error => console.log(error.stack));
================================================
FILE: examples/bridge/link-button.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Simulating link button press...`);
client.bridge.linkButton()
.then(() => console.log('Done...'))
.catch(error => console.log(error.stack));
================================================
FILE: examples/bridge/ping.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Pinging bridge...');
client.bridge.ping()
.then(() => {
console.log('Success');
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/bridge/save-bridge.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Retrieving bridge (${client.host})...`);
client.bridge.get()
.then(bridge => {
bridge.name = `Huejay test ${(new Date()).getSeconds()}`;
bridge.timeZone = 'America/Detroit';
bridge.zigbeeChannel = 20;
bridge.dhcpEnabled = true;
bridge.touchlinkEnabled = true;
bridge.linkButtonEnabled = true;
console.log(`Saving bridge configuration...`);
return client.bridge.save(bridge);
})
.then(bridge => {
console.log(`Bridge "${bridge.name}" saved...`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/capabilities/get-groups.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving group capabilities...');
client.capabilities.groups()
.then(groups => {
console.log('Groups:');
console.log(` Available: ${groups.available}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/capabilities/get-lights.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving light capabilities...');
client.capabilities.lights()
.then(lights => {
console.log('Lights:');
console.log(` Available: ${lights.available}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/capabilities/get-resource-links.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving resource links capabilities...');
client.capabilities.resourceLinks()
.then(resourceLinks => {
console.log('Resource Links:');
console.log(` Available: ${resourceLinks.available}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/capabilities/get-rules.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving rule capabilities...');
client.capabilities.rules()
.then(rules => {
console.log('Rules:');
console.log(` Available: ${rules.available}`);
console.log(` Conditions Available: ${rules.conditionsAvailable}`);
console.log(` Actions Available: ${rules.actionsAvailable}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/capabilities/get-scenes.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving scene capabilities...');
client.capabilities.scenes()
.then(scenes => {
console.log('Scenes:');
console.log(` Available: ${scenes.available}`);
console.log(` Light States Available: ${scenes.lightStatesAvailable}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/capabilities/get-schedules.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving schedule capabilities...');
client.capabilities.schedules()
.then(schedules => {
console.log('Schedules:');
console.log(` Available: ${schedules.available}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/capabilities/get-sensors.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving sensor capabilities...');
client.capabilities.sensors()
.then(sensors => {
console.log('Sensors:');
console.log(` Available: ${sensors.available}`);
console.log(` CLIP Available: ${sensors.clipAvailable}`);
console.log(` ZLL Available: ${sensors.zllAvailable}`);
console.log(` ZGP Available: ${sensors.zgpAvailable}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/capabilities/get-time-zones.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving supported time zones...');
client.capabilities.getTimeZones()
.then(timeZones => {
console.log('Time Zones:');
for (let tz of timeZones) {
console.log(` ${tz}`);
}
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/discover.js
================================================
#!/usr/bin/env node
'use strict';
let huejay = require('../lib/Huejay');
console.log('Discovering bridges...');
huejay.discover()
.then(bridges => {
if (!bridges.length) {
console.log('- No bridges found');
return;
}
for (let bridge of bridges) {
console.log(`- Id: ${bridge.id}, IP: ${bridge.ip}`);
}
})
.catch(error => {
console.log(error.message);
});
================================================
FILE: examples/groups/get-groups.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving groups...');
console.log();
client.groups.getAll()
.then(groups => {
for (let group of groups) {
console.log(`Group [${group.id}]: ${group.name}`);
console.log(` Type: ${group.type}`);
console.log(` Class: ${group.class}`);
console.log(' Light Ids: ' + group.lightIds.join(', '));
console.log(' State:');
console.log(` Any on: ${group.anyOn}`);
console.log(` All on: ${group.allOn}`);
console.log(' Action:');
console.log(` On: ${group.on}`);
console.log(` Brightness: ${group.brightness}`);
console.log(` Color mode: ${group.colorMode}`);
console.log(` Hue: ${group.hue}`);
console.log(` Saturation: ${group.saturation}`);
console.log(` X/Y: ${group.xy[0]}, ${group.xy[1]}`);
console.log(` Color Temp: ${group.colorTemp}`);
console.log(` Alert: ${group.alert}`);
console.log(` Effect: ${group.effect}`);
if (group.modelId !== undefined) {
console.log(` Model Id: ${group.modelId}`);
console.log(` Unique Id: ${group.uniqueId}`);
console.log(' Model:');
console.log(` Id: ${group.model.id}`);
console.log(` Manufacturer: ${group.model.manufacturer}`);
console.log(` Name: ${group.model.name}`);
console.log(` Type: ${group.model.type}`);
}
console.log();
}
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/groups/increase-group-hs.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Incrementing group hue/saturation levels...`);
client.groups.getById(0)
.then(group => {
console.log(`Saving group...`);
group.incrementHue = 6500;
group.incrementSaturation = 25;
group.transitionTime = 0.3;
return client.groups.save(group);
})
.then(group => {
console.log('New hue:', group.hue);
console.log('New saturation:', group.saturation);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/groups/manage-group.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Creating group...');
let group = new client.groups.Group;
group.name = 'Group name here';
group.lightIds = [1, 2];
client.groups.create(group)
.then(group => {
console.log(`New group [${group.id}]:`);
console.log(` Name: ${group.name}`);
console.log(' Light Ids:', group.lightIds.join(', '));
return group.id;
})
.then(groupId => {
console.log(`Retrieving group ${groupId}`);
return client.groups.getById(groupId);
})
.then(group => {
console.log('Updating group and changing action');
group.name = 'New group name here';
group.lightIds = [3, 4, 5, 6];
group.on = true;
group.brightness = 254;
group.transitionTime = 0;
return client.groups.save(group);
})
.then(group => {
console.log('Deleting group');
return client.groups.delete(group);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/groups/manage-room-group.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Creating group...');
let group = new client.groups.Group;
group.name = 'Office group';
group.type = 'Room';
group.class = 'Office';
group.lightIds = [4, 5];
client.groups.create(group)
.then(group => {
console.log(`New group [${group.id}]:`);
console.log(` Name: ${group.name}`);
console.log(` Type: ${group.type}`);
console.log(` Class: ${group.class}`);
console.log(' Light Ids:', group.lightIds.join(', '));
return group;
})
.then(group => {
console.log('Deleting group');
return client.groups.delete(group);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/init-client.js
================================================
#!/usr/bin/env node
'use strict';
let huejay = require('../lib/Huejay');
let credentials = require('./.credentials.json');
let client = new huejay.Client(credentials);
module.exports = client;
================================================
FILE: examples/internet-services/get-internet-services.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Retrieving internet services (${client.host})...`);
client.internetServices.get()
.then(internetServices => {
console.log(`Internet services:`);
console.log(` Internet connected: ${internetServices.internetConnected}`);
console.log(` Remote access connected: ${internetServices.remoteAccessConnected}`);
console.log(` Time sync connected: ${internetServices.timeSyncConnected}`);
console.log(` Software update connected: ${internetServices.softwareUpdateConnected}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/lights/get-light.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving light...');
console.log();
client.lights.getById(8)
.then(light => {
console.log(`Light [${light.id}]: ${light.name}`);
console.log(` Type: ${light.type}`);
console.log(` Unique ID: ${light.uniqueId}`);
console.log(` Manufacturer: ${light.manufacturer}`);
console.log(` Model Id: ${light.modelId}`);
console.log(' Model:');
console.log(` Id: ${light.model.id}`);
console.log(` Name: ${light.model.name}`);
console.log(` Type: ${light.model.type}`);
console.log(` Color Gamut: ${light.model.colorGamut}`);
console.log(` Friends of Hue: ${light.model.friendsOfHue}`);
console.log(` Software Version: ${light.softwareVersion}`);
console.log(' State:');
console.log(` On: ${light.on}`);
console.log(` Reachable: ${light.reachable}`);
console.log(` Brightness: ${light.brightness}`);
console.log(` Color mode: ${light.colorMode}`);
console.log(` Hue: ${light.hue}`);
console.log(` Saturation: ${light.saturation}`);
console.log(` X/Y: ${light.xy[0]}, ${light.xy[1]}`);
console.log(` Color Temp: ${light.colorTemp}`);
console.log(` Alert: ${light.alert}`);
console.log(` Effect: ${light.effect}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/lights/get-lights.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving lights...');
console.log();
client.lights.getAll()
.then(lights => {
for (let light of lights) {
console.log(`Light [${light.id}]: ${light.name}`);
console.log(` Type: ${light.type}`);
console.log(` Unique ID: ${light.uniqueId}`);
console.log(` Manufacturer: ${light.manufacturer}`);
console.log(` Model Id: ${light.modelId}`);
console.log(' Model:');
console.log(` Id: ${light.model.id}`);
console.log(` Manufacturer: ${light.model.manufacturer}`);
console.log(` Name: ${light.model.name}`);
console.log(` Type: ${light.model.type}`);
console.log(` Color Gamut: ${light.model.colorGamut}`);
console.log(` Friends of Hue: ${light.model.friendsOfHue}`);
console.log(` Product Id: ${light.productId}`);
console.log(` Software Version: ${light.softwareVersion}`);
console.log(` Software Config Id: ${light.softwareConfigId}`);
console.log(' State:');
console.log(` On: ${light.on}`);
console.log(` Reachable: ${light.reachable}`);
console.log(` Brightness: ${light.brightness}`);
console.log(` Color mode: ${light.colorMode}`);
console.log(` Hue: ${light.hue}`);
console.log(` Saturation: ${light.saturation}`);
console.log(` X/Y: ${light.xy[0]}, ${light.xy[1]}`);
console.log(` Color Temp: ${light.colorTemp}`);
console.log(` Alert: ${light.alert}`);
console.log(` Effect: ${light.effect}`);
console.log();
}
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/lights/get-new-lights.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving new lights...');
console.log();
client.lights.getNew()
.then(lights => {
for (let light of lights) {
console.log(`Light [${light.id}]: ${light.name}`);
console.log(` Type: ${light.type}`);
console.log(` Unique ID: ${light.uniqueId}`);
console.log(` Manufacturer: ${light.manufacturer}`);
console.log(` Model Id: ${light.modelId}`);
console.log(' Model:');
console.log(` Id: ${light.model.id}`);
console.log(` Manufacturer: ${light.model.manufacturer}`);
console.log(` Name: ${light.model.name}`);
console.log(` Type: ${light.model.type}`);
console.log(` Color Gamut: ${light.model.colorGamut}`);
console.log(` Friends of Hue: ${light.model.friendsOfHue}`);
console.log(` Software Version: ${light.softwareVersion}`);
console.log(' State:');
console.log(` On: ${light.on}`);
console.log(` Reachable: ${light.reachable}`);
console.log(` Brightness: ${light.brightness}`);
console.log(` Color mode: ${light.colorMode}`);
console.log(` Hue: ${light.hue}`);
console.log(` Saturation: ${light.saturation}`);
console.log(` X/Y: ${light.xy[0]}, ${light.xy[1]}`);
console.log(` Color Temp: ${light.colorTemp}`);
console.log(` Alert: ${light.alert}`);
console.log(` Effect: ${light.effect}`);
console.log();
}
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/lights/increase-light-hs.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Incrementing light hue/saturation levels...`);
client.lights.getById(3)
.then(light => {
console.log(`Saving light...`);
light.incrementHue = 6500;
light.incrementSaturation = 25;
light.transitionTime = 5;
return client.lights.save(light);
})
.then(light => {
console.log('New hue:', light.hue);
console.log('New saturation:', light.saturation);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/lights/save-light.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Retrieving light from (${client.host})...`);
client.lights.getAll()
.then(lights => {
let light = lights[4];
light.name = `Name test`;
light.on = true;
console.log(`Saving light...`);
return client.lights.save(light);
})
.then(light => {
console.log(`Saved light [${light.id}]`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/lights/start-light-scan.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Starting light scan...');
client.lights.scan()
.then(() => {
console.log('Success');
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/portal/get-portal.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Retrieving portal (${client.host})...`);
client.portal.get()
.then(portal => {
console.log(`Portal:`);
console.log(` Is signed on: ${portal.signedOn}`);
console.log(` Incoming: ${portal.incoming}`);
console.log(` Outgoing: ${portal.outgoing}`);
console.log(` Communication: ${portal.communication}`);
console.log();
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/resource-links/get-resource-link.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving resource link...');
console.log();
client.resourceLinks.getById(1)
.then(resourceLink => {
console.log(`Resource Link [${resourceLink.id}]: ${resourceLink.name}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/resource-links/get-resource-links.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving resource links...');
console.log();
client.resourceLinks.getAll()
.then(resourceLinks => {
for (let resourceLink of resourceLinks) {
console.log(`Resource Link [${resourceLink.id}]:`, resourceLink.name);
console.log(` Description: ${resourceLink.description}`);
console.log(` Type: ${resourceLink.type}`);
console.log(` Class Id: ${resourceLink.classId}`);
console.log(` Owner: ${resourceLink.owner}`);
console.log(` Recycle: ${resourceLink.recycle}`);
console.log(` Links: ${resourceLink.links}`);
console.log();
}
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/resource-links/manage-resource-link.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Creating resource link...');
let resourceLink = new client.resourceLinks.ResourceLink;
resourceLink.name = 'Resource link name here';
resourceLink.description = 'Resource link description here';
resourceLink.classId = 1;
resourceLink.links = ['/groups/1'];
client.resourceLinks.create(resourceLink)
.then(resourceLink => {
console.log(`New resource link [${resourceLink.id}]:`);
return resourceLink.id;
})
.then(resourceLinkId => {
console.log(`Retrieving resource link ${resourceLinkId}`);
return client.resourceLinks.getById(resourceLinkId);
})
.then(resourceLink => {
console.log('Updating resource link');
resourceLink.name = 'New resource link name here';
resourceLink.description = 'New resource link description here';
resourceLink.links = ['/groups/2', '/groups/3'];
return client.resourceLinks.save(resourceLink);
})
.then(resourceLink => {
console.log('Deleting resource link');
return client.resourceLinks.delete(resourceLink);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/rules/get-rules.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving rules...');
console.log();
client.rules.getAll()
.then(rules => {
for (let rule of rules) {
console.log(`Rule [${rule.id}]: ${rule.name}`);
console.log(` Last Triggered: ${rule.lastTriggered}`);
console.log(` Created: ${rule.created}`);
console.log(` Times Triggered: ${rule.timesTriggered}`);
console.log(` Owner: ${rule.owner}`);
console.log(` Status: ${rule.status}`);
console.log(` Conditions:`);
for (let condition of rule.conditions) {
console.log(` Address: ${condition.address}`);
console.log(` Operator: ${condition.operator}`);
console.log(` Value: ${condition.value}`);
console.log();
}
console.log(` Actions:`);
for (let action of rule.actions) {
console.log(` Address: ${action.address}`);
console.log(` Method: ${action.method}`);
console.log(` Body: ${JSON.stringify(action.body)}`);
console.log();
}
console.log();
}
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/rules/manage-rule.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Creating rule...');
let rule = new client.rules.Rule;
rule.name = 'Fake sensor: All lights off';
rule.status = 'enabled';
Promise.all([
client.sensors.getById(31),
client.groups.getById(0),
client.groups.getById(1),
])
.then(results => {
let sensor = results[0];
let group = results[1];
let group2 = results[2];
group.on = false;
rule.addCondition(sensor).when('buttonEvent').equals(42);
rule.addCondition(sensor).when('lastUpdated').changes();
rule.addAction(new client.actions.ChangeGroupAction(group));
return client.rules.create(rule)
.then(() => {
console.log(`Rule [${rule.id}] created...`);
rule.name = 'Fake sensor: Updated name';
rule.status = 'disabled';
rule.addAction(new client.actions.ChangeGroupAction(group2, ['brightness']));
console.log('Updating rule...');
return client.rules.save(rule);
})
.then(() => {
console.log('Deleting rule...');
return client.rules.delete(rule);
});
})
.catch(error => console.log(error.stack));
================================================
FILE: examples/scenes/get-scenes.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving scenes...');
console.log();
client.scenes.getAll()
.then(scenes => {
for (let scene of scenes) {
console.log(`Scene [${scene.id}]:`, scene.name);
console.log(' Lights:', scene.lightIds.join(', '));
console.log(' Owner:', scene.owner);
console.log(' Recycle:', scene.recycle);
console.log(' Locked:', scene.locked);
console.log(' App data:', scene.appData);
console.log(' Picture:', scene.picture);
console.log(' Last Updated:', scene.lastUpdated);
console.log(' Version:', scene.version);
console.log();
}
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/scenes/manage-scene.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Creating scene...');
let scene = new client.scenes.Scene;
scene.name = 'Huejay test';
scene.lightIds = [1, 2];
scene.recycle = false;
scene.appData = {version: 1, data: "custom data"};
scene.transitionTime = 0;
client.scenes.create(scene)
.then(scene => {
console.log(`Scene [${scene.id}] created...`);
console.log(' Name:', scene.name);
console.log(' Lights:', scene.lightIds.join(', '));
console.log(' Owner:', scene.owner);
console.log(' Recycle:', scene.recycle);
console.log(' Locked:', scene.locked);
console.log(' App data:', scene.appData);
console.log(' Picture:', scene.picture);
console.log(' Last Updated:', scene.lastUpdated);
console.log(' Version:', scene.version);
console.log();
scene.name = 'New scene name';
scene.setLightState(1, {
brightness: 254,
colorTemp: 300,
});
scene.setLightState(2, {
brightness: 254,
colorTemp: 250
});
return client.scenes.save(scene);
})
.then(scene => {
console.log(`Scene saved...`);
return client.scenes.delete(scene);
})
.then(() => {
console.log('Scene deleted...');
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/scenes/recall-scene.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Recalling scene...');
client.scenes.recall('34df1eb80-on-0')
.then(() => {
console.log('Scene recalled...');
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/scenes/save-scene.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Getting scene...');
client.scenes.getById('jflowFI1AtKps8d')
.then(scene => {
scene.setLightState(10, {
brightness: 254,
colorTemp: 300,
});
scene.setLightState(9, {
brightness: 254,
colorTemp: 250
});
return client.scenes.save(scene)
})
.then(scene => {
console.log(`Scene saved...`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/schedules/get-schedules.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving schedules...');
console.log();
client.schedules.getAll()
.then(schedules => {
for (let schedule of schedules) {
console.log(`Schedule [${schedule.id}]: ${schedule.name}`);
console.log(` Description: ${schedule.description}`);
console.log(` Created: ${schedule.created}`);
console.log(` Local time: ${schedule.localTime}`);
console.log(` Status: ${schedule.status}`);
console.log(` Auto delete: ${Boolean(schedule.autoDelete)}`);
console.log(` Command:`);
console.log(` Method: ${schedule.action.method}`);
console.log(` Address: ${schedule.action.address}`);
console.log(` Body: ${JSON.stringify(schedule.action.body)}`);
console.log();
}
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/schedules/manage-schedule.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
// Get light
client.lights.getById(1)
.then(light => {
console.log('Light found...');
light.brightness = 1;
let schedule = new client.schedules.Schedule;
schedule.name = 'Huejay test';
schedule.description = 'Setting light brightness to 1 in 10 seconds';
schedule.localTime = new client.timePatterns.Timer(10);
schedule.autoDelete = true;
schedule.action = new client.actions.ChangeLightState(light, ['brightness']);
console.log('Creating schedule with light...');
return client.schedules.create(schedule);
})
.then(schedule => {
console.log(`Schedule created: ${schedule.id}`);
console.log('Saving schedule');
schedule.name = 'New name';
return client.schedules.save(schedule);
})
.then(schedule => {
console.log('Saved schedule');
console.log('Retrieving schedule');
return client.schedules.getById(schedule.id);
})
.then(schedule => {
console.log(`Schedule [${schedule.id}]: ${schedule.name}`);
return client.schedules.delete(schedule);
})
.then(() => {
console.log(`Schedule deleted`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/sensors/create-switch.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Creating sensor...');
let sensor = new client.sensors.Sensor;
sensor.name = 'Switch test';
sensor.modelId = 'Sensormodel';
sensor.softwareVersion = '1.2.3';
sensor.type = 'CLIPSwitch';
sensor.uniqueId = '123.456.789';
sensor.manufacturer = 'Huejay';
sensor.config.on = true;
sensor.state.buttonEvent = 69;
client.sensors.create(sensor)
.then(sensor => {
console.log(`New sensor [${sensor.id}]: ${sensor.name}`);
console.log(` Type: ${sensor.type}`);
console.log(` Model Id: ${sensor.modelId}`);
console.log(` Manufacturer: ${sensor.manufacturer}`);
console.log(` Software Version: ${sensor.softwareVersion}`);
console.log(` Unique Id: ${sensor.uniqueId}`);
console.log(` Config:`);
console.log(` On: ${sensor.config.on}`);
console.log(` State:`);
console.log(` Button Event: ${sensor.state.buttonEvent}`);
console.log();
})
.catch(error => console.log(error.stack));
================================================
FILE: examples/sensors/get-sensors.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving sensors...');
console.log();
client.sensors.getAll()
.then(sensors => {
for (let sensor of sensors) {
console.log(`Sensor [${sensor.id}]: ${sensor.name}`);
console.log(` Type: ${sensor.type}`);
console.log(` Manufacturer: ${sensor.manufacturer}`);
console.log(` Model Id: ${sensor.modelId}`);
console.log(' Model:');
console.log(` Id: ${sensor.model.id}`);
console.log(` Manufacturer: ${sensor.model.manufacturer}`);
console.log(` Name: ${sensor.model.name}`);
console.log(` Type: ${sensor.model.type}`);
console.log(` Product Id: ${sensor.productId}`);
console.log(` Software Version: ${sensor.softwareVersion}`);
console.log(` Software Config Id: ${sensor.softwareConfigId}`);
console.log(` Unique Id: ${sensor.uniqueId}`);
console.log(` Config:`);
console.log(` On: ${sensor.config.on}`);
console.log(` State:`);
for (let state in sensor.state.stateMap) {
console.log(` ${state}: ${sensor.state[state]}`);
}
console.log();
}
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/sensors/manage-sensor.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Creating sensor...');
let sensor = new client.sensors.Sensor;
sensor.name = 'Sensor name here';
sensor.modelId = 'Sensormodel';
sensor.softwareVersion = '1.2.3';
sensor.type = 'CLIPTemperature';
sensor.uniqueId = '123.456.789';
sensor.manufacturer = 'Huejay';
sensor.config.on = false;
sensor.state.temperature = 10.2;
client.sensors.create(sensor)
.then(sensor => {
console.log(`New sensor [${sensor.id}]: ${sensor.name}`);
console.log(` Type: ${sensor.type}`);
console.log(` Model Id: ${sensor.modelId}`);
console.log(` Manufacturer: ${sensor.manufacturer}`);
console.log(` Software Version: ${sensor.softwareVersion}`);
console.log(` Unique Id: ${sensor.uniqueId}`);
console.log(` Config:`);
console.log(` On: ${sensor.config.on}`);
console.log(` State:`);
console.log(` Temperature: ${sensor.state.temperature}`);
console.log();
console.log(`Retrieving sensor ${sensor.id}`);
return client.sensors.getById(sensor.id);
})
.then(sensor => {
console.log('Updating sensor and changing state');
sensor.name = 'New sensor name here';
sensor.config.on = false;
sensor.state.temperature = 28.5;
return client.sensors.save(sensor);
})
.then(sensor => {
console.log('Deleting sensor');
return client.sensors.delete(sensor);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/sensors/update-switch.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Updating sensor...');
client.sensors.getById(31)
.then(sensor => {
sensor.state.buttonEvent = 42;
return client.sensors.save(sensor);
})
.catch(error => console.log(error.stack));
================================================
FILE: examples/software-update/check-for-software-updates.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Checking for software update (${client.host})...`);
client.softwareUpdate.check()
.then(() => {
console.log('Retrieving software update details...');
return client.softwareUpdate.get();
})
.then(softwareUpdate => {
console.log(` Checking: ${softwareUpdate.checkingEnabled}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/software-update/disable-install-notification.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Disabling install notification (${client.host})...`);
client.softwareUpdate.disableInstallNotification()
.then(() => {
console.log('Retrieving software update details...');
return client.softwareUpdate.get();
})
.then(softwareUpdate => {
console.log(` Install notification: ${softwareUpdate.installNotificationEnabled}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/software-update/get-software-update.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Retrieving software update details (${client.host})...`);
client.softwareUpdate.get()
.then(softwareUpdate => {
console.log(` State: ${softwareUpdate.state}`);
console.log(` Checking for update: ${softwareUpdate.checkingEnabled}`);
console.log(` Bridge updates: ${softwareUpdate.bridge}`);
if (softwareUpdate.lights.length) {
console.log(' Lights: ' + softwareUpdate.lights.join(', '));
} else {
console.log(' Lights: false');
}
if (softwareUpdate.sensors.length) {
console.log(' Sensors: ' + softwareUpdate.sensors.join(', '));
} else {
console.log(' Sensors: false');
}
console.log(` Release URL: ${softwareUpdate.releaseUrl}`);
console.log(` Release notes: ${softwareUpdate.releaseNotes}`);
console.log(` Notify after installation: ${softwareUpdate.installNotificationEnabled}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/software-update/install-software-updates.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log(`Installing software updates (${client.host})...`);
client.softwareUpdate.install()
.then(() => {
console.log('Retrieving software update details...');
return client.softwareUpdate.get();
})
.then(softwareUpdate => {
console.log(` State: ${softwareUpdate.state}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/time-zones/get-time-zones.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving supported time zones...');
client.timeZones.getAll()
.then(timeZones => {
console.log('Time Zones:');
for (let tz of timeZones) {
console.log(` ${tz}`);
}
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/users/create-user.js
================================================
#!/usr/bin/env node
'use strict';
let huejay = require('../../lib/Huejay');
let client = require('../init-client');
console.log('Attempting to create user.');
console.log('Make sure link button on bridge is pressed.');
console.log('...');
let user = new client.users.User;
client.users.create(user)
.then(user => {
console.log(`New user created:`);
console.log(` Username: ${user.username}`);
console.log(` Device type: ${user.deviceType}`);
})
.catch(error => {
if (error instanceof huejay.Error && error.type === 101) {
return console.log(`Link button not pressed. Try again...`);
}
console.log(error.stack);
});
================================================
FILE: examples/users/delete-user.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Deleting user...');
client.users.delete('usernamehere')
.then(() => {
console.log('Success');
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/users/get-user.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving user...');
client.users.get()
.then(user => {
if (user === undefined) {
return console.log(' Not found.');
}
console.log(` Username: ${user.username}`);
console.log(` Device type: ${user.deviceType}`);
console.log(` Create date: ${user.created}`);
console.log(` Last use date: ${user.lastUsed}`);
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: examples/users/get-users.js
================================================
#!/usr/bin/env node
'use strict';
let client = require('../init-client');
console.log('Retrieving users...');
console.log();
client.users.getAll()
.then(users => {
for (let user of users) {
console.log(` Username: ${user.username}`);
console.log(` Device type: ${user.deviceType}`);
console.log(` Create date: ${user.created}`);
console.log(` Last use date: ${user.lastUsed}`);
console.log();
}
})
.catch(error => {
console.log(error.stack);
});
================================================
FILE: lib/Accessor/AbstractAccessor.js
================================================
'use strict';
/**
* Abstract accessor
*/
class AbstractAccessor {
/**
* Constructor
*
* @param {Client} client Client
*/
constructor(client) {
this.client = client;
}
}
module.exports = AbstractAccessor;
================================================
FILE: lib/Accessor/Actions.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
// Action helpers
let ChangeLightState = require('../Action/ChangeLightState');
let ChangeGroupAction = require('../Action/ChangeGroupAction');
let ChangeSensorState = require('../Action/ChangeSensorState');
/**
* Actions accessor
*/
class Actions extends AbstractAccessor {
/**
* Constructor
*
* @param {Client} client Client
*/
constructor(client) {
super(client);
this.ChangeLightState = ChangeLightState;
this.ChangeGroupAction = ChangeGroupAction;
this.ChangeSensorState = ChangeSensorState;
}
}
module.exports = Actions;
================================================
FILE: lib/Accessor/Bridge.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
let BridgeModel = require('../Model/Bridge');
// Commands
let Ping = require('../Command/Bridge/Ping');
let IsAuthenticated = require('../Command/Bridge/IsAuthenticated');
let EnableLinkButton = require('../Command/Bridge/EnableLinkButton');
let EnableTouchlink = require('../Command/Bridge/EnableTouchlink');
let GetBridge = require('../Command/Bridge/GetBridge');
let SaveBridge = require('../Command/Bridge/SaveBridge');
/**
* Bridge accessor
*/
class Bridge extends AbstractAccessor {
/**
* Constructor
*
* @return {Client} client Client
*/
constructor(client) {
super(client);
this.Bridge = BridgeModel;
}
/**
* Ping the bridge
*
* @return {Promise} Promise for chaining
*/
ping() {
return this.client.invokeCommand(new Ping);
}
/**
* Is authenticated
*
* @return {Promise} Promise for chaining
*/
isAuthenticated() {
return this.client.invokeCommand(new IsAuthenticated);
}
/**
* Get the bridge
*
* @return {Promise} Promise for chaining
*/
get() {
return this.client.invokeCommand(new GetBridge);
}
/**
* Save bridge
*
* @return {Promise} Promise for chaining
*/
save(bridge) {
return this.client.invokeCommand(new SaveBridge(bridge));
}
/**
* Enable link button
*
* @return {Promise} Promise for chaining
*/
linkButton() {
return this.client.invokeCommand(new EnableLinkButton);
}
/**
* Enable Touchlink
*
* @return {Promise} Promise for chaining
*/
touchlink() {
return this.client.invokeCommand(new EnableTouchlink);
}
}
module.exports = Bridge;
================================================
FILE: lib/Accessor/Capabilities.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
// Commands
let GetLights = require('../Command/Capability/GetLights');
let GetSensors = require('../Command/Capability/GetSensors');
let GetGroups = require('../Command/Capability/GetGroups');
let GetScenes = require('../Command/Capability/GetScenes');
let GetSchedules = require('../Command/Capability/GetSchedules');
let GetRules = require('../Command/Capability/GetRules');
let GetResourceLinks = require('../Command/Capability/GetResourceLinks');
let GetTimeZones = require('../Command/Capability/GetTimeZones');
/**
* Capabilities accessor
*/
class Capabilities extends AbstractAccessor {
/**
* Get light capabilities
*
* @return {Promise} Promise for chaining
*/
lights() {
return this.client.invokeCommand(new GetLights);
}
/**
* Get sensor capabilities
*
* @return {Promise} Promise for chaining
*/
sensors() {
return this.client.invokeCommand(new GetSensors);
}
/**
* Get group capabilities
*
* @return {Promise} Promise for chaining
*/
groups() {
return this.client.invokeCommand(new GetGroups);
}
/**
* Get scene capabilities
*
* @return {Promise} Promise for chaining
*/
scenes() {
return this.client.invokeCommand(new GetScenes);
}
/**
* Get rule capabilities
*
* @return {Promise} Promise for chaining
*/
rules() {
return this.client.invokeCommand(new GetRules);
}
/**
* Get resource links capabilities
*
* @return {Promise} Promise for chaining
*/
resourceLinks() {
return this.client.invokeCommand(new GetResourceLinks);
}
/**
* Get schedule capabilities
*
* @return {Promise} Promise for chaining
*/
schedules() {
return this.client.invokeCommand(new GetSchedules);
}
/**
* Get time zones
*
* @return {Promise} Promise for chaining
*/
getTimeZones() {
return this.client.invokeCommand(new GetTimeZones);
}
}
module.exports = Capabilities;
================================================
FILE: lib/Accessor/Groups.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
let Group = require('../Model/Group');
// Commands
let GetGroups = require('../Command/Group/GetGroups');
let GetGroup = require('../Command/Group/GetGroup');
let CreateGroup = require('../Command/Group/CreateGroup');
let SaveGroup = require('../Command/Group/SaveGroup');
let SaveGroupAction = require('../Command/Group/SaveGroupAction');
let DeleteGroup = require('../Command/Group/DeleteGroup');
/**
* Groups accessor
*/
class Groups extends AbstractAccessor {
/**
* Constructor
*
* @param {Client} client Client
*/
constructor(client) {
super(client);
this.Group = Group;
}
/**
* Get groups
*
* @return {Promise} Promise for chaining
*/
getAll() {
return this.client.invokeCommand(new GetGroups);
}
/**
* Get group by id
*
* @param {string} id Group Id
*
* @return {Promise} Promise for chaining
*/
getById(id) {
return this.client.invokeCommand(new GetGroup(id));
}
/**
* Create group
*
* @param {Group} group Group
*
* @return {Promise} Promise for chaining
*/
create(group) {
return this.client.invokeCommand(new CreateGroup(group));
}
/**
* Save group
*
* @param {Group} group Group
*
* @return {Promise} Promise for chaining
*/
save(group) {
return Promise.all([
this.client.invokeCommand(new SaveGroup(group)),
this.client.invokeCommand(new SaveGroupAction(group))
]).then(() => {
return group;
});
}
/**
* Delete group
*
* @param {Group} group Group object or group Id
*
* @return {Promise} Promise for chaining
*/
delete(group) {
return this.client.invokeCommand(new DeleteGroup(group));
}
}
module.exports = Groups;
================================================
FILE: lib/Accessor/InternetServices.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
// Commands
let GetInternetServices = require('../Command/InternetServices/GetInternetServices');
/**
* Internet services accessor
*/
class InternetServices extends AbstractAccessor {
/**
* Get internet services
*
* @return {Promise} Promise for chaining
*/
get() {
return this.client.invokeCommand(new GetInternetServices);
}
}
module.exports = InternetServices;
================================================
FILE: lib/Accessor/Lights.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
let Light = require('../Model/Light');
// Commands
let StartLightScan = require('../Command/Light/StartLightScan');
let GetNewLights = require('../Command/Light/GetNewLights');
let GetLights = require('../Command/Light/GetLights');
let GetLight = require('../Command/Light/GetLight');
let SaveLight = require('../Command/Light/SaveLight');
let SaveLightState = require('../Command/Light/SaveLightState');
let DeleteLight = require('../Command/Light/DeleteLight');
/**
* Lights accessor
*/
class Lights extends AbstractAccessor {
/**
* Constructor
*
* @param {Client} client Client
*/
constructor(client) {
super(client);
this.Light = Light;
}
/**
* Start light scan
*
* @return {Promise} Promise for chaining
*/
scan() {
return this.client.invokeCommand(new StartLightScan);
}
/**
* Get new lights
*
* @return {Promise} Promise for chaining
*/
getNew() {
return this.client.invokeCommand(new GetNewLights);
}
/**
* Get all lights
*
* @return {Promise} Promise for chaining
*/
getAll() {
return this.client.invokeCommand(new GetLights);
}
/**
* Get light by id
*
* @param {string} id Light Id
*
* @return {Promise} Promise for chaining
*/
getById(lightId) {
return this.client.invokeCommand(new GetLight(lightId));
}
/**
* Save light
*
* @param {Light} light Light
*
* @return {Promise} Promise for chaining
*/
save(light) {
return Promise.all([
this.client.invokeCommand(new SaveLight(light)),
this.client.invokeCommand(new SaveLightState(light))
]).then(() => {
return light;
});
}
/**
* Delete
*
* @param {mixed} light Light object or light id
*
* @return {Promise} Promise for chaining
*/
delete(light) {
return this.client.invokeCommand(new DeleteLight(light));
}
}
module.exports = Lights;
================================================
FILE: lib/Accessor/Portal.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
// Commands
let GetPortal = require('../Command/Portal/GetPortal');
/**
* Portal accessor
*/
class Portal extends AbstractAccessor {
/**
* Get portal
*
* @return {Promise} Promise for chaining
*/
get() {
return this.client.invokeCommand(new GetPortal);
}
}
module.exports = Portal;
================================================
FILE: lib/Accessor/ResourceLinks.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
let ResourceLink = require('../Model/ResourceLink');
// Commands
let GetResourceLinks = require('../Command/ResourceLinks/GetResourceLinks');
let GetResourceLink = require('../Command/ResourceLinks/GetResourceLink');
let CreateResourceLink = require('../Command/ResourceLinks/CreateResourceLink');
let SaveResourceLink = require('../Command/ResourceLinks/SaveResourceLink');
let DeleteResourceLink = require('../Command/ResourceLinks/DeleteResourceLink');
/**
* Resource links accessor
*/
class ResourceLinks extends AbstractAccessor {
/**
* Constructor
*
* @param {Client} client Client
*/
constructor(client) {
super(client);
this.ResourceLink = ResourceLink;
}
/**
* Get resource links
*
* @return {Promise} Promise for chaining
*/
getAll() {
return this.client.invokeCommand(new GetResourceLinks);
}
/**
* Get resource link by id
*
* @param {string} id Resource Link Id
*
* @return {Promise} Promise for chaining
*/
getById(id) {
return this.client.invokeCommand(new GetResourceLink(id));
}
/**
* Create resource link
*
* @param {ResourceLink} resourceLink Resource Link
*
* @return {Promise} Promise for chaining
*/
create(resourceLink) {
return this.client.invokeCommand(new CreateResourceLink(resourceLink));
}
/**
* Save resource link
*
* @param {ResourceLink} resourceLink Resource Link
*
* @return {Promise} Promise for chaining
*/
save(resourceLink) {
return this.client.invokeCommand(new SaveResourceLink(resourceLink));
}
/**
* Delete resource link
*
* @param {ResourceLink} resourceLink Resource Link object or resource link Id
*
* @return {Promise} Promise for chaining
*/
delete(resourceLink) {
return this.client.invokeCommand(new DeleteResourceLink(resourceLink));
}
}
module.exports = ResourceLinks;
================================================
FILE: lib/Accessor/Rules.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
let Rule = require('../Model/Rule');
let Condition = require('../Model/Condition');
// Commands
let GetRules = require('../Command/Rule/GetRules');
let GetRule = require('../Command/Rule/GetRule');
let CreateRule = require('../Command/Rule/CreateRule');
let SaveRule = require('../Command/Rule/SaveRule');
let DeleteRule = require('../Command/Rule/DeleteRule');
/**
* Rules accessor
*/
class Rules extends AbstractAccessor {
/**
* Constructor
*
* @param {Client} client Client
*/
constructor(client) {
super(client);
this.Rule = Rule;
this.Condition = Condition;
}
/**
* Get all rules
*
* @return {Promise} Promise for chaining
*/
getAll() {
return this.client.invokeCommand(new GetRules);
}
/**
* Get rule by id
*
* @param {string} id Id
*
* @return {Promise} Promise for chaining
*/
getById(id) {
return this.client.invokeCommand(new GetRule(id));
}
/**
* Create rule
*
* @param {Rule} rule Rule
*
* @return {Promise} Promise for chaining
*/
create(rule) {
return this.client.invokeCommand(new CreateRule(rule));
}
/**
* Save rule
*
* @param {Rule} rule Rule
*
* @return {Promise} Promise for chaining
*/
save(rule) {
return this.client.invokeCommand(new SaveRule(rule));
}
/**
* Delete rule
*
* @param {mixed} rule Rule or rule id
*
* @return {[type]} [description]
*/
delete(rule) {
return this.client.invokeCommand(new DeleteRule(rule));
}
}
module.exports = Rules;
================================================
FILE: lib/Accessor/Scenes.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
let Scene = require('../Model/Scene');
// Commands
let GetScenes = require('../Command/Scene/GetScenes');
let GetSceneById = require('../Command/Scene/GetSceneById');
let CreateScene = require('../Command/Scene/CreateScene');
let SaveScene = require('../Command/Scene/SaveScene');
let SaveSceneLightState = require('../Command/Scene/SaveSceneLightState');
let RecallScene = require('../Command/Scene/RecallScene');
let DeleteScene = require('../Command/Scene/DeleteScene');
/**
* Scenes accessor
*/
class Scenes extends AbstractAccessor {
/**
* Constructor
*
* @param {Client} client Client
*/
constructor(client) {
super(client);
this.Scene = Scene;
}
/**
* Get scenes
*
* @return {Promise} Promise for chaining
*/
getAll() {
return this.client.invokeCommand(new GetScenes);
}
/**
* Get by id
*
* @param {string} sceneId Scene Id
*
* @return {Promise} Promise for chaining
*/
getById(sceneId) {
return this.client.invokeCommand(new GetSceneById(sceneId));
}
/**
* Create scene
*
* @param {Scene} scene Scene
*
* @return {Promise} Promise for chaining
*/
create(scene) {
return this.client.invokeCommand(new CreateScene(scene));
}
/**
* Save scene
*
* @param {Scene} scene Scene
*
* @return {Promise} Promise for chaining
*/
save(scene) {
return Promise.all([
this.client.invokeCommand(new SaveScene(scene)),
this.client.invokeCommand(new SaveSceneLightState(scene))
]).then(() => {
return scene;
});
}
/**
* Recall scene
*
* @param {mixed} scene Scene object or scene id
*
* @return {Promise} Promise for chaining
*/
recall(scene) {
return this.client.invokeCommand(new RecallScene(scene));
}
/**
* Delete scene
*
* @param {mixed} scene Scene object or scene id
*
* @return {Promise} Promise for chaining
*/
delete(scene) {
return this.client.invokeCommand(new DeleteScene(scene));
}
}
module.exports = Scenes;
================================================
FILE: lib/Accessor/Schedules.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
let Schedule = require('../Model/Schedule');
// Commands
let GetSchedules = require('../Command/Schedule/GetSchedules');
let GetSchedule = require('../Command/Schedule/GetSchedule');
let CreateSchedule = require('../Command/Schedule/CreateSchedule');
let SaveSchedule = require('../Command/Schedule/SaveSchedule');
let DeleteSchedule = require('../Command/Schedule/DeleteSchedule');
/**
* Schedules accessor
*/
class Schedules extends AbstractAccessor {
/**
* Constructor
*
* @param {Client} client Client
*/
constructor(client) {
super(client);
this.Schedule = Schedule;
}
/**
* Get all schedules
*
* @return {Promise} Promise for chaining
*/
getAll() {
return this.client.invokeCommand(new GetSchedules);
}
/**
* Get schedule
*
* @param {string} id Schedule Id
*
* @return {Promise} Promise for chaining
*/
getById(id) {
return this.client.invokeCommand(new GetSchedule(id));
}
/**
* Create schedule
*
* @param {Schedule} schedule Schedule
*
* @return {Promise} Promise for chaining
*/
create(schedule) {
return this.client.invokeCommand(
new CreateSchedule(schedule)
);
}
/**
* Save schedule
*
* @param {Schedule} schedule Schedule
*
* @return {Promise} Promise for chaining
*/
save(schedule) {
return this.client.invokeCommand(
new SaveSchedule(schedule)
);
}
/**
* Delete schedule
*
* @param {mixed} Schedule object or schedule Id
*
* @return {Promise} Promise for chaining
*/
delete(schedule) {
return this.client.invokeCommand(new DeleteSchedule(schedule));
}
}
module.exports = Schedules;
================================================
FILE: lib/Accessor/Sensors.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
let Sensor = require('../Model/Sensor');
// Commands
let StartSensorScan = require('../Command/Sensor/StartSensorScan');
let GetNewSensors = require('../Command/Sensor/GetNewSensors');
let GetSensors = require('../Command/Sensor/GetSensors');
let GetSensor = require('../Command/Sensor/GetSensor');
let CreateSensor = require('../Command/Sensor/CreateSensor');
let SaveSensor = require('../Command/Sensor/SaveSensor');
let SaveSensorState = require('../Command/Sensor/SaveSensorState');
let SaveSensorConfig = require('../Command/Sensor/SaveSensorConfig');
let DeleteSensor = require('../Command/Sensor/DeleteSensor');
/**
* Sensors accessor
*/
class Sensors extends AbstractAccessor {
/**
* Constructor
*
* @param {Client} client Client
*/
constructor(client) {
super(client);
this.Sensor = Sensor;
}
/**
* Scan for new sensors
*
* @return {Promise} Promise for chaining
*/
scan() {
return this.client.invokeCommand(new StartSensorScan);
}
/**
* Get new sensors
*
* @return {Promise} Promise for chaining
*/
getNew() {
return this.client.invokeCommand(new GetNewSensors);
}
/**
* Get all sensors
*
* @return {Promise} Promise for chaining
*/
getAll() {
return this.client.invokeCommand(new GetSensors);
}
/**
* Get sensor by id
*
* @param {mixed} id Sensor Id
*
* @return {Promise} Promise for chaining
*/
getById(id) {
return this.client.invokeCommand(new GetSensor(id));
}
/**
* Create sensor
*
* @param {Sensor} sensor Sensor
*
* @return {Promise} Promise for chaining
*/
create(sensor) {
return this.client.invokeCommand(new CreateSensor(sensor));
}
/**
* Save sensor
*
* @param {Sensor} sensor Sensor
*
* @return {Promise} Promise for chaining
*/
save(sensor) {
return Promise.all([
this.client.invokeCommand(new SaveSensor(sensor)),
this.client.invokeCommand(new SaveSensorState(sensor)),
this.client.invokeCommand(new SaveSensorConfig(sensor))
]).then(() => {
return sensor;
});
}
/**
* Delete sensor
*
* @param {mixed} sensor Sensor object or sensor id
*
* @return {Promise} Promise for chaining
*/
delete(sensor) {
return this.client.invokeCommand(new DeleteSensor(sensor));
}
}
module.exports = Sensors;
================================================
FILE: lib/Accessor/SoftwareUpdate.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
// Commands
let GetSoftwareUpdate = require('../Command/SoftwareUpdate/GetSoftwareUpdate');
let CheckForSoftwareUpdates = require('../Command/SoftwareUpdate/CheckForSoftwareUpdates');
let InstallSoftwareUpdates = require('../Command/SoftwareUpdate/InstallSoftwareUpdates');
let DisableInstallNotification = require('../Command/SoftwareUpdate/DisableInstallNotification');
/**
* Software update accessor
*/
class SoftwareUpdate extends AbstractAccessor {
/**
* Get software update
*
* @return {Promise} Promise for chaining
*/
get() {
return this.client.invokeCommand(new GetSoftwareUpdate);
}
/**
* Check for updates
*
* @return {Promise} Promise for chaining
*/
check() {
return this.client.invokeCommand(new CheckForSoftwareUpdates);
}
/**
* Install updates
*
* @return {Promise} Promise for chaining
*/
install() {
return this.client.invokeCommand(new InstallSoftwareUpdates);
}
/**
* Disable install notification
*
* @return {Promise} Promise for chaining
*/
disableInstallNotification() {
return this.client.invokeCommand(new DisableInstallNotification);
}
}
module.exports = SoftwareUpdate;
================================================
FILE: lib/Accessor/TimePatterns.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
// Time patterns
let AbsoluteTime = require('../TimePattern/AbsoluteTime');
let RandomizedTime = require('../TimePattern/RandomizedTime');
let RecurringTime = require('../TimePattern/RecurringTime');
let Timer = require('../TimePattern/Timer');
/**
* Time patterns accessor
*/
class TimePatterns extends AbstractAccessor {
/**
* Constructor
*
* @param {Client} client Client
*/
constructor(client) {
super(client);
this.AbsoluteTime = AbsoluteTime;
this.RandomizedTime = RandomizedTime;
this.RecurringTime = RecurringTime;
this.Timer = Timer;
}
}
module.exports = TimePatterns;
================================================
FILE: lib/Accessor/TimeZones.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
// Commands
let GetTimeZones = require('../Command/TimeZone/GetTimeZones');
/**
* Time zones accessor
*/
class TimeZones extends AbstractAccessor {
/**
* Get all time zones
*
* @return {Promise} Promise for chaining
*/
getAll() {
return this.client.invokeCommand(new GetTimeZones);
}
}
module.exports = TimeZones;
================================================
FILE: lib/Accessor/Users.js
================================================
'use strict';
let AbstractAccessor = require('./AbstractAccessor');
let User = require('../Model/User');
// Commands
let GetUsers = require('../Command/User/GetUsers');
let GetUser = require('../Command/User/GetUser');
let CreateUser = require('../Command/User/CreateUser');
let DeleteUser = require('../Command/User/DeleteUser');
/**
* Users accessor
*/
class Users extends AbstractAccessor {
/**
* Constructor
*
* @param {Client} client Client
*/
constructor(client) {
super(client);
this.User = User;
}
/**
* Get all users
*
* @return {Promise} Promise for chaining
*/
getAll() {
return this.client.invokeCommand(new GetUsers);
}
/**
* Get currently authed user
*
* @return {Promise} Promise for chaining
*/
get() {
return this.client.invokeCommand(new GetUser(this.client.username));
}
/**
* Get user by username
*
* @param {mixed} username Username or User object
*
* @return {Promise} Promise for chaining
*/
getByUsername(username) {
return this.client.invokeCommand(new GetUser(username));
}
/**
* Create user
*
* @param {User} user User
*
* @return {Promise} Promise for chaining
*/
create(user) {
return this.client.invokeCommand(new CreateUser(user));
}
/**
* Delete user
*
* @param {mixed} user Username or User object
*
* @return {Promise} Promise for chaining
*/
delete(user) {
return this.client.invokeCommand(new DeleteUser(user));
}
}
module.exports = Users;
================================================
FILE: lib/Action/AbstractAction.js
================================================
'use strict';
let Error = require('../Error');
/**
* Abstract action
*/
class AbstractAction {
/**
* Export action
*/
exportAction() {
throw new Error({
message: 'Action must define exportAction'
});
}
}
module.exports = AbstractAction;
================================================
FILE: lib/Action/ChangeGroupAction.js
================================================
'use strict';
let AbstractAction = require('./AbstractAction');
let GroupUtils = require('../Command/Group/Utils');
const GROUP_ACTION_MAP = {
on: 'on',
brightness: 'bri',
hue: 'hue',
saturation: 'sat',
xy: 'xy',
colorTemp: 'ct',
alert: 'alert',
effect: 'effect',
scene: 'scene',
transitionTime: 'transitiontime',
incrementBrightness: 'bri_inc',
incrementHue: 'hue_inc',
incrementSaturation: 'sat_inc',
incrementXy: 'xy_inc',
incrementColorTemp: 'ct_inc',
};
/**
* Change group action action
*/
class ChangeGroupAction extends AbstractAction {
/**
* Constructor
*
* @param {Group} group Group
* @param {array} useAction Action to use
*/
constructor(group, useAction) {
super();
GroupUtils.validateGroup(group);
this.group = group;
this.useAction = useAction;
}
/**
* Export action
*
* @param {client} client Client
*
* @return {Object} Action object
*/
exportAction(client, withUsername) {
let address = `/groups/${this.group.id}/action`;
let body = {};
if (this.useAction !== undefined) {
for (let key of this.useAction) {
if (key in GROUP_ACTION_MAP) {
let actionAttribute = GROUP_ACTION_MAP[key];
body[actionAttribute] = this.group.action.get(actionAttribute);
}
}
} else {
body = this.group.action.getChanged();
}
if (!!withUsername) {
address = `/api/${client.username}${address}`;
}
return {
method: 'PUT',
address,
body,
}
}
}
module.exports = ChangeGroupAction;
================================================
FILE: lib/Action/ChangeLightState.js
================================================
'use strict';
let AbstractAction = require('./AbstractAction');
let LightUtils = require('../Command/Light/Utils');
const LIGHT_STATE_MAP = {
on: 'on',
brightness: 'bri',
hue: 'hue',
saturation: 'sat',
xy: 'xy',
colorTemp: 'ct',
alert: 'alert',
effect: 'effect',
transitionTime: 'transitiontime',
incrementBrightness: 'bri_inc',
incrementHue: 'hue_inc',
incrementSaturation: 'sat_inc',
incrementXy: 'xy_inc',
incrementColorTemp: 'ct_inc',
};
/**
* Change light state action
*/
class ChangeLightState extends AbstractAction {
/**
* Constructor
*
* @param {Light} light Light
* @param {array} useState State to use
*/
constructor(light, useState) {
super();
LightUtils.validateLight(light);
this.light = light;
this.useState = useState;
}
/**
* Export action
*
* @param {client} client Client
*
* @return {Object} Action object
*/
exportAction(client, withUsername) {
let address = `/lights/${this.light.id}/state`;
let body = {};
if (this.useState !== undefined) {
for (let key of this.useState) {
if (key in LIGHT_STATE_MAP) {
let stateAttribute = LIGHT_STATE_MAP[key];
body[stateAttribute] = this.light.state.get(stateAttribute);
}
}
} else {
body = this.light.state.getChanged();
}
if (!!withUsername) {
address = `/api/${client.username}${address}`;
}
return {
method: 'PUT',
address,
body,
}
}
}
module.exports = ChangeLightState;
================================================
FILE: lib/Action/ChangeSensorState.js
================================================
'use strict';
let AbstractAction = require('./AbstractAction');
let SensorUtils = require('../Command/Sensor/Utils');
/**
* Change sensor state action
*/
class ChangeSensorState extends AbstractAction {
/**
* Constructor
*
* @param {Sensor} sensor Sensor
* @param {array} useState State to use
*/
constructor(sensor, useState) {
super();
SensorUtils.validateSensor(sensor);
this.sensor = sensor;
this.useState = useState;
}
/**
* Export action
*
* @param {client} client Client
*
* @return {Object} Action object
*/
exportAction(client, withUsername) {
let address = `/sensors/${this.sensor.id}/state`;
let body = {};
let sensorStateMap = this.sensor.state.stateMap;
if (this.useState !== undefined) {
for (let key of this.useState) {
if (key in sensorStateMap) {
let stateAttribute = sensorStateMap[key];
body[stateAttribute] = this.sensor.state.attributes.get(stateAttribute);
}
}
} else {
body = this.sensor.state.attributes.getChanged();
}
if (!!withUsername) {
address = `/api/${client.username}${address}`;
}
return {
method: 'PUT',
address,
body,
}
}
}
module.exports = ChangeSensorState;
================================================
FILE: lib/BridgeModel/AbstractBridgeModel.js
================================================
'use strict';
/**
* Abstract bridge model
*/
class AbstractBridgeModel {
/**
* Constructor
*
* @param {Object} details Bridge model details
*/
constructor(details) {
this.details = Object.assign({}, details);
}
/**
* Get id of model
*
* @return {string} Id
*/
get id() {
return this.details.id;
}
/**
* Get manufacturer
*
* @return {string} Manufacturer
*/
get manufacturer() {
return this.details.manufacturer;
}
/**
* Get name of model
*
* @return {string} Name
*/
get name() {
return this.details.name;
}
/**
* To string
*
* @return {string} Name
*/
toString() {
return this.name;
}
}
module.exports = AbstractBridgeModel;
================================================
FILE: lib/BridgeModel/BSB001.js
================================================
'use strict';
let AbstractBridgeModel = require('./AbstractBridgeModel');
const DETAILS = {
id: 'BSB001',
manufacturer: 'Philips',
name: 'Hue v1',
};
/**
* Bridge model: BSB001
*/
class BSB001 extends AbstractBridgeModel {
/**
* Constructor
*/
constructor() {
super(DETAILS);
}
}
module.exports = BSB001;
================================================
FILE: lib/BridgeModel/BSB002.js
================================================
'use strict';
let AbstractBridgeModel = require('./AbstractBridgeModel');
const DETAILS = {
id: 'BSB002',
manufacturer: 'Philips',
name: 'Hue v2',
};
/**
* Bridge model: BSB002
*/
class BSB002 extends AbstractBridgeModel {
/**
* Constructor
*/
constructor() {
super(DETAILS);
}
}
module.exports = BSB002;
================================================
FILE: lib/BridgeModel/Factory.js
================================================
'use strict';
const SUPPORTED_BRIDGES = [
'BSB001',
'BSB002',
'Unknown',
];
/**
* Factory for Bridge Models
*/
class Factory {
/**
* Create bridge model
*
* @param {string} modelId Model Id
*
* @return {AbstractBridgeModel} Bridge model
*/
static createBridgeModel(modelId) {
if (SUPPORTED_BRIDGES.indexOf(modelId) === -1) {
modelId = 'Unknown';
}
let BridgeModel = require(`./${modelId}`);
return new BridgeModel;
}
}
module.exports = Factory;
================================================
FILE: lib/BridgeModel/Unknown.js
================================================
'use strict';
let AbstractBridgeModel = require('./AbstractBridgeModel');
const DETAILS = {
id: null,
manufacturer: null,
name: null,
};
/**
* Bridge model: Unknown
*/
class Unknown extends AbstractBridgeModel {
/**
* Constructor
*/
constructor() {
super(DETAILS);
}
}
module.exports = Unknown;
================================================
FILE: lib/CapabilityModel/AbstractCapabilityModel.js
================================================
'use strict';
/**
* Abstract capability model
*/
class AbstractCapabilityModel {
/**
* Constructor
*
* @param {Object} details Capability model details
*/
constructor(details) {
this.details = Object.assign({}, details);
}
/**
* Available
*
* @param {int} Available
*/
get available() {
return this.details.available;
}
}
module.exports = AbstractCapabilityModel;
================================================
FILE: lib/CapabilityModel/Groups.js
================================================
'use strict';
let AbstractCapabilityModel = require('./AbstractCapabilityModel');
/**
* Groups capability model
*/
class Groups extends AbstractCapabilityModel {}
module.exports = Groups;
================================================
FILE: lib/CapabilityModel/Lights.js
================================================
'use strict';
let AbstractCapabilityModel = require('./AbstractCapabilityModel');
/**
* Lights capability model
*/
class Lights extends AbstractCapabilityModel {}
module.exports = Lights;
================================================
FILE: lib/CapabilityModel/ResourceLinks.js
================================================
'use strict';
let AbstractCapabilityModel = require('./AbstractCapabilityModel');
/**
* Resource links capability model
*/
class ResourceLinks extends AbstractCapabilityModel {}
module.exports = ResourceLinks;
================================================
FILE: lib/CapabilityModel/Rules.js
================================================
'use strict';
let AbstractCapabilityModel = require('./AbstractCapabilityModel');
/**
* Rules capability model
*/
class Rules extends AbstractCapabilityModel {
/**
* Get conditions available
*
* @params {int} Available
*/
get conditionsAvailable() {
return this.details.conditions.available;
}
/**
* Get actions available
*
* @params {int} Available
*/
get actionsAvailable() {
return this.details.actions.available;
}
}
module.exports = Rules;
================================================
FILE: lib/CapabilityModel/Scenes.js
================================================
'use strict';
let AbstractCapabilityModel = require('./AbstractCapabilityModel');
/**
* Scenes capability model
*/
class Scenes extends AbstractCapabilityModel {
/**
* Get light states available
*
* @params {int} Available
*/
get lightStatesAvailable() {
return this.details.lightstates.available;
}
}
module.exports = Scenes;
================================================
FILE: lib/CapabilityModel/Schedules.js
================================================
'use strict';
let AbstractCapabilityModel = require('./AbstractCapabilityModel');
/**
* Schedules capability model
*/
class Schedules extends AbstractCapabilityModel {}
module.exports = Schedules;
================================================
FILE: lib/CapabilityModel/Sensors.js
================================================
'use strict';
let AbstractCapabilityModel = require('./AbstractCapabilityModel');
/**
* Sensors capability model
*/
class Sensors extends AbstractCapabilityModel {
/**
* Get clip available
*
* @params {int} Available
*/
get clipAvailable() {
return this.details.clip.available;
}
/**
* Get zll available
*
* @params {int} Available
*/
get zllAvailable() {
return this.details.zll.available;
}
/**
* Get zgps available
*
* @params {int} Available
*/
get zgpAvailable() {
return this.details.zgp.available;
}
}
module.exports = Sensors;
================================================
FILE: lib/Client.js
================================================
'use strict';
const DEFAULT_CONFIG = {
host: undefined,
port: 80,
username: undefined,
timeout: 15000,
};
/**
* Client
*
* Serves as client to the bridge
*/
class Client {
/**
* Constructor
*
* @param {Object} config Configuration
*/
constructor(config) {
this.config = Object.assign({}, DEFAULT_CONFIG, config);
this.accessors = {};
}
/**
* Get host
*
* @return {string} Host
*/
get host() {
return this.config.host;
}
/**
* Set host
*
* @param {string} host Host
*/
set host(host) {
this.config.host = host;
}
/**
* Get port
*
* @return {int} Port
*/
get port() {
return this.config.port;
}
/**
* Set port
*
* @param {int} port Port
*/
set port(port) {
this.config.port = Number(port);
}
/**
* Get username
*
* @return {string} Username
*/
get username() {
return this.config.username;
}
/**
* Set username
*
* @param {string} username Username
*/
set username(username) {
this.config.username = username;
}
/**
* Get timeout
*
* @return {int} Timeout
*/
get timeout() {
return this.config.timeout;
}
/**
* Set timeout
*
* @param {int} timeout Timeout
*/
set timeout(timeout) {
this.config.timeout = Number(timeout);
}
/**
* Get bridge accessor
*
* @return {mixed} Bridge accessor
*/
get bridge() {
return this.loadAccessor('Bridge');
}
/**
* Get portal accessor
*
* @return {mixed} Portal accessor
*/
get portal() {
return this.loadAccessor('Portal');
}
/**
* Get internet services
*
* @return {mixed} Internet services accessor
*/
get internetServices() {
return this.loadAccessor('InternetServices');
}
/**
* Get sofware update accessor
*
* @return {mixed} Software update accessor
*/
get softwareUpdate() {
return this.loadAccessor('SoftwareUpdate');
}
/**
* Get users accessor
*
* @return {mixed} Users accessor
*/
get users() {
return this.loadAccessor('Users');
}
/**
* Get lights accessor
*
* @return {mixed} Lights accessor
*/
get lights() {
return this.loadAccessor('Lights');
}
/**
* Get groups accessor
*
* @return {mixed} Groups accessor
*/
get groups() {
return this.loadAccessor('Groups');
}
/**
* Get scenes accessor
*
* @return {mixed} Scenes accessor
*/
get scenes() {
return this.loadAccessor('Scenes');
}
/**
* Get schedules accessor
*
* @return {mixed} Schedules accessor
*/
get schedules() {
return this.loadAccessor('Schedules');
}
/**
* Get sensors accessor
*
* @return {mixed} Sensors accessor
*/
get sensors() {
return this.loadAccessor('Sensors');
}
/**
* Get rules accessor
*
* @return {mixed} Rules accessor
*/
get rules() {
return this.loadAccessor('Rules');
}
/**
* Get actions accessor
*
* @return {mixed} Actions accessor
*/
get actions() {
return this.loadAccessor('Actions');
}
/**
* Get time patterns accessor
*
* @return {mixed} Time patterns accessor
*/
get timePatterns() {
return this.loadAccessor('TimePatterns');
}
/**
* Get resource links accessor
*
* @return {mixed} Resource links accessor
*/
get resourceLinks() {
return this.loadAccessor('ResourceLinks');
}
/**
* Get capabilities accessor
*
* @return {mixed} Capabilities accessor
*/
get capabilities() {
return this.loadAccessor('Capabilities');
}
/**
* Get time zones accessor
*
* @return {mixed} Time zones accessor
*/
get timeZones() {
return this.loadAccessor('TimeZones');
}
/**
* Load accessor
*
* @param {string} accessor Accessor name
*
* @return {mixed} Accessor
*/
loadAccessor(accessor) {
if (!this.accessors[accessor]) {
let Accessor = require(`./Accessor/${accessor}`);
this.accessors[accessor] = new Accessor(this);
}
return this.accessors[accessor];
}
/**
* Get transport
*
* @return {Transport} Transport (http)
*/
getTransport() {
if (this.transport === undefined) {
let Transport = new require('./Transport');
this.transport = new Transport(this);
}
return this.transport;
}
/**
* Invoke command
*
* @param {mixed} command Command
*
* @return {mixed} Result from command
*/
invokeCommand(command) {
return command.invoke(this);
}
}
module.exports = Client;
================================================
FILE: lib/Command/Bridge/EnableLinkButton.js
================================================
'use strict';
/**
* Enable Link Button command
*
* Enable link button
*/
class EnableLinkButton {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'PUT',
url: `api/${client.username}/config`,
data: {
'linkbutton': true
}
};
return client.getTransport()
.sendRequest(options)
.then(() => true);
}
}
module.exports = EnableLinkButton;
================================================
FILE: lib/Command/Bridge/EnableTouchlink.js
================================================
'use strict';
/**
* Enable Touchlink command
*
* Enable Touchlink
*/
class EnableTouchlink {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'PUT',
url: `api/${client.username}/config`,
data: {
'touchlink': true
}
};
return client.getTransport()
.sendRequest(options)
.then(() => true);
}
}
module.exports = EnableTouchlink;
================================================
FILE: lib/Command/Bridge/GetBridge.js
================================================
'use strict';
let Utils = require('./Utils');
/**
* Get bridge command
*
* Get bridge info and configuration
*/
class GetBridge {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: client.username !== undefined
? `api/${client.username}/config`
: 'api/config'
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return Utils.buildBridge(result);
});
}
}
module.exports = GetBridge;
================================================
FILE: lib/Command/Bridge/IsAuthenticated.js
================================================
'use strict';
/**
* Is authenticated command
*
* Determines if user is authenticated to bridge
*/
class IsAuthenticated {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
// Time zone retrieval as it requires user and not resource intensive
url: `api/${client.username}/info/timezones`
};
return client.getTransport()
.sendRequest(options)
.then(() => true);
}
}
module.exports = IsAuthenticated;
================================================
FILE: lib/Command/Bridge/Ping.js
================================================
'use strict';
/**
* Ping command
*
* Pings bridge
*/
class Ping {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: 'api/config'
};
return client.getTransport()
.sendRequest(options)
.then(() => true);
}
}
module.exports = Ping;
================================================
FILE: lib/Command/Bridge/SaveBridge.js
================================================
'use strict';
let Utils = require('./Utils');
const ALLOWED_ATTRIBUTES = [
'name',
'zigbeechannel',
'ipaddress',
'dhcp',
'netmask',
'gateway',
'proxyport',
'proxyaddress',
'timezone',
'linkbutton',
'touchlink',
];
/**
* Save bridge command
*
* Saves bridge
*/
class SaveBridge {
/**
* Constructor
*
* @param {Bridge} bridge Bridge
*/
constructor(bridge) {
Utils.validateBridge(bridge);
this.bridge = bridge;
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let promises = [];
let attributes = this.bridge.attributes.getChanged();
for (let key of ALLOWED_ATTRIBUTES) {
if (key in attributes) {
promises.push(
this.saveBridgeAttribute(
client,
key,
attributes[key]
)
);
}
}
return Promise.all(promises)
.then(results => {
this.bridge.attributes.resetChanged();
return this.bridge;
});
}
/**
* Save bridge attribute
*
* @param {Client} client Client
* @param {string} attribute Attribute
* @param {mixed} value Value
*
* @return {Promise} Promise for chaining
*/
saveBridgeAttribute(client, attribute, value) {
let options = {
method: 'PUT',
url: `api/${client.username}/config`,
data: {}
};
options.data[attribute] = value;
return client.getTransport()
.sendRequest(options);
}
}
module.exports = SaveBridge;
================================================
FILE: lib/Command/Bridge/Utils.js
================================================
'use strict';
let Bridge = require('../../Model/Bridge');
let Error = require('../../Error');
const BRIDGE_ATTRIBUTES = [
'bridgeid',
'name',
'modelid',
'factorynew',
'replacesbridgeid',
'datastoreversion',
'starterkitid',
'zigbeechannel',
'apiversion',
'swversion',
'mac',
'ipaddress',
'dhcp',
'netmask',
'gateway',
'proxyaddress',
'proxyport',
'UTC',
'localtime',
'timezone',
'portalservices',
'portalconnection',
'linkbutton',
'touchlink',
];
/**
* Bridge utils
*/
class Utils {
/**
* Validate bridge
*
* @param {mixed} bridge Bridge object
*
* @return {bool} True if valid
*/
static validateBridge(bridge) {
if (bridge instanceof Bridge) {
return true;
}
throw new Error({
message: 'Expecting Bridge'
});
}
/**
* Build bridge
*
* @param {Object} result Result
*
* @return {Bridge} Bridge
*/
static buildBridge(result) {
return new Bridge(
this.mapBridgeAttributes(result)
);
}
/**
* Map bridge attributes
*
* @param {Object} result Result
*
* @return {Object} Attributes
*/
static mapBridgeAttributes(result) {
let attributes = {};
if (result === undefined) {
return attributes;
}
for (let key of BRIDGE_ATTRIBUTES) {
if (key in result) {
attributes[key] = result[key];
}
}
return attributes;
}
}
module.exports = Utils;
================================================
FILE: lib/Command/Capability/GetGroups.js
================================================
'use strict';
let Groups = require('../../CapabilityModel/Groups');
/**
* Get groups command
*/
class GetGroups {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/capabilities`,
raw: true
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return new Groups(result.groups);
});
}
}
module.exports = GetGroups;
================================================
FILE: lib/Command/Capability/GetLights.js
================================================
'use strict';
let Lights = require('../../CapabilityModel/Lights');
/**
* Get lights command
*/
class GetLights {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/capabilities`,
raw: true
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return new Lights(result.lights);
});
}
}
module.exports = GetLights;
================================================
FILE: lib/Command/Capability/GetResourceLinks.js
================================================
'use strict';
let ResourceLinks = require('../../CapabilityModel/ResourceLinks');
/**
* Get resource links command
*/
class GetResourceLinks {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/capabilities`,
raw: true
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return new ResourceLinks(result.resourcelinks);
});
}
}
module.exports = GetResourceLinks;
================================================
FILE: lib/Command/Capability/GetRules.js
================================================
'use strict';
let Rules = require('../../CapabilityModel/Rules');
/**
* Get rules command
*/
class GetRules {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/capabilities`,
raw: true
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return new Rules(result.rules);
});
}
}
module.exports = GetRules;
================================================
FILE: lib/Command/Capability/GetScenes.js
================================================
'use strict';
let Scenes = require('../../CapabilityModel/Scenes');
/**
* Get scenes command
*/
class GetScenes {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/capabilities`,
raw: true
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return new Scenes(result.scenes);
});
}
}
module.exports = GetScenes;
================================================
FILE: lib/Command/Capability/GetSchedules.js
================================================
'use strict';
let Schedules = require('../../CapabilityModel/Schedules');
/**
* Get schedules command
*/
class GetSchedules {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/capabilities`,
raw: true
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return new Schedules(result.schedules);
});
}
}
module.exports = GetSchedules;
================================================
FILE: lib/Command/Capability/GetSensors.js
================================================
'use strict';
let Sensors = require('../../CapabilityModel/Sensors');
/**
* Get sensors command
*/
class GetSensors {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/capabilities`,
raw: true
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return new Sensors(result.sensors);
});
}
}
module.exports = GetSensors;
================================================
FILE: lib/Command/Capability/GetTimeZones.js
================================================
'use strict';
/**
* Get time zones command
*
* Get a list of supported time zones
*/
class GetTimeZones {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/capabilities`,
raw: true
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return result.timezones.values;
});
}
}
module.exports = GetTimeZones;
================================================
FILE: lib/Command/Group/CreateGroup.js
================================================
'use strict';
let Utils = require('./Utils');
const ALLOWED_ATTRIBUTES = [
'name',
'type',
'class',
'lights',
];
/**
* Create group command
*
* Create a group
*/
class CreateGroup {
/**
* Constructor
*
* @param {Group} group Group
*/
constructor(group) {
Utils.validateGroup(group);
this.group = group;
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'POST',
url: `api/${client.username}/groups`,
data: {}
};
let attributes = this.group.attributes.getAll();
for (let key of ALLOWED_ATTRIBUTES) {
if (key in attributes) {
options.data[key] = attributes[key];
}
}
return client.getTransport()
.sendRequest(options)
.then(result => {
this.group.attributes.resetChanged();
this.group.attributes.replace({
id: result.id
});
return this.group;
});
}
}
module.exports = CreateGroup;
================================================
FILE: lib/Command/Group/DeleteGroup.js
================================================
'use strict';
/**
* Delete group command
*
* Delete a group by id
*/
class DeleteGroup {
/**
* Constructor
*
* @param {string} groupId Group Id or Group object
*/
constructor(groupId) {
this.groupId = String(groupId);
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'DELETE',
url: `api/${client.username}/groups/${this.groupId}`
};
return client.getTransport()
.sendRequest(options)
.then(() => true);
}
}
module.exports = DeleteGroup;
================================================
FILE: lib/Command/Group/GetGroup.js
================================================
'use strict';
let Utils = require('./Utils');
/**
* Get group command
*
* Get a group by id
*/
class GetGroup {
/**
* Constructor
*
* @param {int} groupId Group Id
*/
constructor(groupId) {
this.groupId = Number(groupId);
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/groups/${this.groupId}`
};
return client.getTransport()
.sendRequest(options)
.then(result => {
result.id = this.groupId;
return Utils.buildGroup(result);
});
}
}
module.exports = GetGroup;
================================================
FILE: lib/Command/Group/GetGroups.js
================================================
'use strict';
let Utils = require('./Utils');
/**
* Get groups command
*
* Get a list of groups
*/
class GetGroups {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/groups`
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return Object.keys(result).map(groupId => {
result[groupId].id = groupId;
return Utils.buildGroup(result[groupId]);
});
});
}
}
module.exports = GetGroups;
================================================
FILE: lib/Command/Group/SaveGroup.js
================================================
'use strict';
let Utils = require('./Utils');
const ALLOWED_ATTRIBUTES = [
'name',
'lights'
];
/**
* Save group command
*
* Save a group
*/
class SaveGroup {
/**
* Constructor
*
* @param {Group} group Group
*/
constructor(group) {
Utils.validateGroup(group);
this.group = group;
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'PUT',
url: `api/${client.username}/groups/${this.group.id}`,
data: {}
};
let attributes = this.group.attributes.getChanged();
for (let key of ALLOWED_ATTRIBUTES) {
if (key in attributes) {
options.data[key] = attributes[key];
}
}
return client.getTransport()
.sendRequest(options)
.then(() => {
this.group.attributes.resetChanged();
return this.group;
});
}
}
module.exports = SaveGroup;
================================================
FILE: lib/Command/Group/SaveGroupAction.js
================================================
'use strict';
let Utils = require('./Utils');
const ALLOWED_ACTION = [
'on',
'bri',
'hue',
'sat',
'xy',
'ct',
'alert',
'effect',
'scene',
'transitiontime',
'bri_inc',
'hue_inc',
'sat_inc',
'xy_inc',
'ct_inc',
];
/**
* Save group action command
*
* Saves group action
*/
class SaveGroupAction {
/**
* Constructor
*
* @param {Group} group Group
*/
constructor(group) {
Utils.validateGroup(group);
this.group = group;
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'PUT',
url: `api/${client.username}/groups/${this.group.id}/action`,
data: {},
multi: true
};
let attributes = this.group.action.getChanged();
for (let key of ALLOWED_ACTION) {
if (key in attributes) {
options.data[key] = attributes[key];
}
}
return client.getTransport()
.sendRequest(options)
.then(results => {
this.refreshGroupAction(results);
return this.group;
});
}
/**
* Refresh group action
*
* @param {Object} results Results
*/
refreshGroupAction(results) {
this.group.action.resetChanged();
let newAction = {};
for (let i in results) {
let key = i.match(/\/action\/(\w+)$/)[1];
newAction[key] = results[i];
}
this.group.action.replace(Utils.mapGroupAction(newAction));
}
}
module.exports = SaveGroupAction;
================================================
FILE: lib/Command/Group/Utils.js
================================================
'use strict';
let Error = require('../../Error');
let Group = require('../../Model/Group');
const GROUP_ATTRIBUTES = [
'id',
'name',
'type',
'class',
'lights',
'modelid',
'uniqueid'
];
const GROUP_STATE = [
'any_on',
'all_on'
];
const GROUP_ACTION_ATTRIBUTES = [
'on',
'bri',
'colormode',
'hue',
'sat',
'xy',
'ct',
'transitiontime',
'alert',
'effect',
'scene'
];
/**
* Group utils
*/
class Utils {
/**
* Validate group
*
* @param {mixed} group Group object
*
* @return {bool} True if valid
*/
static validateGroup(group) {
if (group instanceof Group) {
return true;
}
throw new Error({
message: 'Expecting Group'
});
}
/**
* Build group
*
* @param {Object} result Result
*
* @return {Group} Group
*/
static buildGroup(result) {
return new Group(
this.mapGroupAttributes(result),
this.mapGroupState(result.state),
this.mapGroupAction(result.action)
);
}
/**
* Map group attributes
*
* @param {Object} result Result
*
* @return {Object} Attributes
*/
static mapGroupAttributes(result) {
let attributes = {};
if (result === undefined) {
return attributes;
}
for (let key of GROUP_ATTRIBUTES) {
if (key in result) {
attributes[key] = result[key];
}
}
return attributes;
}
/**
* Map group state
*
* @param {Object} result Result
*
* @return {Object} State
*/
static mapGroupState(result) {
let state = {};
if (result === undefined) {
return state;
}
for (let key of GROUP_STATE) {
if (key in result) {
state[key] = result[key];
}
}
return state;
}
/**
* Map group action
*
* @param {Object} result Result
*
* @return {Object} Action
*/
static mapGroupAction(result) {
let action = {};
if (result === undefined) {
return action;
}
for (let key of GROUP_ACTION_ATTRIBUTES) {
if (key in result) {
action[key] = result[key];
}
}
return action;
}
}
module.exports = Utils;
================================================
FILE: lib/Command/InternetServices/GetInternetServices.js
================================================
'use strict';
let Utils = require('./Utils');
/**
* Get internet services command
*
* Get internet services connectivity info
*/
class GetInternetServices {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/config`
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return Utils.buildInternetServices(result.internetservices);
});
}
}
module.exports = GetInternetServices;
================================================
FILE: lib/Command/InternetServices/Utils.js
================================================
'use strict';
let InternetServices = require('../../Model/InternetServices');
const INTERNET_SERVICES_ATTRIBUTES = [
'internet',
'remoteaccess',
'time',
'swupdate',
];
/**
* Internet services utils
*/
class Utils {
/**
* Build internet services
*
* @param {Object} result Result
*
* @return {InternetServices} Internet services
*/
static buildInternetServices(result) {
return new InternetServices(
this.mapInternetServicesAttributes(result)
);
}
/**
* Map internet services attributes
*
* @param {Object} result Result
*
* @return {Object} Attributes
*/
static mapInternetServicesAttributes(result) {
let attributes = {};
if (result === undefined) {
return attributes;
}
for (let key of INTERNET_SERVICES_ATTRIBUTES) {
if (key in result) {
attributes[key] = result[key];
}
}
return attributes;
}
}
module.exports = Utils;
================================================
FILE: lib/Command/Light/DeleteLight.js
================================================
'use strict';
/**
* Delete light command
*
* Delete a light by id
*/
class DeleteLight {
/**
* Constructor
*
* @param {string} lightId Light Id or Light object
*/
constructor(lightId) {
this.lightId = String(lightId);
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'DELETE',
url: `api/${client.username}/lights/${this.lightId}`
};
return client.getTransport()
.sendRequest(options)
.then(() => true);
}
}
module.exports = DeleteLight;
================================================
FILE: lib/Command/Light/GetLight.js
================================================
'use strict';
let Utils = require('./Utils');
/**
* Get light command
*
* Get a light by id
*/
class GetLight {
/**
* Constructor
*
* @param {int} lightId Light Id
*/
constructor(lightId) {
this.lightId = Number(lightId);
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/lights/${this.lightId}`
};
return client.getTransport()
.sendRequest(options)
.then(result => {
result.id = this.lightId;
return Utils.buildLight(result);
});
}
}
module.exports = GetLight;
================================================
FILE: lib/Command/Light/GetLights.js
================================================
'use strict';
let Utils = require('./Utils');
/**
* Get lights command
*
* Get a list of lights
*/
class GetLights {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/lights`
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return Object.keys(result).map(lightId => {
result[lightId].id = lightId;
return Utils.buildLight(result[lightId]);
});
});
}
}
module.exports = GetLights;
================================================
FILE: lib/Command/Light/GetNewLights.js
================================================
'use strict';
let GetLights = require('./GetLights');
/**
* Get new lights command
*
* Get a list of new lights
*/
class GetNewLights {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/lights/new`
};
return client.getTransport()
.sendRequest(options)
.then(result => {
delete result.lastscan;
let newLightIds = Object.keys(result);
return (new GetLights).invoke(client)
.then(lights => {
let newLights = [];
for (let light of lights) {
if (newLightIds.indexOf(light.id) > -1) {
newLights.push(light);
}
}
return newLights;
});
});
}
}
module.exports = GetNewLights;
================================================
FILE: lib/Command/Light/SaveLight.js
================================================
'use strict';
let Utils = require('./Utils');
const ALLOWED_ATTRIBUTES = [
'name'
];
/**
* Save light command
*
* Saves light
*/
class SaveLight {
/**
* Constructor
*
* @param {Light} light Light
*/
constructor(light) {
Utils.validateLight(light);
this.light = light;
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let promises = [];
let attributes = this.light.attributes.getChanged();
for (let key of ALLOWED_ATTRIBUTES) {
if (key in attributes) {
promises.push(
this.saveLightAttribute(
client,
key,
attributes[key]
)
);
}
}
return Promise.all(promises)
.then(results => {
this.light.attributes.resetChanged();
return this.light;
});
}
/**
* Save light attribute
*
* @param {Client} client Client
* @param {string} attribute Attribute
* @param {mixed} value Value
*
* @return {Promise} Promise for chaining
*/
saveLightAttribute(client, attribute, value) {
let options = {
method: 'PUT',
url: `api/${client.username}/lights/${this.light.id}`,
data: {}
};
options.data[attribute] = value;
return client.getTransport()
.sendRequest(options);
}
}
module.exports = SaveLight;
================================================
FILE: lib/Command/Light/SaveLightState.js
================================================
'use strict';
let Utils = require('./Utils');
const ALLOWED_STATE = [
'on',
'bri',
'hue',
'sat',
'xy',
'ct',
'alert',
'effect',
'transitiontime',
'bri_inc',
'hue_inc',
'sat_inc',
'xy_inc',
'ct_inc',
];
/**
* Save light state command
*
* Saves light state
*/
class SaveLightState {
/**
* Constructor
*
* @param {Light} light Light
*/
constructor(light) {
Utils.validateLight(light);
this.light = light;
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'PUT',
url: `api/${client.username}/lights/${this.light.id}/state`,
data: {},
multi: true
};
let attributes = this.light.state.getChanged()
for (let key of ALLOWED_STATE) {
if (key in attributes) {
options.data[key] = attributes[key];
}
}
return client.getTransport()
.sendRequest(options)
.then(results => {
this.refreshLightState(results);
return this.light;
});
}
/**
* Refresh light state
*
* @param {Object} results Results
*/
refreshLightState(results) {
this.light.state.resetChanged();
let newState = {};
for (let i in results) {
let key = i.match(/\/state\/(\w+)$/)[1];
newState[key] = results[i];
}
this.light.state.replace(newState);
}
}
module.exports = SaveLightState;
================================================
FILE: lib/Command/Light/StartLightScan.js
================================================
'use strict';
/**
* Start light scan command
*
* Start a scan for new lights
*/
class StartLightScan {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'POST',
url: `api/${client.username}/lights`
};
return client.getTransport()
.sendRequest(options)
.then(() => true);
}
}
module.exports = StartLightScan;
================================================
FILE: lib/Command/Light/Utils.js
================================================
'use strict';
let Error = require('../../Error');
let Light = require('../../Model/Light');
const LIGHT_ATTRIBUTES = [
'id',
'name',
'type',
'uniqueid',
'manufacturername',
'modelid',
'productid',
'swversion',
'swconfigid'
];
const LIGHT_STATE_ATTRIBUTES = [
'on',
'reachable',
'bri',
'colormode',
'hue',
'sat',
'xy',
'ct',
'transitiontime',
'alert',
'effect'
];
/**
* Light utils
*/
class Utils {
/**
* Validate light
*
* @param {mixed} light Light object
*
* @return {bool} True if valid
*/
static validateLight(light) {
if (light instanceof Light) {
return true;
}
throw new Error({
message: 'Expecting Light'
});
}
/**
* Build light
*
* @param {Object} result Result
*
* @return {Light} Light
*/
static buildLight(result) {
return new Light(
this.mapLightAttributes(result),
this.mapLightState(result.state)
);
}
/**
* Map light attributes
*
* @param {Object} result Result
*
* @return {Object} Attributes
*/
static mapLightAttributes(result) {
let attributes = {};
if (result === undefined) {
return attributes;
}
for (let key of LIGHT_ATTRIBUTES) {
if (key in result) {
attributes[key] = result[key];
}
}
return attributes;
}
/**
* Map light state
*
* @param {Object} result Result
*
* @return {Object} State
*/
static mapLightState(result) {
let state = {};
if (result === undefined) {
return state;
}
for (let key of LIGHT_STATE_ATTRIBUTES) {
if (key in result) {
state[key] = result[key];
}
}
return state;
}
}
module.exports = Utils;
================================================
FILE: lib/Command/Portal/GetPortal.js
================================================
'use strict';
let Utils = require('./Utils');
/**
* Get portal command
*
* Get portal connectivity info
*/
class GetPortal {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/config`
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return Utils.buildPortal(result.portalstate);
});
}
}
module.exports = GetPortal;
================================================
FILE: lib/Command/Portal/Utils.js
================================================
'use strict';
let Portal = require('../../Model/Portal');
const PORTAL_ATTRIBUTES = [
'signedon',
'incoming',
'outgoing',
'communication',
];
/**
* Portal utils
*/
class Utils {
/**
* Build portal
*
* @param {Object} result Result
*
* @return {Portal} Portal
*/
static buildPortal(result) {
return new Portal(
this.mapPortalAttributes(result)
);
}
/**
* Map portal attributes
*
* @param {Object} result Result
*
* @return {Object} Attributes
*/
static mapPortalAttributes(result) {
let attributes = {};
if (result === undefined) {
return attributes;
}
for (let key of PORTAL_ATTRIBUTES) {
if (key in result) {
attributes[key] = result[key];
}
}
return attributes;
}
}
module.exports = Utils;
================================================
FILE: lib/Command/ResourceLinks/CreateResourceLink.js
================================================
'use strict';
let Utils = require('./Utils');
const ALLOWED_ATTRIBUTES = [
'name',
'description',
'classid',
'recycle',
'links'
];
/**
* Create resource link command
*
* Create a resource link
*/
class CreateResourceLink {
/**
* Constructor
*
* @param {ResourceLink} resourceLink Resource Link
*/
constructor(resourceLink) {
Utils.validateResourceLink(resourceLink);
this.resourceLink = resourceLink;
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'POST',
url: `api/${client.username}/resourcelinks`,
data: {}
};
let attributes = this.resourceLink.attributes.getAll();
for (let key of ALLOWED_ATTRIBUTES) {
if (key in attributes) {
options.data[key] = attributes[key];
}
}
return client.getTransport()
.sendRequest(options)
.then(result => {
this.resourceLink.attributes.resetChanged();
this.resourceLink.attributes.replace({
id: result.id
});
return this.resourceLink;
});
}
}
module.exports = CreateResourceLink;
================================================
FILE: lib/Command/ResourceLinks/DeleteResourceLink.js
================================================
'use strict';
/**
* Delete resource link command
*
* Delete a resource link by id
*/
class DeleteResourceLink {
/**
* Constructor
*
* @param {string} resourceLinkId Resource Link Id or ResourceLink object
*/
constructor(resourceLinkId) {
this.resourceLinkId = String(resourceLinkId);
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'DELETE',
url: `api/${client.username}/resourcelinks/${this.resourceLinkId}`
};
return client.getTransport()
.sendRequest(options)
.then(() => true);
}
}
module.exports = DeleteResourceLink;
================================================
FILE: lib/Command/ResourceLinks/GetResourceLink.js
================================================
'use strict';
let Utils = require('./Utils');
/**
* Get resource link command
*
* Get a resource link by id
*/
class GetResourceLink {
/**
* Constructor
*
* @param {int} resourceLinkId Resource link Id
*/
constructor(resourceLinkId) {
this.resourceLinkId = Number(resourceLinkId);
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/resourcelinks/${this.resourceLinkId}`
};
return client.getTransport()
.sendRequest(options)
.then(result => {
result.id = this.resourceLinkId;
return Utils.buildResourceLink(result);
});
}
}
module.exports = GetResourceLink;
================================================
FILE: lib/Command/ResourceLinks/GetResourceLinks.js
================================================
'use strict';
let Utils = require('./Utils');
/**
* Get resource links command
*
* Get a list of resource links
*/
class GetResourceLinks {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/resourcelinks`
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return Object.keys(result).map(resourceLinkId => {
result[resourceLinkId].id = resourceLinkId;
return Utils.buildResourceLink(result[resourceLinkId]);
});
});
}
}
module.exports = GetResourceLinks;
================================================
FILE: lib/Command/ResourceLinks/SaveResourceLink.js
================================================
'use strict';
let Utils = require('./Utils');
const ALLOWED_ATTRIBUTES = [
'name',
'description',
'links'
];
/**
* Save resource link command
*
* Save a resource link
*/
class SaveResourceLink {
/**
* Constructor
*
* @param {ResourceLink} resourceLink Resource Link
*/
constructor(resourceLink) {
Utils.validateResourceLink(resourceLink);
this.resourceLink = resourceLink;
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'PUT',
url: `api/${client.username}/resourcelinks/${this.resourceLink.id}`,
data: {}
};
let attributes = this.resourceLink.attributes.getChanged();
for (let key of ALLOWED_ATTRIBUTES) {
if (key in attributes) {
options.data[key] = attributes[key];
}
}
return client.getTransport()
.sendRequest(options)
.then(() => {
this.resourceLink.attributes.resetChanged();
return this.resourceLink;
});
}
}
module.exports = SaveResourceLink;
================================================
FILE: lib/Command/ResourceLinks/Utils.js
================================================
'use strict';
let Error = require('../../Error');
let ResourceLink = require('../../Model/ResourceLink');
const RESOURCE_LINK_ATTRIBUTES = [
'id',
'name',
'description',
'type',
'classid',
'owner',
'recycle',
'links'
];
/**
* Resource link utils
*/
class Utils {
/**
* Validate resource link
*
* @param {mixed} resourceLink ResourceLink object
*
* @return {bool} True if valid
*/
static validateResourceLink(resourceLink) {
if (resourceLink instanceof ResourceLink) {
return true;
}
throw new Error({
message: 'Expecting Resource Link'
});
}
/**
* Build resource link
*
* @param {Object} result Result
*
* @return {ResourceLink} Resource link
*/
static buildResourceLink(result) {
return new ResourceLink(
this.mapResourceLinkAttributes(result)
);
}
/**
* Map resource link attributes
*
* @param {Object} result Result
*
* @return {Object} Attributes
*/
static mapResourceLinkAttributes(result) {
let attributes = {};
if (result === undefined) {
return attributes;
}
for (let key of RESOURCE_LINK_ATTRIBUTES) {
if (key in result) {
attributes[key] = result[key];
}
}
return attributes;
}
}
module.exports = Utils;
================================================
FILE: lib/Command/Rule/CreateRule.js
================================================
'use strict';
let Utils = require('./Utils');
const ALLOWED_ATTRIBUTES = [
'name',
'status',
'conditions',
'actions',
];
/**
* Create rule command
*
* Create a rule
*/
class CreateRule {
/**
* Constructor
*
* @param {Rule} rule Rule
*/
constructor(rule) {
Utils.validateRule(rule);
this.rule = rule;
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'POST',
url: `api/${client.username}/rules`,
data: {}
};
Utils.convertConditions(this.rule);
Utils.convertActions(this.rule);
let attributes = this.rule.attributes.getAll();
for (let key of ALLOWED_ATTRIBUTES) {
if (key in attributes) {
options.data[key] = attributes[key];
}
}
return client.getTransport()
.sendRequest(options)
.then(result => {
this.rule.attributes.resetChanged();
this.rule.attributes.replace({
id: result.id
});
return this.rule;
});
}
}
module.exports = CreateRule;
================================================
FILE: lib/Command/Rule/DeleteRule.js
================================================
'use strict';
/**
* Delete rule command
*
* Delete a rule by id
*/
class DeleteRule {
/**
* Constructor
*
* @param {string} ruleId Rule Id or Rule object
*/
constructor(ruleId) {
this.ruleId = String(ruleId);
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'DELETE',
url: `api/${client.username}/rules/${this.ruleId}`
};
return client.getTransport()
.sendRequest(options)
.then(() => true);
}
}
module.exports = DeleteRule;
================================================
FILE: lib/Command/Rule/GetRule.js
================================================
'use strict';
let Utils = require('./Utils');
/**
* Get rule command
*
* Get a rule by id
*/
class GetRule {
/**
* Constructor
*
* @param {string} ruleId Rule Id
*/
constructor(ruleId) {
this.ruleId = String(ruleId);
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/rules/${this.ruleId}`
};
return client.getTransport()
.sendRequest(options)
.then(result => {
result.id = this.ruleId;
return Utils.buildRule(result);
});
}
}
module.exports = GetRule;
================================================
FILE: lib/Command/Rule/GetRules.js
================================================
'use strict';
let Utils = require('./Utils');
/**
* Get rules command
*
* Get a list of rules
*/
class GetRules {
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
url: `api/${client.username}/rules`
};
return client.getTransport()
.sendRequest(options)
.then(result => {
return Object.keys(result).map(ruleId => {
result[ruleId].id = ruleId;
return Utils.buildRule(result[ruleId]);
})
});
}
}
module.exports = GetRules;
================================================
FILE: lib/Command/Rule/SaveRule.js
================================================
'use strict';
let Utils = require('./Utils');
const ALLOWED_ATTRIBUTES = [
'name',
'status',
'conditions',
'actions',
];
/**
* Save rule command
*
* Save a rule
*/
class SaveRule {
/**
* Constructor
*
* @param {Rule} rule Rule
*/
constructor(rule) {
Utils.validateRule(rule);
this.rule = rule;
}
/**
* Invoke command
*
* @param {Client} client Client
*
* @return {Promise} Promise for chaining
*/
invoke(client) {
let options = {
method: 'PUT',
url: `api/${client.username}/rules/${this.rule.id}`,
data: {}
};
Utils.convertConditions(this.rule);
Utils.convertActions(this.rule);
let attributes = this.rule.attributes.getChanged();
for (let key of ALLOWED_ATTRIBUTES) {
if (key in attributes) {
options.data[key] = attributes[key];
}
}
return client.getTransport()
.sendRequest(options)
.then(() => {
this.rule.attributes.resetChanged();
return this.rule;
});
}
}
module.exports = SaveRule;
================================================
FILE: lib/Command/Rule/Utils.js
================================================
'use strict';
let AbstractAction = require('../../Action/AbstractAction');
let Condition = require('../../Model/Condition');
let Error = req
gitextract_9a1zhf9_/
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── examples/
│ ├── .gitignore
│ ├── bridge/
│ │ ├── get-bridge.js
│ │ ├── is-authenticated.js
│ │ ├── lamp-stealer.js
│ │ ├── link-button.js
│ │ ├── ping.js
│ │ └── save-bridge.js
│ ├── capabilities/
│ │ ├── get-groups.js
│ │ ├── get-lights.js
│ │ ├── get-resource-links.js
│ │ ├── get-rules.js
│ │ ├── get-scenes.js
│ │ ├── get-schedules.js
│ │ ├── get-sensors.js
│ │ └── get-time-zones.js
│ ├── discover.js
│ ├── groups/
│ │ ├── get-groups.js
│ │ ├── increase-group-hs.js
│ │ ├── manage-group.js
│ │ └── manage-room-group.js
│ ├── init-client.js
│ ├── internet-services/
│ │ └── get-internet-services.js
│ ├── lights/
│ │ ├── get-light.js
│ │ ├── get-lights.js
│ │ ├── get-new-lights.js
│ │ ├── increase-light-hs.js
│ │ ├── save-light.js
│ │ └── start-light-scan.js
│ ├── portal/
│ │ └── get-portal.js
│ ├── resource-links/
│ │ ├── get-resource-link.js
│ │ ├── get-resource-links.js
│ │ └── manage-resource-link.js
│ ├── rules/
│ │ ├── get-rules.js
│ │ └── manage-rule.js
│ ├── scenes/
│ │ ├── get-scenes.js
│ │ ├── manage-scene.js
│ │ ├── recall-scene.js
│ │ └── save-scene.js
│ ├── schedules/
│ │ ├── get-schedules.js
│ │ └── manage-schedule.js
│ ├── sensors/
│ │ ├── create-switch.js
│ │ ├── get-sensors.js
│ │ ├── manage-sensor.js
│ │ └── update-switch.js
│ ├── software-update/
│ │ ├── check-for-software-updates.js
│ │ ├── disable-install-notification.js
│ │ ├── get-software-update.js
│ │ └── install-software-updates.js
│ ├── time-zones/
│ │ └── get-time-zones.js
│ └── users/
│ ├── create-user.js
│ ├── delete-user.js
│ ├── get-user.js
│ └── get-users.js
├── lib/
│ ├── Accessor/
│ │ ├── AbstractAccessor.js
│ │ ├── Actions.js
│ │ ├── Bridge.js
│ │ ├── Capabilities.js
│ │ ├── Groups.js
│ │ ├── InternetServices.js
│ │ ├── Lights.js
│ │ ├── Portal.js
│ │ ├── ResourceLinks.js
│ │ ├── Rules.js
│ │ ├── Scenes.js
│ │ ├── Schedules.js
│ │ ├── Sensors.js
│ │ ├── SoftwareUpdate.js
│ │ ├── TimePatterns.js
│ │ ├── TimeZones.js
│ │ └── Users.js
│ ├── Action/
│ │ ├── AbstractAction.js
│ │ ├── ChangeGroupAction.js
│ │ ├── ChangeLightState.js
│ │ └── ChangeSensorState.js
│ ├── BridgeModel/
│ │ ├── AbstractBridgeModel.js
│ │ ├── BSB001.js
│ │ ├── BSB002.js
│ │ ├── Factory.js
│ │ └── Unknown.js
│ ├── CapabilityModel/
│ │ ├── AbstractCapabilityModel.js
│ │ ├── Groups.js
│ │ ├── Lights.js
│ │ ├── ResourceLinks.js
│ │ ├── Rules.js
│ │ ├── Scenes.js
│ │ ├── Schedules.js
│ │ └── Sensors.js
│ ├── Client.js
│ ├── Command/
│ │ ├── Bridge/
│ │ │ ├── EnableLinkButton.js
│ │ │ ├── EnableTouchlink.js
│ │ │ ├── GetBridge.js
│ │ │ ├── IsAuthenticated.js
│ │ │ ├── Ping.js
│ │ │ ├── SaveBridge.js
│ │ │ └── Utils.js
│ │ ├── Capability/
│ │ │ ├── GetGroups.js
│ │ │ ├── GetLights.js
│ │ │ ├── GetResourceLinks.js
│ │ │ ├── GetRules.js
│ │ │ ├── GetScenes.js
│ │ │ ├── GetSchedules.js
│ │ │ ├── GetSensors.js
│ │ │ └── GetTimeZones.js
│ │ ├── Group/
│ │ │ ├── CreateGroup.js
│ │ │ ├── DeleteGroup.js
│ │ │ ├── GetGroup.js
│ │ │ ├── GetGroups.js
│ │ │ ├── SaveGroup.js
│ │ │ ├── SaveGroupAction.js
│ │ │ └── Utils.js
│ │ ├── InternetServices/
│ │ │ ├── GetInternetServices.js
│ │ │ └── Utils.js
│ │ ├── Light/
│ │ │ ├── DeleteLight.js
│ │ │ ├── GetLight.js
│ │ │ ├── GetLights.js
│ │ │ ├── GetNewLights.js
│ │ │ ├── SaveLight.js
│ │ │ ├── SaveLightState.js
│ │ │ ├── StartLightScan.js
│ │ │ └── Utils.js
│ │ ├── Portal/
│ │ │ ├── GetPortal.js
│ │ │ └── Utils.js
│ │ ├── ResourceLinks/
│ │ │ ├── CreateResourceLink.js
│ │ │ ├── DeleteResourceLink.js
│ │ │ ├── GetResourceLink.js
│ │ │ ├── GetResourceLinks.js
│ │ │ ├── SaveResourceLink.js
│ │ │ └── Utils.js
│ │ ├── Rule/
│ │ │ ├── CreateRule.js
│ │ │ ├── DeleteRule.js
│ │ │ ├── GetRule.js
│ │ │ ├── GetRules.js
│ │ │ ├── SaveRule.js
│ │ │ └── Utils.js
│ │ ├── Scene/
│ │ │ ├── CreateScene.js
│ │ │ ├── DeleteScene.js
│ │ │ ├── GetSceneById.js
│ │ │ ├── GetScenes.js
│ │ │ ├── RecallScene.js
│ │ │ ├── SaveScene.js
│ │ │ ├── SaveSceneLightState.js
│ │ │ └── Utils.js
│ │ ├── Schedule/
│ │ │ ├── CreateSchedule.js
│ │ │ ├── DeleteSchedule.js
│ │ │ ├── GetSchedule.js
│ │ │ ├── GetSchedules.js
│ │ │ ├── SaveSchedule.js
│ │ │ └── Utils.js
│ │ ├── Sensor/
│ │ │ ├── CreateSensor.js
│ │ │ ├── DeleteSensor.js
│ │ │ ├── GetNewSensors.js
│ │ │ ├── GetSensor.js
│ │ │ ├── GetSensors.js
│ │ │ ├── SaveSensor.js
│ │ │ ├── SaveSensorConfig.js
│ │ │ ├── SaveSensorState.js
│ │ │ ├── StartSensorScan.js
│ │ │ └── Utils.js
│ │ ├── SoftwareUpdate/
│ │ │ ├── CheckForSoftwareUpdates.js
│ │ │ ├── DisableInstallNotification.js
│ │ │ ├── GetSoftwareUpdate.js
│ │ │ ├── InstallSoftwareUpdates.js
│ │ │ └── Utils.js
│ │ ├── TimeZone/
│ │ │ └── GetTimeZones.js
│ │ └── User/
│ │ ├── CreateUser.js
│ │ ├── DeleteUser.js
│ │ ├── GetUser.js
│ │ ├── GetUsers.js
│ │ └── Utils.js
│ ├── Discovery.js
│ ├── DiscoveryStrategy/
│ │ ├── Nupnp.js
│ │ └── Upnp.js
│ ├── Error.js
│ ├── GroupModel/
│ │ ├── AbstractGroupModel.js
│ │ ├── Factory.js
│ │ ├── HBL001.js
│ │ ├── HBL002.js
│ │ ├── HBL003.js
│ │ ├── HEL001.js
│ │ ├── HEL002.js
│ │ ├── HIL001.js
│ │ ├── HIL002.js
│ │ ├── HML001.js
│ │ ├── HML002.js
│ │ ├── HML003.js
│ │ ├── HML004.js
│ │ ├── HML005.js
│ │ ├── HML006.js
│ │ ├── HML007.js
│ │ └── Unknown.js
│ ├── Huejay.js
│ ├── LightModel/
│ │ ├── AbstractLightModel.js
│ │ ├── Factory.js
│ │ ├── LCT001.js
│ │ ├── LCT002.js
│ │ ├── LCT003.js
│ │ ├── LCT007.js
│ │ ├── LCT010.js
│ │ ├── LCT011.js
│ │ ├── LCT012.js
│ │ ├── LCT014.js
│ │ ├── LLC006.js
│ │ ├── LLC007.js
│ │ ├── LLC010.js
│ │ ├── LLC011.js
│ │ ├── LLC012.js
│ │ ├── LLC013.js
│ │ ├── LLC014.js
│ │ ├── LLC020.js
│ │ ├── LLM001.js
│ │ ├── LLM010.js
│ │ ├── LLM011.js
│ │ ├── LLM012.js
│ │ ├── LST001.js
│ │ ├── LST002.js
│ │ ├── LTW001.js
│ │ ├── LTW004.js
│ │ ├── LTW010.js
│ │ ├── LTW011.js
│ │ ├── LTW012.js
│ │ ├── LTW013.js
│ │ ├── LTW014.js
│ │ ├── LTW015.js
│ │ ├── LWB004.js
│ │ ├── LWB006.js
│ │ ├── LWB007.js
│ │ ├── LWB010.js
│ │ ├── LWB014.js
│ │ └── Unknown.js
│ ├── Model/
│ │ ├── Attributes.js
│ │ ├── Bridge.js
│ │ ├── Condition.js
│ │ ├── Group.js
│ │ ├── InternetServices.js
│ │ ├── Light.js
│ │ ├── Portal.js
│ │ ├── ResourceLink.js
│ │ ├── Rule.js
│ │ ├── Scene.js
│ │ ├── Schedule.js
│ │ ├── Sensor.js
│ │ ├── SoftwareUpdate.js
│ │ └── User.js
│ ├── SensorModel/
│ │ ├── AbstractSensorModel.js
│ │ ├── Factory.js
│ │ ├── PHDL00.js
│ │ ├── RWL020.js
│ │ ├── RWL021.js
│ │ ├── SML001.js
│ │ ├── Unknown.js
│ │ └── ZGPSWITCH.js
│ ├── SensorType/
│ │ ├── AbstractClipSensorConfig.js
│ │ ├── AbstractSensorConfig.js
│ │ ├── AbstractSensorState.js
│ │ ├── AbstractZLLSensorConfig.js
│ │ ├── CLIPGenericFlag/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPGenericStatus/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPHumidity/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPLightLevel/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPOpenClose/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPPresence/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPSwitch/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── CLIPTemperature/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── Daylight/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── Factory.js
│ │ ├── Unknown/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── ZGPSwitch/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── ZLLLightLevel/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── ZLLPresence/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ ├── ZLLSwitch/
│ │ │ ├── Config.js
│ │ │ └── State.js
│ │ └── ZLLTemperature/
│ │ ├── Config.js
│ │ └── State.js
│ ├── TimePattern/
│ │ ├── AbsoluteTime.js
│ │ ├── RandomizedTime.js
│ │ ├── RecurringTime.js
│ │ └── Timer.js
│ └── Transport.js
├── package.json
└── test/
├── Discovery.spec.js
├── Huejay.spec.js
├── TimePattern/
│ ├── AbsoluteTime.spec.js
│ ├── RandomizedTime.spec.js
│ ├── RecurringTime.spec.js
│ └── Timer.spec.js
└── mocha.opts
SYMBOL INDEX (1096 symbols across 236 files)
FILE: lib/Accessor/AbstractAccessor.js
class AbstractAccessor (line 6) | class AbstractAccessor {
method constructor (line 12) | constructor(client) {
FILE: lib/Accessor/Actions.js
class Actions (line 13) | class Actions extends AbstractAccessor {
method constructor (line 19) | constructor(client) {
FILE: lib/Accessor/Bridge.js
class Bridge (line 17) | class Bridge extends AbstractAccessor {
method constructor (line 23) | constructor(client) {
method ping (line 34) | ping() {
method isAuthenticated (line 43) | isAuthenticated() {
method get (line 52) | get() {
method save (line 61) | save(bridge) {
method linkButton (line 70) | linkButton() {
method touchlink (line 79) | touchlink() {
FILE: lib/Accessor/Capabilities.js
class Capabilities (line 18) | class Capabilities extends AbstractAccessor {
method lights (line 24) | lights() {
method sensors (line 33) | sensors() {
method groups (line 42) | groups() {
method scenes (line 51) | scenes() {
method rules (line 60) | rules() {
method resourceLinks (line 69) | resourceLinks() {
method schedules (line 78) | schedules() {
method getTimeZones (line 87) | getTimeZones() {
FILE: lib/Accessor/Groups.js
class Groups (line 17) | class Groups extends AbstractAccessor {
method constructor (line 23) | constructor(client) {
method getAll (line 34) | getAll() {
method getById (line 45) | getById(id) {
method create (line 56) | create(group) {
method save (line 67) | save(group) {
method delete (line 83) | delete(group) {
FILE: lib/Accessor/InternetServices.js
class InternetServices (line 11) | class InternetServices extends AbstractAccessor {
method get (line 17) | get() {
FILE: lib/Accessor/Lights.js
class Lights (line 18) | class Lights extends AbstractAccessor {
method constructor (line 24) | constructor(client) {
method scan (line 35) | scan() {
method getNew (line 44) | getNew() {
method getAll (line 53) | getAll() {
method getById (line 64) | getById(lightId) {
method save (line 75) | save(light) {
method delete (line 91) | delete(light) {
FILE: lib/Accessor/Portal.js
class Portal (line 11) | class Portal extends AbstractAccessor {
method get (line 17) | get() {
FILE: lib/Accessor/ResourceLinks.js
class ResourceLinks (line 16) | class ResourceLinks extends AbstractAccessor {
method constructor (line 22) | constructor(client) {
method getAll (line 33) | getAll() {
method getById (line 44) | getById(id) {
method create (line 55) | create(resourceLink) {
method save (line 66) | save(resourceLink) {
method delete (line 77) | delete(resourceLink) {
FILE: lib/Accessor/Rules.js
class Rules (line 17) | class Rules extends AbstractAccessor {
method constructor (line 23) | constructor(client) {
method getAll (line 35) | getAll() {
method getById (line 46) | getById(id) {
method create (line 57) | create(rule) {
method save (line 68) | save(rule) {
method delete (line 79) | delete(rule) {
FILE: lib/Accessor/Scenes.js
class Scenes (line 18) | class Scenes extends AbstractAccessor {
method constructor (line 24) | constructor(client) {
method getAll (line 35) | getAll() {
method getById (line 47) | getById(sceneId) {
method create (line 58) | create(scene) {
method save (line 69) | save(scene) {
method recall (line 85) | recall(scene) {
method delete (line 96) | delete(scene) {
FILE: lib/Accessor/Schedules.js
class Schedules (line 16) | class Schedules extends AbstractAccessor {
method constructor (line 22) | constructor(client) {
method getAll (line 33) | getAll() {
method getById (line 44) | getById(id) {
method create (line 55) | create(schedule) {
method save (line 68) | save(schedule) {
method delete (line 81) | delete(schedule) {
FILE: lib/Accessor/Sensors.js
class Sensors (line 20) | class Sensors extends AbstractAccessor {
method constructor (line 26) | constructor(client) {
method scan (line 37) | scan() {
method getNew (line 46) | getNew() {
method getAll (line 55) | getAll() {
method getById (line 66) | getById(id) {
method create (line 77) | create(sensor) {
method save (line 88) | save(sensor) {
method delete (line 105) | delete(sensor) {
FILE: lib/Accessor/SoftwareUpdate.js
class SoftwareUpdate (line 14) | class SoftwareUpdate extends AbstractAccessor {
method get (line 20) | get() {
method check (line 29) | check() {
method install (line 38) | install() {
method disableInstallNotification (line 47) | disableInstallNotification() {
FILE: lib/Accessor/TimePatterns.js
class TimePatterns (line 14) | class TimePatterns extends AbstractAccessor {
method constructor (line 20) | constructor(client) {
FILE: lib/Accessor/TimeZones.js
class TimeZones (line 11) | class TimeZones extends AbstractAccessor {
method getAll (line 17) | getAll() {
FILE: lib/Accessor/Users.js
class Users (line 15) | class Users extends AbstractAccessor {
method constructor (line 21) | constructor(client) {
method getAll (line 32) | getAll() {
method get (line 41) | get() {
method getByUsername (line 52) | getByUsername(username) {
method create (line 63) | create(user) {
method delete (line 74) | delete(user) {
FILE: lib/Action/AbstractAction.js
class AbstractAction (line 8) | class AbstractAction {
method exportAction (line 12) | exportAction() {
FILE: lib/Action/ChangeGroupAction.js
constant GROUP_ACTION_MAP (line 6) | const GROUP_ACTION_MAP = {
class ChangeGroupAction (line 27) | class ChangeGroupAction extends AbstractAction {
method constructor (line 34) | constructor(group, useAction) {
method exportAction (line 50) | exportAction(client, withUsername) {
FILE: lib/Action/ChangeLightState.js
constant LIGHT_STATE_MAP (line 6) | const LIGHT_STATE_MAP = {
class ChangeLightState (line 26) | class ChangeLightState extends AbstractAction {
method constructor (line 33) | constructor(light, useState) {
method exportAction (line 49) | exportAction(client, withUsername) {
FILE: lib/Action/ChangeSensorState.js
class ChangeSensorState (line 9) | class ChangeSensorState extends AbstractAction {
method constructor (line 16) | constructor(sensor, useState) {
method exportAction (line 32) | exportAction(client, withUsername) {
FILE: lib/BridgeModel/AbstractBridgeModel.js
class AbstractBridgeModel (line 6) | class AbstractBridgeModel {
method constructor (line 12) | constructor(details) {
method id (line 21) | get id() {
method manufacturer (line 30) | get manufacturer() {
method name (line 39) | get name() {
method toString (line 48) | toString() {
FILE: lib/BridgeModel/BSB001.js
constant DETAILS (line 5) | const DETAILS = {
class BSB001 (line 14) | class BSB001 extends AbstractBridgeModel {
method constructor (line 18) | constructor() {
FILE: lib/BridgeModel/BSB002.js
constant DETAILS (line 5) | const DETAILS = {
class BSB002 (line 14) | class BSB002 extends AbstractBridgeModel {
method constructor (line 18) | constructor() {
FILE: lib/BridgeModel/Factory.js
constant SUPPORTED_BRIDGES (line 3) | const SUPPORTED_BRIDGES = [
class Factory (line 12) | class Factory {
method createBridgeModel (line 20) | static createBridgeModel(modelId) {
FILE: lib/BridgeModel/Unknown.js
constant DETAILS (line 5) | const DETAILS = {
class Unknown (line 14) | class Unknown extends AbstractBridgeModel {
method constructor (line 18) | constructor() {
FILE: lib/CapabilityModel/AbstractCapabilityModel.js
class AbstractCapabilityModel (line 6) | class AbstractCapabilityModel {
method constructor (line 12) | constructor(details) {
method available (line 21) | get available() {
FILE: lib/CapabilityModel/Groups.js
class Groups (line 8) | class Groups extends AbstractCapabilityModel {}
FILE: lib/CapabilityModel/Lights.js
class Lights (line 8) | class Lights extends AbstractCapabilityModel {}
FILE: lib/CapabilityModel/ResourceLinks.js
class ResourceLinks (line 8) | class ResourceLinks extends AbstractCapabilityModel {}
FILE: lib/CapabilityModel/Rules.js
class Rules (line 8) | class Rules extends AbstractCapabilityModel {
method conditionsAvailable (line 14) | get conditionsAvailable() {
method actionsAvailable (line 23) | get actionsAvailable() {
FILE: lib/CapabilityModel/Scenes.js
class Scenes (line 8) | class Scenes extends AbstractCapabilityModel {
method lightStatesAvailable (line 14) | get lightStatesAvailable() {
FILE: lib/CapabilityModel/Schedules.js
class Schedules (line 8) | class Schedules extends AbstractCapabilityModel {}
FILE: lib/CapabilityModel/Sensors.js
class Sensors (line 8) | class Sensors extends AbstractCapabilityModel {
method clipAvailable (line 14) | get clipAvailable() {
method zllAvailable (line 23) | get zllAvailable() {
method zgpAvailable (line 32) | get zgpAvailable() {
FILE: lib/Client.js
constant DEFAULT_CONFIG (line 3) | const DEFAULT_CONFIG = {
class Client (line 15) | class Client {
method constructor (line 21) | constructor(config) {
method host (line 31) | get host() {
method host (line 40) | set host(host) {
method port (line 49) | get port() {
method port (line 58) | set port(port) {
method username (line 67) | get username() {
method username (line 76) | set username(username) {
method timeout (line 85) | get timeout() {
method timeout (line 94) | set timeout(timeout) {
method bridge (line 103) | get bridge() {
method portal (line 112) | get portal() {
method internetServices (line 121) | get internetServices() {
method softwareUpdate (line 130) | get softwareUpdate() {
method users (line 139) | get users() {
method lights (line 148) | get lights() {
method groups (line 157) | get groups() {
method scenes (line 166) | get scenes() {
method schedules (line 175) | get schedules() {
method sensors (line 184) | get sensors() {
method rules (line 193) | get rules() {
method actions (line 202) | get actions() {
method timePatterns (line 211) | get timePatterns() {
method resourceLinks (line 220) | get resourceLinks() {
method capabilities (line 229) | get capabilities() {
method timeZones (line 238) | get timeZones() {
method loadAccessor (line 249) | loadAccessor(accessor) {
method getTransport (line 264) | getTransport() {
method invokeCommand (line 281) | invokeCommand(command) {
FILE: lib/Command/Bridge/EnableLinkButton.js
class EnableLinkButton (line 8) | class EnableLinkButton {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Bridge/EnableTouchlink.js
class EnableTouchlink (line 8) | class EnableTouchlink {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Bridge/GetBridge.js
class GetBridge (line 10) | class GetBridge {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/Bridge/IsAuthenticated.js
class IsAuthenticated (line 8) | class IsAuthenticated {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Bridge/Ping.js
class Ping (line 8) | class Ping {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Bridge/SaveBridge.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class SaveBridge (line 24) | class SaveBridge {
method constructor (line 30) | constructor(bridge) {
method invoke (line 43) | invoke(client) {
method saveBridgeAttribute (line 76) | saveBridgeAttribute(client, attribute, value) {
FILE: lib/Command/Bridge/Utils.js
constant BRIDGE_ATTRIBUTES (line 6) | const BRIDGE_ATTRIBUTES = [
class Utils (line 36) | class Utils {
method validateBridge (line 44) | static validateBridge(bridge) {
method buildBridge (line 61) | static buildBridge(result) {
method mapBridgeAttributes (line 74) | static mapBridgeAttributes(result) {
FILE: lib/Command/Capability/GetGroups.js
class GetGroups (line 8) | class GetGroups {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Capability/GetLights.js
class GetLights (line 8) | class GetLights {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Capability/GetResourceLinks.js
class GetResourceLinks (line 8) | class GetResourceLinks {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Capability/GetRules.js
class GetRules (line 8) | class GetRules {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Capability/GetScenes.js
class GetScenes (line 8) | class GetScenes {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Capability/GetSchedules.js
class GetSchedules (line 8) | class GetSchedules {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Capability/GetSensors.js
class GetSensors (line 8) | class GetSensors {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Capability/GetTimeZones.js
class GetTimeZones (line 8) | class GetTimeZones {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Group/CreateGroup.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class CreateGroup (line 17) | class CreateGroup {
method constructor (line 23) | constructor(group) {
method invoke (line 36) | invoke(client) {
FILE: lib/Command/Group/DeleteGroup.js
class DeleteGroup (line 8) | class DeleteGroup {
method constructor (line 14) | constructor(groupId) {
method invoke (line 25) | invoke(client) {
FILE: lib/Command/Group/GetGroup.js
class GetGroup (line 10) | class GetGroup {
method constructor (line 16) | constructor(groupId) {
method invoke (line 27) | invoke(client) {
FILE: lib/Command/Group/GetGroups.js
class GetGroups (line 10) | class GetGroups {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/Group/SaveGroup.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class SaveGroup (line 15) | class SaveGroup {
method constructor (line 21) | constructor(group) {
method invoke (line 34) | invoke(client) {
FILE: lib/Command/Group/SaveGroupAction.js
constant ALLOWED_ACTION (line 5) | const ALLOWED_ACTION = [
class SaveGroupAction (line 28) | class SaveGroupAction {
method constructor (line 34) | constructor(group) {
method invoke (line 47) | invoke(client) {
method refreshGroupAction (line 76) | refreshGroupAction(results) {
FILE: lib/Command/Group/Utils.js
constant GROUP_ATTRIBUTES (line 6) | const GROUP_ATTRIBUTES = [
constant GROUP_STATE (line 16) | const GROUP_STATE = [
constant GROUP_ACTION_ATTRIBUTES (line 21) | const GROUP_ACTION_ATTRIBUTES = [
class Utils (line 38) | class Utils {
method validateGroup (line 46) | static validateGroup(group) {
method buildGroup (line 63) | static buildGroup(result) {
method mapGroupAttributes (line 78) | static mapGroupAttributes(result) {
method mapGroupState (line 101) | static mapGroupState(result) {
method mapGroupAction (line 124) | static mapGroupAction(result) {
FILE: lib/Command/InternetServices/GetInternetServices.js
class GetInternetServices (line 10) | class GetInternetServices {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/InternetServices/Utils.js
constant INTERNET_SERVICES_ATTRIBUTES (line 5) | const INTERNET_SERVICES_ATTRIBUTES = [
class Utils (line 15) | class Utils {
method buildInternetServices (line 23) | static buildInternetServices(result) {
method mapInternetServicesAttributes (line 36) | static mapInternetServicesAttributes(result) {
FILE: lib/Command/Light/DeleteLight.js
class DeleteLight (line 8) | class DeleteLight {
method constructor (line 14) | constructor(lightId) {
method invoke (line 25) | invoke(client) {
FILE: lib/Command/Light/GetLight.js
class GetLight (line 10) | class GetLight {
method constructor (line 16) | constructor(lightId) {
method invoke (line 27) | invoke(client) {
FILE: lib/Command/Light/GetLights.js
class GetLights (line 10) | class GetLights {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/Light/GetNewLights.js
class GetNewLights (line 10) | class GetNewLights {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/Light/SaveLight.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class SaveLight (line 14) | class SaveLight {
method constructor (line 20) | constructor(light) {
method invoke (line 33) | invoke(client) {
method saveLightAttribute (line 66) | saveLightAttribute(client, attribute, value) {
FILE: lib/Command/Light/SaveLightState.js
constant ALLOWED_STATE (line 5) | const ALLOWED_STATE = [
class SaveLightState (line 27) | class SaveLightState {
method constructor (line 33) | constructor(light) {
method invoke (line 46) | invoke(client) {
method refreshLightState (line 75) | refreshLightState(results) {
FILE: lib/Command/Light/StartLightScan.js
class StartLightScan (line 8) | class StartLightScan {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Light/Utils.js
constant LIGHT_ATTRIBUTES (line 6) | const LIGHT_ATTRIBUTES = [
constant LIGHT_STATE_ATTRIBUTES (line 18) | const LIGHT_STATE_ATTRIBUTES = [
class Utils (line 35) | class Utils {
method validateLight (line 43) | static validateLight(light) {
method buildLight (line 60) | static buildLight(result) {
method mapLightAttributes (line 74) | static mapLightAttributes(result) {
method mapLightState (line 97) | static mapLightState(result) {
FILE: lib/Command/Portal/GetPortal.js
class GetPortal (line 10) | class GetPortal {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/Portal/Utils.js
constant PORTAL_ATTRIBUTES (line 5) | const PORTAL_ATTRIBUTES = [
class Utils (line 15) | class Utils {
method buildPortal (line 23) | static buildPortal(result) {
method mapPortalAttributes (line 36) | static mapPortalAttributes(result) {
FILE: lib/Command/ResourceLinks/CreateResourceLink.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class CreateResourceLink (line 18) | class CreateResourceLink {
method constructor (line 24) | constructor(resourceLink) {
method invoke (line 37) | invoke(client) {
FILE: lib/Command/ResourceLinks/DeleteResourceLink.js
class DeleteResourceLink (line 8) | class DeleteResourceLink {
method constructor (line 14) | constructor(resourceLinkId) {
method invoke (line 25) | invoke(client) {
FILE: lib/Command/ResourceLinks/GetResourceLink.js
class GetResourceLink (line 10) | class GetResourceLink {
method constructor (line 16) | constructor(resourceLinkId) {
method invoke (line 27) | invoke(client) {
FILE: lib/Command/ResourceLinks/GetResourceLinks.js
class GetResourceLinks (line 10) | class GetResourceLinks {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/ResourceLinks/SaveResourceLink.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class SaveResourceLink (line 16) | class SaveResourceLink {
method constructor (line 22) | constructor(resourceLink) {
method invoke (line 35) | invoke(client) {
FILE: lib/Command/ResourceLinks/Utils.js
constant RESOURCE_LINK_ATTRIBUTES (line 6) | const RESOURCE_LINK_ATTRIBUTES = [
class Utils (line 20) | class Utils {
method validateResourceLink (line 28) | static validateResourceLink(resourceLink) {
method buildResourceLink (line 45) | static buildResourceLink(result) {
method mapResourceLinkAttributes (line 58) | static mapResourceLinkAttributes(result) {
FILE: lib/Command/Rule/CreateRule.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class CreateRule (line 17) | class CreateRule {
method constructor (line 23) | constructor(rule) {
method invoke (line 36) | invoke(client) {
FILE: lib/Command/Rule/DeleteRule.js
class DeleteRule (line 8) | class DeleteRule {
method constructor (line 14) | constructor(ruleId) {
method invoke (line 25) | invoke(client) {
FILE: lib/Command/Rule/GetRule.js
class GetRule (line 10) | class GetRule {
method constructor (line 16) | constructor(ruleId) {
method invoke (line 27) | invoke(client) {
FILE: lib/Command/Rule/GetRules.js
class GetRules (line 10) | class GetRules {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/Rule/SaveRule.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class SaveRule (line 17) | class SaveRule {
method constructor (line 23) | constructor(rule) {
method invoke (line 36) | invoke(client) {
FILE: lib/Command/Rule/Utils.js
class Utils (line 11) | class Utils {
method validateRule (line 19) | static validateRule(rule) {
method buildRule (line 36) | static buildRule(result) {
method convertConditions (line 45) | static convertConditions(rule) {
method convertActions (line 65) | static convertActions(rule, client) {
FILE: lib/Command/Scene/CreateScene.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class CreateScene (line 18) | class CreateScene {
method constructor (line 24) | constructor(scene) {
method invoke (line 37) | invoke(client) {
method reloadSceneAttributes (line 71) | reloadSceneAttributes(client) {
FILE: lib/Command/Scene/DeleteScene.js
class DeleteScene (line 8) | class DeleteScene {
method constructor (line 14) | constructor(sceneId) {
method invoke (line 25) | invoke(client) {
FILE: lib/Command/Scene/GetSceneById.js
class GetSceneById (line 10) | class GetSceneById {
method constructor (line 16) | constructor(sceneId) {
method invoke (line 27) | invoke(client) {
FILE: lib/Command/Scene/GetScenes.js
class GetScenes (line 10) | class GetScenes {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/Scene/RecallScene.js
class RecallScene (line 8) | class RecallScene {
method constructor (line 14) | constructor(sceneId) {
method invoke (line 25) | invoke(client) {
FILE: lib/Command/Scene/SaveScene.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class SaveScene (line 19) | class SaveScene {
method constructor (line 25) | constructor(scene) {
method invoke (line 38) | invoke(client) {
method reloadSceneAttributes (line 68) | reloadSceneAttributes(client) {
FILE: lib/Command/Scene/SaveSceneLightState.js
constant STATE_MAP (line 5) | const STATE_MAP = {
class SaveSceneLightState (line 21) | class SaveSceneLightState {
method constructor (line 27) | constructor(scene) {
method invoke (line 40) | invoke(client) {
method saveLightState (line 65) | saveLightState(client, lightId, state) {
FILE: lib/Command/Scene/Utils.js
constant SCENE_ATTRIBUTES (line 7) | const SCENE_ATTRIBUTES = [
class Utils (line 25) | class Utils {
method validateScene (line 33) | static validateScene(scene) {
method buildScene (line 50) | static buildScene(result) {
method mapSceneAttributes (line 64) | static mapSceneAttributes(result) {
method mapSceneLightStates (line 87) | static mapSceneLightStates(result) {
FILE: lib/Command/Schedule/CreateSchedule.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class CreateSchedule (line 19) | class CreateSchedule {
method constructor (line 25) | constructor(schedule) {
method invoke (line 38) | invoke(client) {
FILE: lib/Command/Schedule/DeleteSchedule.js
class DeleteSchedule (line 8) | class DeleteSchedule {
method constructor (line 14) | constructor(scheduleId) {
method invoke (line 25) | invoke(client) {
FILE: lib/Command/Schedule/GetSchedule.js
class GetSchedule (line 10) | class GetSchedule {
method constructor (line 16) | constructor(scheduleId) {
method invoke (line 27) | invoke(client) {
FILE: lib/Command/Schedule/GetSchedules.js
class GetSchedules (line 10) | class GetSchedules {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/Schedule/SaveSchedule.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class SaveSchedule (line 19) | class SaveSchedule {
method constructor (line 25) | constructor(schedule) {
method invoke (line 38) | invoke(client) {
FILE: lib/Command/Schedule/Utils.js
constant SCHEDULE_ATTRIBUTES (line 7) | const SCHEDULE_ATTRIBUTES = [
class Utils (line 22) | class Utils {
method validateSchedule (line 30) | static validateSchedule(schedule) {
method buildSchedule (line 47) | static buildSchedule(result) {
method mapScheduleAttributes (line 60) | static mapScheduleAttributes(result) {
method convertAction (line 82) | static convertAction(schedule, client) {
FILE: lib/Command/Sensor/CreateSensor.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class CreateSensor (line 19) | class CreateSensor {
method constructor (line 25) | constructor(sensor) {
method invoke (line 38) | invoke(client) {
FILE: lib/Command/Sensor/DeleteSensor.js
class DeleteSensor (line 8) | class DeleteSensor {
method constructor (line 14) | constructor(sensorId) {
method invoke (line 25) | invoke(client) {
FILE: lib/Command/Sensor/GetNewSensors.js
class GetNewSensors (line 10) | class GetNewSensors {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/Sensor/GetSensor.js
class GetSensor (line 10) | class GetSensor {
method constructor (line 16) | constructor(sensorId) {
method invoke (line 27) | invoke(client) {
FILE: lib/Command/Sensor/GetSensors.js
class GetSensors (line 10) | class GetSensors {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/Sensor/SaveSensor.js
constant ALLOWED_ATTRIBUTES (line 5) | const ALLOWED_ATTRIBUTES = [
class SaveSensor (line 14) | class SaveSensor {
method constructor (line 20) | constructor(sensor) {
method invoke (line 33) | invoke(client) {
method saveSensorAttribute (line 62) | saveSensorAttribute(client, attribute, value) {
FILE: lib/Command/Sensor/SaveSensorConfig.js
class SaveSensorConfig (line 10) | class SaveSensorConfig {
method constructor (line 16) | constructor(sensor) {
method invoke (line 29) | invoke(client) {
FILE: lib/Command/Sensor/SaveSensorState.js
class SaveSensorState (line 10) | class SaveSensorState {
method constructor (line 16) | constructor(sensor) {
method invoke (line 29) | invoke(client) {
FILE: lib/Command/Sensor/StartSensorScan.js
class StartSensorScan (line 8) | class StartSensorScan {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/Sensor/Utils.js
constant SENSOR_ATTRIBUTES (line 6) | const SENSOR_ATTRIBUTES = [
class Utils (line 21) | class Utils {
method validateSensor (line 29) | static validateSensor(sensor) {
method buildSensor (line 46) | static buildSensor(result) {
method mapSensorAttributes (line 61) | static mapSensorAttributes(result) {
method mapSensorConfig (line 84) | static mapSensorConfig(config) {
method mapSensorState (line 95) | static mapSensorState(state) {
FILE: lib/Command/SoftwareUpdate/CheckForSoftwareUpdates.js
class CheckForSoftwareUpdates (line 8) | class CheckForSoftwareUpdates {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/SoftwareUpdate/DisableInstallNotification.js
class DisableInstallNotification (line 8) | class DisableInstallNotification {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/SoftwareUpdate/GetSoftwareUpdate.js
class GetSoftwareUpdate (line 10) | class GetSoftwareUpdate {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/SoftwareUpdate/InstallSoftwareUpdates.js
class InstallSoftwareUpdates (line 8) | class InstallSoftwareUpdates {
method invoke (line 16) | invoke(client) {
FILE: lib/Command/SoftwareUpdate/Utils.js
constant SW_ATTRIBUTES (line 5) | const SW_ATTRIBUTES = [
class Utils (line 17) | class Utils {
method buildSoftwareUpdate (line 25) | static buildSoftwareUpdate(result) {
method mapSoftwareUpdateAttributes (line 38) | static mapSoftwareUpdateAttributes(result) {
FILE: lib/Command/User/CreateUser.js
class CreateUser (line 11) | class CreateUser {
method constructor (line 17) | constructor(user) {
method invoke (line 30) | invoke(client) {
FILE: lib/Command/User/DeleteUser.js
class DeleteUser (line 8) | class DeleteUser {
method constructor (line 14) | constructor(username) {
method invoke (line 25) | invoke(client) {
FILE: lib/Command/User/GetUser.js
class GetUser (line 11) | class GetUser {
method constructor (line 17) | constructor(username) {
method invoke (line 28) | invoke(client) {
FILE: lib/Command/User/GetUsers.js
class GetUsers (line 10) | class GetUsers {
method invoke (line 18) | invoke(client) {
FILE: lib/Command/User/Utils.js
constant USER_ATTRIBUTES (line 6) | const USER_ATTRIBUTES = [
class Utils (line 16) | class Utils {
method validateUser (line 24) | static validateUser(user) {
method buildUser (line 41) | static buildUser(result) {
method mapUserAttributes (line 54) | static mapUserAttributes(result) {
FILE: lib/Discovery.js
constant ENABLED_STRATEGIES (line 5) | const ENABLED_STRATEGIES = {
constant DEFAULT_OPTIONS (line 10) | const DEFAULT_OPTIONS = {
class Discovery (line 19) | class Discovery {
method constructor (line 25) | constructor(options) {
method discoverBridges (line 36) | static discoverBridges(options) {
method discover (line 45) | discover() {
function validateDiscoveryStrategy (line 76) | function validateDiscoveryStrategy(strategy) {
function getDiscoveryStrategy (line 91) | function getDiscoveryStrategy(strategy) {
FILE: lib/DiscoveryStrategy/Nupnp.js
constant PHILIPS_NUPNP_URL (line 6) | const PHILIPS_NUPNP_URL = 'https://discovery.meethue.com/';
class Nupnp (line 13) | class Nupnp {
method discover (line 19) | discover() {
method requestService (line 28) | requestService() {
FILE: lib/DiscoveryStrategy/Upnp.js
constant SSDP_ADDRESS (line 5) | const SSDP_ADDRESS = '239.255.255.250';
constant SSDP_PORT (line 6) | const SSDP_PORT = 1900;
constant SSDP_SEARCH_TARGET (line 7) | const SSDP_SEARCH_TARGET = 'upnp:rootdevice';
constant SOURCE_INTERFACE (line 8) | const SOURCE_INTERFACE = '0.0.0.0';
constant SOURCE_PORT (line 9) | const SOURCE_PORT = 0;
constant TIMEOUT_MS (line 10) | const TIMEOUT_MS = 3000;
class Upnp (line 17) | class Upnp {
method constructor (line 21) | constructor() {
method discover (line 30) | discover() {
method startDiscovery (line 42) | startDiscovery(resolve, reject) {
method broadcast (line 61) | broadcast() {
method handleMessage (line 81) | handleMessage(message) {
method stopDiscovery (line 104) | stopDiscovery(resolve, reject) {
FILE: lib/Error.js
class HuejayError (line 8) | class HuejayError extends Error {
method constructor (line 16) | constructor(error, fileName, lineNumber) {
FILE: lib/GroupModel/AbstractGroupModel.js
class AbstractGroupModel (line 6) | class AbstractGroupModel {
method constructor (line 12) | constructor(details) {
method id (line 21) | get id() {
method manufacturer (line 30) | get manufacturer() {
method name (line 39) | get name() {
method type (line 48) | get type() {
method toString (line 57) | toString() {
FILE: lib/GroupModel/Factory.js
class Factory (line 6) | class Factory {
method createGroupModel (line 14) | static createGroupModel(modelId) {
FILE: lib/GroupModel/HBL001.js
constant DETAILS (line 5) | const DETAILS = {
class HBL001 (line 15) | class HBL001 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HBL002.js
constant DETAILS (line 5) | const DETAILS = {
class HBL002 (line 15) | class HBL002 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HBL003.js
constant DETAILS (line 5) | const DETAILS = {
class HBL003 (line 15) | class HBL003 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HEL001.js
constant DETAILS (line 5) | const DETAILS = {
class HEL001 (line 15) | class HEL001 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HEL002.js
constant DETAILS (line 5) | const DETAILS = {
class HEL002 (line 15) | class HEL002 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HIL001.js
constant DETAILS (line 5) | const DETAILS = {
class HIL001 (line 15) | class HIL001 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HIL002.js
constant DETAILS (line 5) | const DETAILS = {
class HIL002 (line 15) | class HIL002 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HML001.js
constant DETAILS (line 5) | const DETAILS = {
class HML001 (line 15) | class HML001 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HML002.js
constant DETAILS (line 5) | const DETAILS = {
class HML002 (line 15) | class HML002 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HML003.js
constant DETAILS (line 5) | const DETAILS = {
class HML003 (line 15) | class HML003 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HML004.js
constant DETAILS (line 5) | const DETAILS = {
class HML004 (line 15) | class HML004 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HML005.js
constant DETAILS (line 5) | const DETAILS = {
class HML005 (line 15) | class HML005 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HML006.js
constant DETAILS (line 5) | const DETAILS = {
class HML006 (line 15) | class HML006 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/HML007.js
constant DETAILS (line 5) | const DETAILS = {
class HML007 (line 15) | class HML007 extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/GroupModel/Unknown.js
constant DETAILS (line 5) | const DETAILS = {
class Unknown (line 15) | class Unknown extends AbstractGroupModel {
method constructor (line 19) | constructor() {
FILE: lib/LightModel/AbstractLightModel.js
class AbstractLightModel (line 6) | class AbstractLightModel {
method constructor (line 12) | constructor(details) {
method id (line 21) | get id() {
method manufacturer (line 30) | get manufacturer() {
method name (line 39) | get name() {
method type (line 48) | get type() {
method colorGamut (line 57) | get colorGamut() {
method friendsOfHue (line 66) | get friendsOfHue() {
method toString (line 75) | toString() {
FILE: lib/LightModel/Factory.js
class Factory (line 6) | class Factory {
method createLightModel (line 14) | static createLightModel(modelId) {
FILE: lib/LightModel/LCT001.js
constant DETAILS (line 5) | const DETAILS = {
class LCT001 (line 17) | class LCT001 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LCT002.js
constant DETAILS (line 5) | const DETAILS = {
class LCT002 (line 17) | class LCT002 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LCT003.js
constant DETAILS (line 5) | const DETAILS = {
class LCT003 (line 17) | class LCT003 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LCT007.js
constant DETAILS (line 5) | const DETAILS = {
class LCT007 (line 17) | class LCT007 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LCT010.js
constant DETAILS (line 5) | const DETAILS = {
class LCT010 (line 17) | class LCT010 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LCT011.js
constant DETAILS (line 5) | const DETAILS = {
class LCT011 (line 17) | class LCT011 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LCT012.js
constant DETAILS (line 5) | const DETAILS = {
class LCT012 (line 17) | class LCT012 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LCT014.js
constant DETAILS (line 5) | const DETAILS = {
class LCT014 (line 17) | class LCT014 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LLC006.js
constant DETAILS (line 5) | const DETAILS = {
class LLC006 (line 17) | class LLC006 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LLC007.js
constant DETAILS (line 5) | const DETAILS = {
class LLC007 (line 17) | class LLC007 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LLC010.js
constant DETAILS (line 5) | const DETAILS = {
class LLC010 (line 17) | class LLC010 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LLC011.js
constant DETAILS (line 5) | const DETAILS = {
class LLC011 (line 17) | class LLC011 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LLC012.js
constant DETAILS (line 5) | const DETAILS = {
class LLC012 (line 17) | class LLC012 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LLC013.js
constant DETAILS (line 5) | const DETAILS = {
class LLC013 (line 17) | class LLC013 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LLC014.js
constant DETAILS (line 5) | const DETAILS = {
class LLC014 (line 17) | class LLC014 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LLC020.js
constant DETAILS (line 5) | const DETAILS = {
class LLC020 (line 17) | class LLC020 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LLM001.js
constant DETAILS (line 5) | const DETAILS = {
class LLM001 (line 17) | class LLM001 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LLM010.js
constant DETAILS (line 5) | const DETAILS = {
class LLM010 (line 17) | class LLM010 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LLM011.js
constant DETAILS (line 5) | const DETAILS = {
class LLM011 (line 17) | class LLM011 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LLM012.js
constant DETAILS (line 5) | const DETAILS = {
class LLM012 (line 17) | class LLM012 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LST001.js
constant DETAILS (line 5) | const DETAILS = {
class LST001 (line 17) | class LST001 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LST002.js
constant DETAILS (line 5) | const DETAILS = {
class LST002 (line 17) | class LST002 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LTW001.js
constant DETAILS (line 5) | const DETAILS = {
class LTW001 (line 17) | class LTW001 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LTW004.js
constant DETAILS (line 5) | const DETAILS = {
class LTW004 (line 17) | class LTW004 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LTW010.js
constant DETAILS (line 5) | const DETAILS = {
class LTW010 (line 17) | class LTW010 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LTW011.js
constant DETAILS (line 5) | const DETAILS = {
class LTW011 (line 17) | class LTW011 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LTW012.js
constant DETAILS (line 5) | const DETAILS = {
class LTW012 (line 17) | class LTW012 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LTW013.js
constant DETAILS (line 5) | const DETAILS = {
class LTW013 (line 17) | class LTW013 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LTW014.js
constant DETAILS (line 5) | const DETAILS = {
class LTW014 (line 17) | class LTW014 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LTW015.js
constant DETAILS (line 5) | const DETAILS = {
class LTW015 (line 17) | class LTW015 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LWB004.js
constant DETAILS (line 5) | const DETAILS = {
class LWB004 (line 17) | class LWB004 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LWB006.js
constant DETAILS (line 5) | const DETAILS = {
class LWB006 (line 17) | class LWB006 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LWB007.js
constant DETAILS (line 5) | const DETAILS = {
class LWB007 (line 17) | class LWB007 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LWB010.js
constant DETAILS (line 5) | const DETAILS = {
class LWB010 (line 17) | class LWB010 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/LWB014.js
constant DETAILS (line 5) | const DETAILS = {
class LWB014 (line 17) | class LWB014 extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/LightModel/Unknown.js
constant DETAILS (line 5) | const DETAILS = {
class Unknown (line 17) | class Unknown extends AbstractLightModel {
method constructor (line 21) | constructor() {
FILE: lib/Model/Attributes.js
class Attributes (line 6) | class Attributes {
method constructor (line 13) | constructor(attributes, defaults) {
method replace (line 23) | replace(attributes) {
method get (line 34) | get(attribute) {
method getAll (line 43) | getAll() {
method set (line 53) | set(attribute, value) {
method getChanged (line 64) | getChanged() {
method resetChanged (line 77) | resetChanged() {
FILE: lib/Model/Bridge.js
class Bridge (line 11) | class Bridge {
method constructor (line 17) | constructor(attributes) {
method id (line 26) | get id() {
method name (line 35) | get name() {
method name (line 44) | set name(name) {
method modelId (line 53) | get modelId() {
method model (line 64) | get model() {
method factoryNew (line 77) | get factoryNew() {
method replacesBridgeId (line 86) | get replacesBridgeId() {
method dataStoreVersion (line 95) | get dataStoreVersion() {
method starterKitId (line 104) | get starterKitId() {
method softwareVersion (line 113) | get softwareVersion() {
method apiVersion (line 122) | get apiVersion() {
method zigbeeChannel (line 131) | get zigbeeChannel() {
method zigbeeChannel (line 140) | set zigbeeChannel(channel) {
method macAddress (line 149) | get macAddress() {
method ipAddress (line 158) | get ipAddress() {
method ipAddress (line 167) | set ipAddress(ipAddress) {
method dhcpEnabled (line 176) | get dhcpEnabled() {
method dhcpEnabled (line 185) | set dhcpEnabled(value) {
method netmask (line 194) | get netmask() {
method netmask (line 203) | set netmask(mask) {
method gateway (line 213) | get gateway() {
method gateway (line 222) | set gateway(address) {
method proxyAddress (line 231) | get proxyAddress() {
method proxyAddress (line 244) | set proxyAddress(address) {
method proxyPort (line 253) | get proxyPort() {
method proxyPort (line 266) | set proxyPort(port) {
method utcTime (line 275) | get utcTime() {
method timeZone (line 284) | get timeZone() {
method timeZone (line 297) | set timeZone(timeZone) {
method localTime (line 306) | get localTime() {
method portalServicesEnabled (line 319) | get portalServicesEnabled() {
method portalConnected (line 328) | get portalConnected() {
method linkButtonEnabled (line 337) | get linkButtonEnabled() {
method linkButtonEnabled (line 346) | set linkButtonEnabled(value) {
method touchlinkEnabled (line 355) | get touchlinkEnabled() {
method touchlinkEnabled (line 364) | set touchlinkEnabled(value) {
method toString (line 373) | toString() {
FILE: lib/Model/Condition.js
constant DEFAULT_CONDITION (line 7) | const DEFAULT_CONDITION = {
class Condition (line 19) | class Condition {
method constructor (line 25) | constructor(condition) {
method sensor (line 34) | get sensor() {
method sensor (line 43) | set sensor(sensor) {
method attribute (line 54) | get attribute() {
method attribute (line 63) | set attribute(attribute) {
method operator (line 72) | get operator() {
method operator (line 81) | set operator(operator) {
method value (line 90) | get value() {
method value (line 99) | set value(value) {
method when (line 110) | when(attribute) {
method greaterThan (line 125) | greaterThan(value) {
method lessThan (line 135) | lessThan(value) {
method equals (line 145) | equals(value) {
method changes (line 153) | changes() {
method delayedChanges (line 161) | delayedChanges() {
method stableFor (line 171) | stableFor(time) {
method unstableFor (line 181) | unstableFor(time) {
method in (line 192) | in(startTime, endTime) {
method notIn (line 206) | notIn(startTime, endTime) {
FILE: lib/Model/Group.js
constant DEFAULT_ATTRIBUTES (line 6) | const DEFAULT_ATTRIBUTES = {
class Group (line 16) | class Group {
method constructor (line 24) | constructor(attributes, state, action) {
method id (line 35) | get id() {
method name (line 44) | get name() {
method name (line 53) | set name(name) {
method type (line 62) | get type() {
method type (line 71) | set type(type) {
method class (line 80) | get class() {
method class (line 89) | set class(typeClass) {
method lightIds (line 98) | get lightIds() {
method lightIds (line 107) | set lightIds(lights) {
method modelId (line 120) | get modelId() {
method model (line 131) | get model() {
method uniqueId (line 144) | get uniqueId() {
method on (line 153) | get on() {
method on (line 162) | set on(value) {
method brightness (line 171) | get brightness() {
method brightness (line 180) | set brightness(brightness) {
method colorMode (line 189) | get colorMode() {
method hue (line 198) | get hue() {
method hue (line 207) | set hue(hue) {
method saturation (line 216) | get saturation() {
method saturation (line 225) | set saturation(saturation) {
method xy (line 234) | get xy() {
method xy (line 243) | set xy(xy) {
method colorTemp (line 252) | get colorTemp() {
method colorTemp (line 261) | set colorTemp(temp) {
method alert (line 270) | get alert() {
method alert (line 279) | set alert(mode) {
method effect (line 288) | get effect() {
method effect (line 297) | set effect(effect) {
method scene (line 306) | get scene() {
method scene (line 315) | set scene(scene) {
method transitionTime (line 324) | get transitionTime() {
method transitionTime (line 333) | set transitionTime(time) {
method incrementBrightness (line 342) | get incrementBrightness() {
method incrementBrightness (line 351) | set incrementBrightness(amount) {
method incrementHue (line 360) | get incrementHue() {
method incrementHue (line 369) | set incrementHue(amount) {
method incrementSaturation (line 378) | get incrementSaturation() {
method incrementSaturation (line 387) | set incrementSaturation(amount) {
method incrementXy (line 396) | get incrementXy() {
method incrementXy (line 405) | set incrementXy(amount) {
method incrementColorTemp (line 414) | get incrementColorTemp() {
method incrementColorTemp (line 423) | set incrementColorTemp(amount) {
method anyOn (line 432) | get anyOn() {
method allOn (line 441) | get allOn() {
method toString (line 450) | toString() {
FILE: lib/Model/InternetServices.js
class InternetServices (line 10) | class InternetServices {
method constructor (line 16) | constructor(attributes) {
method internetConnected (line 25) | get internetConnected() {
method remoteAccessConnected (line 34) | get remoteAccessConnected() {
method timeSyncConnected (line 43) | get timeSyncConnected() {
method softwareUpdateConnected (line 52) | get softwareUpdateConnected() {
FILE: lib/Model/Light.js
class Light (line 11) | class Light {
method constructor (line 18) | constructor(attributes, state) {
method id (line 28) | get id() {
method name (line 37) | get name() {
method name (line 46) | set name(name) {
method type (line 55) | get type() {
method uniqueId (line 64) | get uniqueId() {
method manufacturer (line 73) | get manufacturer() {
method modelId (line 82) | get modelId() {
method model (line 93) | get model() {
method productId (line 106) | get productId() {
method softwareVersion (line 115) | get softwareVersion() {
method softwareConfigId (line 124) | get softwareConfigId() {
method on (line 133) | get on() {
method on (line 142) | set on(value) {
method reachable (line 151) | get reachable() {
method brightness (line 160) | get brightness() {
method brightness (line 169) | set brightness(brightness) {
method colorMode (line 178) | get colorMode() {
method hue (line 187) | get hue() {
method hue (line 196) | set hue(hue) {
method saturation (line 205) | get saturation() {
method saturation (line 214) | set saturation(saturation) {
method xy (line 223) | get xy() {
method xy (line 232) | set xy(xy) {
method colorTemp (line 241) | get colorTemp() {
method colorTemp (line 250) | set colorTemp(temp) {
method alert (line 259) | get alert() {
method alert (line 268) | set alert(mode) {
method effect (line 277) | get effect() {
method effect (line 286) | set effect(effect) {
method transitionTime (line 295) | get transitionTime() {
method transitionTime (line 304) | set transitionTime(time) {
method incrementBrightness (line 313) | get incrementBrightness() {
method incrementBrightness (line 322) | set incrementBrightness(amount) {
method incrementHue (line 331) | get incrementHue() {
method incrementHue (line 340) | set incrementHue(amount) {
method incrementSaturation (line 349) | get incrementSaturation() {
method incrementSaturation (line 358) | set incrementSaturation(amount) {
method incrementXy (line 367) | get incrementXy() {
method incrementXy (line 376) | set incrementXy(amount) {
method incrementColorTemp (line 385) | get incrementColorTemp() {
method incrementColorTemp (line 394) | set incrementColorTemp(amount) {
method toString (line 403) | toString() {
FILE: lib/Model/Portal.js
class Portal (line 10) | class Portal {
method constructor (line 16) | constructor(attributes) {
method signedOn (line 25) | get signedOn() {
method incoming (line 34) | get incoming() {
method outgoing (line 43) | get outgoing() {
method communication (line 52) | get communication() {
FILE: lib/Model/ResourceLink.js
constant DEFAULT_ATTRIBUTES (line 5) | const DEFAULT_ATTRIBUTES = {
class ResourceLink (line 17) | class ResourceLink {
method constructor (line 23) | constructor(attributes) {
method id (line 32) | get id() {
method name (line 41) | get name() {
method name (line 50) | set name(name) {
method description (line 59) | get description() {
method description (line 68) | set description(description) {
method type (line 77) | get type() {
method classId (line 86) | get classId() {
method classId (line 95) | set classId(classId) {
method owner (line 104) | get owner() {
method recycle (line 113) | get recycle() {
method recycle (line 122) | set recycle(value) {
method links (line 131) | get links() {
method links (line 140) | set links(links) {
method toString (line 149) | toString() {
FILE: lib/Model/Rule.js
constant MAX_CONDITIONS (line 8) | const MAX_CONDITIONS = 8;
constant MAX_ACTIONS (line 9) | const MAX_ACTIONS = 8;
constant DEFAULT_ATTRIBUTES (line 10) | const DEFAULT_ATTRIBUTES = {
class Rule (line 21) | class Rule {
method constructor (line 27) | constructor(attributes) {
method id (line 36) | get id() {
method name (line 45) | get name() {
method name (line 54) | set name(name) {
method created (line 63) | get created() {
method lastTriggered (line 72) | get lastTriggered() {
method timesTriggered (line 83) | get timesTriggered() {
method owner (line 92) | get owner() {
method status (line 101) | get status() {
method status (line 110) | set status(value) {
method conditions (line 123) | get conditions() {
method conditions (line 132) | set conditions(conditions) {
method addCondition (line 143) | addCondition(sensor) {
method clearConditions (line 167) | clearConditions() {
method actions (line 176) | get actions() {
method actions (line 185) | set actions(actions) {
method addAction (line 194) | addAction(action) {
method clearActions (line 217) | clearActions() {
method toString (line 226) | toString() {
FILE: lib/Model/Scene.js
constant DEFAULT_ATTRIBUTES (line 5) | const DEFAULT_ATTRIBUTES = {
class Scene (line 14) | class Scene {
method constructor (line 21) | constructor(attributes, lightStates) {
method id (line 31) | get id() {
method name (line 40) | get name() {
method name (line 49) | set name(name) {
method lightIds (line 58) | get lightIds() {
method lightIds (line 67) | set lightIds(lights) {
method owner (line 80) | get owner() {
method recycle (line 89) | get recycle() {
method recycle (line 98) | set recycle(value) {
method locked (line 107) | get locked() {
method appData (line 116) | get appData() {
method appData (line 125) | set appData(data) {
method picture (line 134) | get picture() {
method lastUpdated (line 143) | get lastUpdated() {
method version (line 152) | get version() {
method captureLightState (line 161) | get captureLightState() {
method captureLightState (line 170) | set captureLightState(capture) {
method getLightState (line 181) | getLightState(lightId) {
method setLightState (line 191) | setLightState(lightId, state) {
method transitionTime (line 200) | get transitionTime() {
method transitionTime (line 209) | set transitionTime(time) {
method toString (line 218) | toString() {
FILE: lib/Model/Schedule.js
constant DEFAULT_ATTRIBUTES (line 6) | const DEFAULT_ATTRIBUTES = {
class Schedule (line 16) | class Schedule {
method constructor (line 22) | constructor(attributes) {
method id (line 31) | get id() {
method name (line 40) | get name() {
method name (line 49) | set name(name) {
method description (line 58) | get description() {
method description (line 67) | set description(description) {
method action (line 76) | get action() {
method action (line 85) | set action(action) {
method created (line 100) | get created() {
method status (line 109) | get status() {
method status (line 118) | set status(value) {
method autoDelete (line 131) | get autoDelete() {
method autoDelete (line 140) | set autoDelete(value) {
method localTime (line 149) | get localTime() {
method localTime (line 158) | set localTime(date) {
method startTime (line 167) | get startTime() {
method toString (line 176) | toString() {
FILE: lib/Model/Sensor.js
constant DEFAULT_ATTRIBUTES (line 7) | const DEFAULT_ATTRIBUTES = {
class Sensor (line 16) | class Sensor {
method constructor (line 24) | constructor(attributes, config, state) {
method id (line 35) | get id() {
method name (line 44) | get name() {
method name (line 53) | set name(name) {
method type (line 62) | get type() {
method type (line 71) | set type(type) {
method modelId (line 85) | get modelId() {
method modelId (line 94) | set modelId(modelId) {
method model (line 107) | get model() {
method manufacturer (line 120) | get manufacturer() {
method manufacturer (line 129) | set manufacturer(manufacturer) {
method productId (line 138) | get productId() {
method softwareVersion (line 147) | get softwareVersion() {
method softwareVersion (line 156) | set softwareVersion(softwareVersion) {
method softwareConfigId (line 165) | get softwareConfigId() {
method uniqueId (line 174) | get uniqueId() {
method uniqueId (line 183) | set uniqueId(uniqueId) {
method reloadConfigAndState (line 193) | reloadConfigAndState(config, state) {
method toString (line 203) | toString() {
FILE: lib/Model/SoftwareUpdate.js
constant UPDATE_STATE_MAP (line 5) | const UPDATE_STATE_MAP = {
class SoftwareUpdate (line 17) | class SoftwareUpdate {
method constructor (line 23) | constructor(attributes) {
method state (line 32) | get state() {
method checkingEnabled (line 41) | get checkingEnabled() {
method bridge (line 50) | get bridge() {
method lights (line 59) | get lights() {
method sensors (line 68) | get sensors() {
method releaseUrl (line 77) | get releaseUrl() {
method releaseNotes (line 86) | get releaseNotes() {
method installNotificationEnabled (line 95) | get installNotificationEnabled() {
FILE: lib/Model/User.js
constant DEFAULT_ATTRIBUTES (line 5) | const DEFAULT_ATTRIBUTES = {
class User (line 14) | class User {
method constructor (line 20) | constructor(attributes) {
method username (line 29) | get username() {
method deviceType (line 38) | get deviceType() {
method deviceType (line 47) | set deviceType(type) {
method created (line 56) | get created() {
method lastUsed (line 65) | get lastUsed() {
method toString (line 74) | toString() {
FILE: lib/SensorModel/AbstractSensorModel.js
class AbstractSensorModel (line 6) | class AbstractSensorModel {
method constructor (line 12) | constructor(details) {
method id (line 21) | get id() {
method manufacturer (line 30) | get manufacturer() {
method name (line 39) | get name() {
method type (line 48) | get type() {
method toString (line 57) | toString() {
FILE: lib/SensorModel/Factory.js
class Factory (line 6) | class Factory {
method createSensorModel (line 14) | static createSensorModel(modelId) {
FILE: lib/SensorModel/PHDL00.js
constant DETAILS (line 5) | const DETAILS = {
class PHDL00 (line 15) | class PHDL00 extends AbstractSensorModel {
method constructor (line 19) | constructor() {
FILE: lib/SensorModel/RWL020.js
constant DETAILS (line 5) | const DETAILS = {
class RWL020 (line 15) | class RWL020 extends AbstractSensorModel {
method constructor (line 19) | constructor() {
FILE: lib/SensorModel/RWL021.js
constant DETAILS (line 5) | const DETAILS = {
class RWL021 (line 15) | class RWL021 extends AbstractSensorModel {
method constructor (line 19) | constructor() {
FILE: lib/SensorModel/SML001.js
constant DETAILS (line 5) | const DETAILS = {
class SML001 (line 15) | class SML001 extends AbstractSensorModel {
method constructor (line 19) | constructor() {
FILE: lib/SensorModel/Unknown.js
constant DETAILS (line 5) | const DETAILS = {
class Unknown (line 15) | class Unknown extends AbstractSensorModel {
method constructor (line 19) | constructor() {
FILE: lib/SensorModel/ZGPSWITCH.js
constant DETAILS (line 5) | const DETAILS = {
class ZGPSWITCH (line 15) | class ZGPSWITCH extends AbstractSensorModel {
method constructor (line 19) | constructor() {
FILE: lib/SensorType/AbstractClipSensorConfig.js
class AbstractClipSensorConfig (line 8) | class AbstractClipSensorConfig extends AbstractSensorConfig {
method reachable (line 14) | get reachable() {
method battery (line 23) | get battery() {
method battery (line 32) | set battery(level) {
method url (line 41) | get url() {
method url (line 50) | set url(url) {
FILE: lib/SensorType/AbstractSensorConfig.js
class AbstractSensorConfig (line 8) | class AbstractSensorConfig {
method constructor (line 14) | constructor(config) {
method on (line 23) | get on() {
method on (line 32) | set on(value) {
FILE: lib/SensorType/AbstractSensorState.js
class AbstractSensorState (line 8) | class AbstractSensorState {
method constructor (line 14) | constructor(state) {
method stateMap (line 23) | get stateMap() {
method lastUpdated (line 34) | get lastUpdated() {
FILE: lib/SensorType/AbstractZLLSensorConfig.js
class AbstractZLLSensorConfig (line 8) | class AbstractZLLSensorConfig extends AbstractSensorConfig {
method reachable (line 14) | get reachable() {
method battery (line 23) | get battery() {
method alert (line 32) | get alert() {
method alert (line 41) | set alert(value) {
method userTest (line 50) | get userTest() {
method userTest (line 59) | set userTest(value) {
method pending (line 68) | get pending() {
method ledIndication (line 77) | get ledIndication() {
method ledIndication (line 86) | set ledIndication(value) {
FILE: lib/SensorType/CLIPGenericFlag/Config.js
class Config (line 8) | class Config extends AbstractClipSensorConfig {}
FILE: lib/SensorType/CLIPGenericFlag/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method flag (line 25) | get flag() {
method flag (line 34) | set flag(value) {
FILE: lib/SensorType/CLIPGenericStatus/Config.js
class Config (line 8) | class Config extends AbstractClipSensorConfig {}
FILE: lib/SensorType/CLIPGenericStatus/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method status (line 25) | get status() {
method status (line 34) | set status(value) {
FILE: lib/SensorType/CLIPHumidity/Config.js
class Config (line 8) | class Config extends AbstractClipSensorConfig {}
FILE: lib/SensorType/CLIPHumidity/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method humidity (line 25) | get humidity() {
method humidity (line 34) | set humidity(degrees) {
FILE: lib/SensorType/CLIPLightLevel/Config.js
class Config (line 8) | class Config extends AbstractClipSensorConfig {
method darkThreshold (line 14) | get darkThreshold() {
method darkThreshold (line 23) | set darkThreshold(threshold) {
method thresholdOffset (line 32) | get thresholdOffset() {
method thresholdOffest (line 41) | set thresholdOffest(threshold) {
FILE: lib/SensorType/CLIPLightLevel/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method lightLevel (line 27) | get lightLevel() {
method dark (line 36) | get dark() {
method daylight (line 45) | get daylight() {
FILE: lib/SensorType/CLIPOpenClose/Config.js
class Config (line 8) | class Config extends AbstractClipSensorConfig {}
FILE: lib/SensorType/CLIPOpenClose/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method open (line 25) | get open() {
method open (line 34) | set open(value) {
FILE: lib/SensorType/CLIPPresence/Config.js
class Config (line 8) | class Config extends AbstractClipSensorConfig {}
FILE: lib/SensorType/CLIPPresence/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method presence (line 25) | get presence() {
method presence (line 34) | set presence(value) {
FILE: lib/SensorType/CLIPSwitch/Config.js
class Config (line 8) | class Config extends AbstractClipSensorConfig {}
FILE: lib/SensorType/CLIPSwitch/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method buttonEvent (line 25) | get buttonEvent() {
method buttonEvent (line 34) | set buttonEvent(event) {
FILE: lib/SensorType/CLIPTemperature/Config.js
class Config (line 8) | class Config extends AbstractClipSensorConfig {}
FILE: lib/SensorType/CLIPTemperature/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method temperature (line 25) | get temperature() {
method temperature (line 34) | set temperature(degrees) {
FILE: lib/SensorType/Daylight/Config.js
class Config (line 8) | class Config extends AbstractSensorConfig {
method longitude (line 14) | get longitude() {
method longitude (line 23) | set longitude(value) {
method latitude (line 32) | get latitude() {
method latitude (line 41) | set latitude(value) {
method configured (line 48) | get configured() {
method sunriseOffset (line 55) | get sunriseOffset() {
method sunriseOffset (line 64) | set sunriseOffset(offset) {
method sunsetOffset (line 71) | get sunsetOffset() {
method sunsetOffset (line 80) | set sunsetOffset(offset) {
FILE: lib/SensorType/Daylight/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method daylight (line 25) | get daylight() {
FILE: lib/SensorType/Factory.js
class Factory (line 6) | class Factory {
method createSensorConfig (line 15) | static createSensorConfig(type, config) {
method createSensorState (line 29) | static createSensorState(type, state) {
method mapSensorType (line 42) | static mapSensorType(type, resource) {
FILE: lib/SensorType/Unknown/Config.js
class Config (line 8) | class Config extends AbstractSensorConfig {}
FILE: lib/SensorType/Unknown/State.js
class State (line 8) | class State extends AbstractSensorState {}
FILE: lib/SensorType/ZGPSwitch/Config.js
class Config (line 8) | class Config extends AbstractSensorConfig {}
FILE: lib/SensorType/ZGPSwitch/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method buttonEvent (line 25) | get buttonEvent() {
method buttonEvent (line 34) | set buttonEvent(event) {
FILE: lib/SensorType/ZLLLightLevel/Config.js
class Config (line 8) | class Config extends AbstractZLLSensorConfig {
method darkThreshold (line 14) | get darkThreshold() {
method darkThreshold (line 23) | set darkThreshold(threshold) {
method thresholdOffset (line 32) | get thresholdOffset() {
method thresholdOffest (line 41) | set thresholdOffest(threshold) {
FILE: lib/SensorType/ZLLLightLevel/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method lightLevel (line 27) | get lightLevel() {
method dark (line 36) | get dark() {
method daylight (line 45) | get daylight() {
FILE: lib/SensorType/ZLLPresence/Config.js
class Config (line 8) | class Config extends AbstractZLLSensorConfig {
method sensitivity (line 14) | get sensitivity() {
method maxSensitivity (line 23) | get maxSensitivity() {
FILE: lib/SensorType/ZLLPresence/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method presence (line 25) | get presence() {
method presence (line 34) | set presence(value) {
FILE: lib/SensorType/ZLLSwitch/Config.js
class Config (line 8) | class Config extends AbstractZLLSensorConfig {}
FILE: lib/SensorType/ZLLSwitch/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method buttonEvent (line 25) | get buttonEvent() {
method buttonEvent (line 34) | set buttonEvent(event) {
FILE: lib/SensorType/ZLLTemperature/Config.js
class Config (line 8) | class Config extends AbstractZLLSensorConfig {}
FILE: lib/SensorType/ZLLTemperature/State.js
class State (line 8) | class State extends AbstractSensorState {
method stateMap (line 14) | get stateMap() {
method temperature (line 25) | get temperature() {
method temperature (line 34) | set temperature(degrees) {
FILE: lib/TimePattern/AbsoluteTime.js
class AbsoluteTime (line 8) | class AbsoluteTime {
method constructor (line 14) | constructor(date) {
method toString (line 23) | toString() {
FILE: lib/TimePattern/RandomizedTime.js
class RandomizedTime (line 9) | class RandomizedTime {
method constructor (line 16) | constructor(date, withinSeconds) {
method toString (line 26) | toString() {
FILE: lib/TimePattern/RecurringTime.js
class RecurringTime (line 8) | class RecurringTime {
method constructor (line 15) | constructor(daysOfWeek, timeOfDay) {
method toString (line 26) | toString() {
FILE: lib/TimePattern/Timer.js
class Timer (line 8) | class Timer {
method constructor (line 15) | constructor(seconds, repeat) {
method toString (line 25) | toString() {
FILE: lib/Transport.js
class Transport (line 12) | class Transport {
method constructor (line 18) | constructor(client) {
method getHttpClient (line 27) | getHttpClient() {
method sendRequest (line 52) | sendRequest(options) {
Condensed preview — 303 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (360K chars).
[
{
"path": ".gitignore",
"chars": 59,
"preview": "/node_modules\n/npm-debug.log\n/package-lock.json\n/benchmark\n"
},
{
"path": ".travis.yml",
"chars": 148,
"preview": "language: node_js\n\nnode_js:\n - \"6.14.4\"\n - \"8.12.0\"\n - \"10.10.0\"\n\nscript:\n - npm run test\n\nnotifications:\n "
},
{
"path": "LICENSE",
"chars": 1091,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2015, 2016 Michael K. Squires\n\nPermission is hereby granted, free of charge, to any"
},
{
"path": "README.md",
"chars": 65804,
"preview": "<p align=\"center\">\n <img src=\"https://cdn.rawgit.com/sqmk/huejay/db9081ee1a22acf77abc93cbd3f2e8f6d20ee16b/media/huejay."
},
{
"path": "examples/.gitignore",
"chars": 18,
"preview": "/.credentials.json"
},
{
"path": "examples/bridge/get-bridge.js",
"chars": 2293,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Retrieving bridge (${client.ho"
},
{
"path": "examples/bridge/is-authenticated.js",
"chars": 257,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Testing authentication...');\n\n"
},
{
"path": "examples/bridge/lamp-stealer.js",
"chars": 241,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Starting lamp stealer...`);\n\nc"
},
{
"path": "examples/bridge/link-button.js",
"chars": 236,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Simulating link button press.."
},
{
"path": "examples/bridge/ping.js",
"chars": 238,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Pinging bridge...');\n\nclient.b"
},
{
"path": "examples/bridge/save-bridge.js",
"chars": 674,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Retrieving bridge (${client.ho"
},
{
"path": "examples/capabilities/get-groups.js",
"chars": 318,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving group capabilities."
},
{
"path": "examples/capabilities/get-lights.js",
"chars": 318,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving light capabilities."
},
{
"path": "examples/capabilities/get-resource-links.js",
"chars": 356,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving resource links capa"
},
{
"path": "examples/capabilities/get-rules.js",
"chars": 453,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving rule capabilities.."
},
{
"path": "examples/capabilities/get-scenes.js",
"chars": 395,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving scene capabilities."
},
{
"path": "examples/capabilities/get-schedules.js",
"chars": 333,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving schedule capabiliti"
},
{
"path": "examples/capabilities/get-sensors.js",
"chars": 508,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving sensor capabilities"
},
{
"path": "examples/capabilities/get-time-zones.js",
"chars": 348,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving supported time zone"
},
{
"path": "examples/discover.js",
"chars": 406,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet huejay = require('../lib/Huejay');\n\nconsole.log('Discovering bridges...');\n\nhuej"
},
{
"path": "examples/groups/get-groups.js",
"chars": 1634,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving groups...');\nconsol"
},
{
"path": "examples/groups/increase-group-hs.js",
"chars": 548,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Incrementing group hue/saturat"
},
{
"path": "examples/groups/manage-group.js",
"chars": 1011,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Creating group...');\n\nlet grou"
},
{
"path": "examples/groups/manage-room-group.js",
"chars": 720,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Creating group...');\n\nlet grou"
},
{
"path": "examples/init-client.js",
"chars": 202,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet huejay = require('../lib/Huejay');\nlet credentials = require('./.credential"
},
{
"path": "examples/internet-services/get-internet-services.js",
"chars": 646,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Retrieving internet services ("
},
{
"path": "examples/lights/get-light.js",
"chars": 1464,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving light...');\nconsole"
},
{
"path": "examples/lights/get-lights.js",
"chars": 1793,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving lights...');\nconsol"
},
{
"path": "examples/lights/get-new-lights.js",
"chars": 1678,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving new lights...');\nco"
},
{
"path": "examples/lights/increase-light-hs.js",
"chars": 546,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Incrementing light hue/saturat"
},
{
"path": "examples/lights/save-light.js",
"chars": 467,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Retrieving light from (${clien"
},
{
"path": "examples/lights/start-light-scan.js",
"chars": 243,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Starting light scan...');\n\ncli"
},
{
"path": "examples/portal/get-portal.js",
"chars": 498,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Retrieving portal (${client.ho"
},
{
"path": "examples/resource-links/get-resource-link.js",
"chars": 333,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving resource link...');"
},
{
"path": "examples/resource-links/get-resource-links.js",
"chars": 743,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving resource links...')"
},
{
"path": "examples/resource-links/manage-resource-link.js",
"chars": 1185,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Creating resource link...');\n\n"
},
{
"path": "examples/rules/get-rules.js",
"chars": 1184,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving rules...');\nconsole"
},
{
"path": "examples/rules/manage-rule.js",
"chars": 1178,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Creating rule...');\n\nlet rule "
},
{
"path": "examples/scenes/get-scenes.js",
"chars": 747,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving scenes...');\nconsol"
},
{
"path": "examples/scenes/manage-scene.js",
"chars": 1333,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Creating scene...');\n\nlet scen"
},
{
"path": "examples/scenes/recall-scene.js",
"chars": 267,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Recalling scene...');\n\nclient."
},
{
"path": "examples/scenes/save-scene.js",
"chars": 494,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Getting scene...');\n\nclient.sc"
},
{
"path": "examples/schedules/get-schedules.js",
"chars": 893,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving schedules...');\ncon"
},
{
"path": "examples/schedules/manage-schedule.js",
"chars": 1250,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\n// Get light\nclient.lights.getById(1)\n .th"
},
{
"path": "examples/sensors/create-switch.js",
"chars": 1071,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Creating sensor...');\n\nlet sen"
},
{
"path": "examples/sensors/get-sensors.js",
"chars": 1356,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving sensors...');\nconso"
},
{
"path": "examples/sensors/manage-sensor.js",
"chars": 1529,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Creating sensor...');\n\nlet sen"
},
{
"path": "examples/sensors/update-switch.js",
"chars": 286,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Updating sensor...');\n\nclient."
},
{
"path": "examples/software-update/check-for-software-updates.js",
"chars": 448,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Checking for software update ("
},
{
"path": "examples/software-update/disable-install-notification.js",
"chars": 494,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Disabling install notification"
},
{
"path": "examples/software-update/get-software-update.js",
"chars": 1022,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Retrieving software update det"
},
{
"path": "examples/software-update/install-software-updates.js",
"chars": 436,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log(`Installing software updates ($"
},
{
"path": "examples/time-zones/get-time-zones.js",
"chars": 339,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving supported time zone"
},
{
"path": "examples/users/create-user.js",
"chars": 661,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet huejay = require('../../lib/Huejay');\nlet client = require('../init-client');\n\nc"
},
{
"path": "examples/users/delete-user.js",
"chars": 252,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Deleting user...');\n\nclient.us"
},
{
"path": "examples/users/get-user.js",
"chars": 494,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving user...');\n\nclient."
},
{
"path": "examples/users/get-users.js",
"chars": 500,
"preview": "#!/usr/bin/env node\n\n'use strict';\n\nlet client = require('../init-client');\n\nconsole.log('Retrieving users...');\nconsole"
},
{
"path": "lib/Accessor/AbstractAccessor.js",
"chars": 230,
"preview": "'use strict';\n\n/**\n * Abstract accessor\n */\nclass AbstractAccessor {\n /**\n * Constructor\n *\n * @param {Client} cl"
},
{
"path": "lib/Accessor/Actions.js",
"chars": 638,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\n\n// Action helpers\nlet ChangeLightState = require("
},
{
"path": "lib/Accessor/Bridge.js",
"chars": 1727,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\nlet BridgeModel = require('../Model/Bridge');\n"
},
{
"path": "lib/Accessor/Capabilities.js",
"chars": 2064,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\n\n// Commands\nlet GetLights = require('../Com"
},
{
"path": "lib/Accessor/Groups.js",
"chars": 1833,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\nlet Group = require('../Model/Group');\n\n"
},
{
"path": "lib/Accessor/InternetServices.js",
"chars": 460,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\n\n// Commands\nlet GetInternetServices = require('../"
},
{
"path": "lib/Accessor/Lights.js",
"chars": 2010,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\nlet Light = require('../Model/Light');\n\n"
},
{
"path": "lib/Accessor/Portal.js",
"chars": 378,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\n\n// Commands\nlet GetPortal = require('../Command/Po"
},
{
"path": "lib/Accessor/ResourceLinks.js",
"chars": 1970,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\nlet ResourceLink = require('../Model/ResourceLi"
},
{
"path": "lib/Accessor/Rules.js",
"chars": 1646,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\nlet Rule = require('../Model/Rule');\nle"
},
{
"path": "lib/Accessor/Scenes.js",
"chars": 2170,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\nlet Scene = require('../Model/Scene');\n\n"
},
{
"path": "lib/Accessor/Schedules.js",
"chars": 1772,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\nlet Schedule = require('../Model/Schedule')"
},
{
"path": "lib/Accessor/Sensors.js",
"chars": 2475,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\nlet Sensor = require('../Model/Sensor');\n"
},
{
"path": "lib/Accessor/SoftwareUpdate.js",
"chars": 1278,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\n\n// Commands\nlet GetSoftwareUpdate = requi"
},
{
"path": "lib/Accessor/TimePatterns.js",
"chars": 715,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\n\n// Time patterns\nlet AbsoluteTime = require('../"
},
{
"path": "lib/Accessor/TimeZones.js",
"chars": 410,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\n\n// Commands\nlet GetTimeZones = require('../Command"
},
{
"path": "lib/Accessor/Users.js",
"chars": 1559,
"preview": "'use strict';\n\nlet AbstractAccessor = require('./AbstractAccessor');\nlet User = require('../Model/User');\n\n/"
},
{
"path": "lib/Action/AbstractAction.js",
"chars": 268,
"preview": "'use strict';\n\nlet Error = require('../Error');\n\n/**\n * Abstract action\n */\nclass AbstractAction {\n /**\n * Export act"
},
{
"path": "lib/Action/ChangeGroupAction.js",
"chars": 1742,
"preview": "'use strict';\n\nlet AbstractAction = require('./AbstractAction');\nlet GroupUtils = require('../Command/Group/Utils');"
},
{
"path": "lib/Action/ChangeLightState.js",
"chars": 1689,
"preview": "'use strict';\n\nlet AbstractAction = require('./AbstractAction');\nlet LightUtils = require('../Command/Light/Utils');"
},
{
"path": "lib/Action/ChangeSensorState.js",
"chars": 1297,
"preview": "'use strict';\n\nlet AbstractAction = require('./AbstractAction');\nlet SensorUtils = require('../Command/Sensor/Utils')"
},
{
"path": "lib/BridgeModel/AbstractBridgeModel.js",
"chars": 744,
"preview": "'use strict';\n\n/**\n * Abstract bridge model\n */\nclass AbstractBridgeModel {\n /**\n * Constructor\n *\n * @param {Obj"
},
{
"path": "lib/BridgeModel/BSB001.js",
"chars": 351,
"preview": "'use strict';\n\nlet AbstractBridgeModel = require('./AbstractBridgeModel');\n\nconst DETAILS = {\n id: 'BSB001',\n"
},
{
"path": "lib/BridgeModel/BSB002.js",
"chars": 351,
"preview": "'use strict';\n\nlet AbstractBridgeModel = require('./AbstractBridgeModel');\n\nconst DETAILS = {\n id: 'BSB002',\n"
},
{
"path": "lib/BridgeModel/Factory.js",
"chars": 504,
"preview": "'use strict';\n\nconst SUPPORTED_BRIDGES = [\n 'BSB001',\n 'BSB002',\n 'Unknown',\n];\n\n/**\n * Factory for Bridge Models\n */"
},
{
"path": "lib/BridgeModel/Unknown.js",
"chars": 341,
"preview": "'use strict';\n\nlet AbstractBridgeModel = require('./AbstractBridgeModel');\n\nconst DETAILS = {\n id: null,\n ma"
},
{
"path": "lib/CapabilityModel/AbstractCapabilityModel.js",
"chars": 412,
"preview": "'use strict';\n\n/**\n * Abstract capability model\n */\nclass AbstractCapabilityModel {\n /**\n * Constructor\n *\n * @pa"
},
{
"path": "lib/CapabilityModel/Groups.js",
"chars": 193,
"preview": "'use strict';\n\nlet AbstractCapabilityModel = require('./AbstractCapabilityModel');\n\n/**\n * Groups capability model\n */\nc"
},
{
"path": "lib/CapabilityModel/Lights.js",
"chars": 193,
"preview": "'use strict';\n\nlet AbstractCapabilityModel = require('./AbstractCapabilityModel');\n\n/**\n * Lights capability model\n */\nc"
},
{
"path": "lib/CapabilityModel/ResourceLinks.js",
"chars": 215,
"preview": "'use strict';\n\nlet AbstractCapabilityModel = require('./AbstractCapabilityModel');\n\n/**\n * Resource links capability mod"
},
{
"path": "lib/CapabilityModel/Rules.js",
"chars": 533,
"preview": "'use strict';\n\nlet AbstractCapabilityModel = require('./AbstractCapabilityModel');\n\n/**\n * Rules capability model\n */\ncl"
},
{
"path": "lib/CapabilityModel/Scenes.js",
"chars": 373,
"preview": "'use strict';\n\nlet AbstractCapabilityModel = require('./AbstractCapabilityModel');\n\n/**\n * Scenes capability model\n */\nc"
},
{
"path": "lib/CapabilityModel/Schedules.js",
"chars": 202,
"preview": "'use strict';\n\nlet AbstractCapabilityModel = require('./AbstractCapabilityModel');\n\n/**\n * Schedules capability model\n *"
},
{
"path": "lib/CapabilityModel/Sensors.js",
"chars": 665,
"preview": "'use strict';\n\nlet AbstractCapabilityModel = require('./AbstractCapabilityModel');\n\n/**\n * Sensors capability model\n */\n"
},
{
"path": "lib/Client.js",
"chars": 4607,
"preview": "'use strict';\n\nconst DEFAULT_CONFIG = {\n host: undefined,\n port: 80,\n username: undefined,\n timeout: 15000,"
},
{
"path": "lib/Command/Bridge/EnableLinkButton.js",
"chars": 518,
"preview": "'use strict';\n\n/**\n * Enable Link Button command\n *\n * Enable link button\n */\nclass EnableLinkButton {\n /**\n * Invoke"
},
{
"path": "lib/Command/Bridge/EnableTouchlink.js",
"chars": 511,
"preview": "'use strict';\n\n/**\n * Enable Touchlink command\n *\n * Enable Touchlink\n */\nclass EnableTouchlink {\n /**\n * Invoke comm"
},
{
"path": "lib/Command/Bridge/GetBridge.js",
"chars": 582,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get bridge command\n *\n * Get bridge info and configuration\n */\ncl"
},
{
"path": "lib/Command/Bridge/IsAuthenticated.js",
"chars": 549,
"preview": "'use strict';\n\n/**\n * Is authenticated command\n *\n * Determines if user is authenticated to bridge\n */\nclass IsAuthentic"
},
{
"path": "lib/Command/Bridge/Ping.js",
"chars": 379,
"preview": "'use strict';\n\n/**\n * Ping command\n *\n * Pings bridge\n */\nclass Ping {\n /**\n * Invoke command\n *\n * @param {Clien"
},
{
"path": "lib/Command/Bridge/SaveBridge.js",
"chars": 1583,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name',\n 'zigbeechannel',\n 'ipaddress',"
},
{
"path": "lib/Command/Bridge/Utils.js",
"chars": 1450,
"preview": "'use strict';\n\nlet Bridge = require('../../Model/Bridge');\nlet Error = require('../../Error');\n\nconst BRIDGE_ATTRIBUTES"
},
{
"path": "lib/Command/Capability/GetGroups.js",
"chars": 524,
"preview": "'use strict';\n\nlet Groups = require('../../CapabilityModel/Groups');\n\n/**\n * Get groups command\n */\nclass GetGroups {\n "
},
{
"path": "lib/Command/Capability/GetLights.js",
"chars": 524,
"preview": "'use strict';\n\nlet Lights = require('../../CapabilityModel/Lights');\n\n/**\n * Get lights command\n */\nclass GetLights {\n "
},
{
"path": "lib/Command/Capability/GetResourceLinks.js",
"chars": 574,
"preview": "'use strict';\n\nlet ResourceLinks = require('../../CapabilityModel/ResourceLinks');\n\n/**\n * Get resource links command\n *"
},
{
"path": "lib/Command/Capability/GetRules.js",
"chars": 517,
"preview": "'use strict';\n\nlet Rules = require('../../CapabilityModel/Rules');\n\n/**\n * Get rules command\n */\nclass GetRules {\n /**\n"
},
{
"path": "lib/Command/Capability/GetScenes.js",
"chars": 524,
"preview": "'use strict';\n\nlet Scenes = require('../../CapabilityModel/Scenes');\n\n/**\n * Get scenes command\n */\nclass GetScenes {\n "
},
{
"path": "lib/Command/Capability/GetSchedules.js",
"chars": 545,
"preview": "'use strict';\n\nlet Schedules = require('../../CapabilityModel/Schedules');\n\n/**\n * Get schedules command\n */\nclass GetSc"
},
{
"path": "lib/Command/Capability/GetSensors.js",
"chars": 531,
"preview": "'use strict';\n\nlet Sensors = require('../../CapabilityModel/Sensors');\n\n/**\n * Get sensors command\n */\nclass GetSensors "
},
{
"path": "lib/Command/Capability/GetTimeZones.js",
"chars": 518,
"preview": "'use strict';\n\n/**\n * Get time zones command\n *\n * Get a list of supported time zones\n */\nclass GetTimeZones {\n /**\n "
},
{
"path": "lib/Command/Group/CreateGroup.js",
"chars": 1071,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name',\n 'type',\n 'class',\n 'lights',\n"
},
{
"path": "lib/Command/Group/DeleteGroup.js",
"chars": 625,
"preview": "'use strict';\n\n/**\n * Delete group command\n *\n * Delete a group by id\n */\nclass DeleteGroup {\n /**\n * Constructor\n "
},
{
"path": "lib/Command/Group/GetGroup.js",
"chars": 685,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get group command\n *\n * Get a group by id\n */\nclass GetGroup {\n "
},
{
"path": "lib/Command/Group/GetGroups.js",
"chars": 621,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get groups command\n *\n * Get a list of groups\n */\nclass GetGroups"
},
{
"path": "lib/Command/Group/SaveGroup.js",
"chars": 980,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name',\n 'lights'\n];\n\n/**\n * Save group "
},
{
"path": "lib/Command/Group/SaveGroupAction.js",
"chars": 1533,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ACTION = [\n 'on',\n 'bri',\n 'hue',\n 'sat',\n 'xy',\n 'c"
},
{
"path": "lib/Command/Group/Utils.js",
"chars": 2149,
"preview": "'use strict';\n\nlet Error = require('../../Error');\nlet Group = require('../../Model/Group');\n\nconst GROUP_ATTRIBUTES = ["
},
{
"path": "lib/Command/InternetServices/GetInternetServices.js",
"chars": 583,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get internet services command\n *\n * Get internet services connect"
},
{
"path": "lib/Command/InternetServices/Utils.js",
"chars": 953,
"preview": "'use strict';\n\nlet InternetServices = require('../../Model/InternetServices');\n\nconst INTERNET_SERVICES_ATTRIBUTES = [\n "
},
{
"path": "lib/Command/Light/DeleteLight.js",
"chars": 625,
"preview": "'use strict';\n\n/**\n * Delete light command\n *\n * Delete a light by id\n */\nclass DeleteLight {\n /**\n * Constructor\n "
},
{
"path": "lib/Command/Light/GetLight.js",
"chars": 685,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get light command\n *\n * Get a light by id\n */\nclass GetLight {\n "
},
{
"path": "lib/Command/Light/GetLights.js",
"chars": 621,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get lights command\n *\n * Get a list of lights\n */\nclass GetLights"
},
{
"path": "lib/Command/Light/GetNewLights.js",
"chars": 888,
"preview": "'use strict';\n\nlet GetLights = require('./GetLights');\n\n/**\n * Get new lights command\n *\n * Get a list of new lights\n */"
},
{
"path": "lib/Command/Light/SaveLight.js",
"chars": 1431,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name'\n];\n\n/**\n * Save light command\n *\n "
},
{
"path": "lib/Command/Light/SaveLightState.js",
"chars": 1482,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_STATE = [\n 'on',\n 'bri',\n 'hue',\n 'sat',\n 'xy',\n 'ct"
},
{
"path": "lib/Command/Light/StartLightScan.js",
"chars": 470,
"preview": "'use strict';\n\n/**\n * Start light scan command\n *\n * Start a scan for new lights\n */\nclass StartLightScan {\n /**\n * I"
},
{
"path": "lib/Command/Light/Utils.js",
"chars": 1745,
"preview": "'use strict';\n\nlet Error = require('../../Error');\nlet Light = require('../../Model/Light');\n\nconst LIGHT_ATTRIBUTES = ["
},
{
"path": "lib/Command/Portal/GetPortal.js",
"chars": 526,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get portal command\n *\n * Get portal connectivity info\n */\nclass G"
},
{
"path": "lib/Command/Portal/Utils.js",
"chars": 822,
"preview": "'use strict';\n\nlet Portal = require('../../Model/Portal');\n\nconst PORTAL_ATTRIBUTES = [\n 'signedon',\n 'incoming',\n 'o"
},
{
"path": "lib/Command/ResourceLinks/CreateResourceLink.js",
"chars": 1213,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name',\n 'description',\n 'classid',\n '"
},
{
"path": "lib/Command/ResourceLinks/DeleteResourceLink.js",
"chars": 712,
"preview": "'use strict';\n\n/**\n * Delete resource link command\n *\n * Delete a resource link by id\n */\nclass DeleteResourceLink {\n /"
},
{
"path": "lib/Command/ResourceLinks/GetResourceLink.js",
"chars": 779,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get resource link command\n *\n * Get a resource link by id\n */\ncla"
},
{
"path": "lib/Command/ResourceLinks/GetResourceLinks.js",
"chars": 693,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get resource links command\n *\n * Get a list of resource links\n */"
},
{
"path": "lib/Command/ResourceLinks/SaveResourceLink.js",
"chars": 1118,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name',\n 'description',\n 'links'\n];\n\n/*"
},
{
"path": "lib/Command/ResourceLinks/Utils.js",
"chars": 1313,
"preview": "'use strict';\n\nlet Error = require('../../Error');\nlet ResourceLink = require('../../Model/ResourceLink');\n\nconst"
},
{
"path": "lib/Command/Rule/CreateRule.js",
"chars": 1140,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name',\n 'status',\n 'conditions',\n 'ac"
},
{
"path": "lib/Command/Rule/DeleteRule.js",
"chars": 613,
"preview": "'use strict';\n\n/**\n * Delete rule command\n *\n * Delete a rule by id\n */\nclass DeleteRule {\n /**\n * Constructor\n *\n "
},
{
"path": "lib/Command/Rule/GetRule.js",
"chars": 675,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get rule command\n *\n * Get a rule by id\n */\nclass GetRule {\n /**"
},
{
"path": "lib/Command/Rule/GetRules.js",
"chars": 610,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get rules command\n *\n * Get a list of rules\n */\nclass GetRules {\n"
},
{
"path": "lib/Command/Rule/SaveRule.js",
"chars": 1071,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name',\n 'status',\n 'conditions',\n 'ac"
},
{
"path": "lib/Command/Rule/Utils.js",
"chars": 1493,
"preview": "'use strict';\n\nlet AbstractAction = require('../../Action/AbstractAction');\nlet Condition = require('../../Model/Co"
},
{
"path": "lib/Command/Scene/CreateScene.js",
"chars": 1569,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name',\n 'lights',\n 'recycle',\n 'appda"
},
{
"path": "lib/Command/Scene/DeleteScene.js",
"chars": 625,
"preview": "'use strict';\n\n/**\n * Delete scene command\n *\n * Delete a scene by id\n */\nclass DeleteScene {\n /**\n * Constructor\n "
},
{
"path": "lib/Command/Scene/GetSceneById.js",
"chars": 702,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get scene by id command\n *\n * Get a list of scenes\n */\nclass GetS"
},
{
"path": "lib/Command/Scene/GetScenes.js",
"chars": 620,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get scenes command\n *\n * Get a list of scenes\n */\nclass GetScenes"
},
{
"path": "lib/Command/Scene/RecallScene.js",
"chars": 647,
"preview": "'use strict';\n\n/**\n * Recall scene command\n *\n * Recall a scene\n */\nclass RecallScene {\n /**\n * Constructor\n *\n *"
},
{
"path": "lib/Command/Scene/SaveScene.js",
"chars": 1521,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name',\n 'lights',\n 'recycle',\n 'appda"
},
{
"path": "lib/Command/Scene/SaveSceneLightState.js",
"chars": 1690,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst STATE_MAP = {\n 'on': 'on',\n 'brightness': 'bri',"
},
{
"path": "lib/Command/Scene/Utils.js",
"chars": 1613,
"preview": "'use strict';\n\nlet Error = require('../../Error');\nlet Light = require('../../Model/Light');\nlet Scene = require('../../"
},
{
"path": "lib/Command/Schedule/CreateSchedule.js",
"chars": 1210,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name',\n 'description',\n 'command',\n '"
},
{
"path": "lib/Command/Schedule/DeleteSchedule.js",
"chars": 661,
"preview": "'use strict';\n\n/**\n * Delete schedule command\n *\n * Delete a schedule by id\n */\nclass DeleteSchedule {\n /**\n * Constr"
},
{
"path": "lib/Command/Schedule/GetSchedule.js",
"chars": 724,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get schedule command\n *\n * Get a schedule by id\n */\nclass GetSche"
},
{
"path": "lib/Command/Schedule/GetSchedules.js",
"chars": 650,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get schedules command\n *\n * Get a list of schedules\n */\nclass Get"
},
{
"path": "lib/Command/Schedule/SaveSchedule.js",
"chars": 1145,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name',\n 'description',\n 'command',\n '"
},
{
"path": "lib/Command/Schedule/Utils.js",
"chars": 1687,
"preview": "'use strict';\n\nlet Error = require('../../Error');\nlet AbstractAction = require('../../Action/AbstractAction');"
},
{
"path": "lib/Command/Sensor/CreateSensor.js",
"chars": 1246,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name',\n 'type',\n 'modelid',\n 'manufac"
},
{
"path": "lib/Command/Sensor/DeleteSensor.js",
"chars": 637,
"preview": "'use strict';\n\n/**\n * Delete sensor command\n *\n * Delete a sensor by id\n */\nclass DeleteSensor {\n /**\n * Constructor\n"
},
{
"path": "lib/Command/Sensor/GetNewSensors.js",
"chars": 911,
"preview": "'use strict';\n\nlet GetSensors = require('./GetSensors');\n\n/**\n * Get new sensors command\n *\n * Get a list of new sensors"
},
{
"path": "lib/Command/Sensor/GetSensor.js",
"chars": 698,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get sensor command\n *\n * Get a sensor by id\n */\nclass GetSensor {"
},
{
"path": "lib/Command/Sensor/GetSensors.js",
"chars": 630,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get sensors command\n *\n * Get a list of sensors\n */\nclass GetSens"
},
{
"path": "lib/Command/Sensor/SaveSensor.js",
"chars": 1346,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\nconst ALLOWED_ATTRIBUTES = [\n 'name'\n];\n\n/**\n * Save sensor command\n *\n"
},
{
"path": "lib/Command/Sensor/SaveSensorConfig.js",
"chars": 831,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Save sensor config command\n *\n * Saves sensor config\n */\nclass Sa"
},
{
"path": "lib/Command/Sensor/SaveSensorState.js",
"chars": 824,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Save sensor state command\n *\n * Saves sensor state\n */\nclass Save"
},
{
"path": "lib/Command/Sensor/StartSensorScan.js",
"chars": 475,
"preview": "'use strict';\n\n/**\n * Start sensor scan command\n *\n * Start a scan for new sensors\n */\nclass StartSensorScan {\n /**\n "
},
{
"path": "lib/Command/Sensor/Utils.js",
"chars": 1655,
"preview": "'use strict';\n\nlet Error = require('../../Error');\nlet Sensor = require('../../Model/Sensor');\n\nconst SENSOR_ATTRIBUTES"
},
{
"path": "lib/Command/SoftwareUpdate/CheckForSoftwareUpdates.js",
"chars": 603,
"preview": "'use strict';\n\n/**\n * Check for software updates command\n *\n * Updates bridge to check for software update\n */\nclass Che"
},
{
"path": "lib/Command/SoftwareUpdate/DisableInstallNotification.js",
"chars": 607,
"preview": "'use strict';\n\n/**\n * Disable install notification command\n *\n * Updates bridge to disable install notification\n */\nclas"
},
{
"path": "lib/Command/SoftwareUpdate/GetSoftwareUpdate.js",
"chars": 552,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get software update command\n *\n * Get software update info\n */\ncl"
},
{
"path": "lib/Command/SoftwareUpdate/InstallSoftwareUpdates.js",
"chars": 592,
"preview": "'use strict';\n\n/**\n * Install software updates command\n *\n * Updates bridge to install software updates\n */\nclass Instal"
},
{
"path": "lib/Command/SoftwareUpdate/Utils.js",
"chars": 929,
"preview": "'use strict';\n\nlet SoftwareUpdate = require('../../Model/SoftwareUpdate');\n\nconst SW_ATTRIBUTES = [\n 'updatestate',\n '"
},
{
"path": "lib/Command/TimeZone/GetTimeZones.js",
"chars": 105,
"preview": "'use strict';\n\nlet GetTimeZones = require('../Capability/GetTimeZones');\n\nmodule.exports = GetTimeZones;\n"
},
{
"path": "lib/Command/User/CreateUser.js",
"chars": 796,
"preview": "'use strict';\n\nlet GetUser = require('./GetUser');\nlet Utils = require('./Utils');\n\n/**\n * Create user command\n *\n * C"
},
{
"path": "lib/Command/User/DeleteUser.js",
"chars": 626,
"preview": "'use strict';\n\n/**\n * Delete user command\n *\n * Delete a user by username\n */\nclass DeleteUser {\n /**\n * Constructor\n"
},
{
"path": "lib/Command/User/GetUser.js",
"chars": 949,
"preview": "'use strict';\n\nlet Error = require('../../Error');\nlet Utils = require('./Utils');\n\n/**\n * Get user command\n *\n * Get a "
},
{
"path": "lib/Command/User/GetUsers.js",
"chars": 689,
"preview": "'use strict';\n\nlet Utils = require('./Utils');\n\n/**\n * Get users command\n *\n * Get a list of registered users\n */\nclass "
},
{
"path": "lib/Command/User/Utils.js",
"chars": 1099,
"preview": "'use strict';\n\nlet Error = require('../../Error');\nlet User = require('../../Model/User');\n\nconst USER_ATTRIBUTES = [\n "
},
{
"path": "lib/Discovery.js",
"chars": 1989,
"preview": "'use strict';\n\nlet Error = require('./Error');\n\nconst ENABLED_STRATEGIES = {\n nupnp: 'Nupnp',\n upnp: 'Upnp',\n};\n\ncons"
},
{
"path": "lib/DiscoveryStrategy/Nupnp.js",
"chars": 969,
"preview": "'use strict';\n\nlet axios = require('axios');\nlet Error = require('../Error');\n\nconst PHILIPS_NUPNP_URL = 'https://discov"
},
{
"path": "lib/DiscoveryStrategy/Upnp.js",
"chars": 2353,
"preview": "'use strict';\n\nlet dgram = require('dgram');\n\nconst SSDP_ADDRESS = '239.255.255.250';\nconst SSDP_PORT = 1"
},
{
"path": "lib/Error.js",
"chars": 585,
"preview": "'use strict';\n\n/**\n * Exception\n *\n * Extends error for customized huejay errors\n */\nclass HuejayError extends Error {\n "
},
{
"path": "lib/GroupModel/AbstractGroupModel.js",
"chars": 848,
"preview": "'use strict';\n\n/**\n * Abstract group model\n */\nclass AbstractGroupModel {\n /**\n * Constructor\n *\n * @param {Objec"
},
{
"path": "lib/GroupModel/Factory.js",
"chars": 441,
"preview": "'use strict';\n\n/**\n * Factory for Group Models\n */\nclass Factory {\n /**\n * Create group model\n *\n * @param {strin"
},
{
"path": "lib/GroupModel/HBL001.js",
"chars": 386,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HBL001',\n "
},
{
"path": "lib/GroupModel/HBL002.js",
"chars": 388,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HBL002',\n "
},
{
"path": "lib/GroupModel/HBL003.js",
"chars": 388,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HBL003',\n "
},
{
"path": "lib/GroupModel/HEL001.js",
"chars": 386,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HEL001',\n "
},
{
"path": "lib/GroupModel/HEL002.js",
"chars": 388,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HEL002',\n "
},
{
"path": "lib/GroupModel/HIL001.js",
"chars": 387,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HIL001',\n "
},
{
"path": "lib/GroupModel/HIL002.js",
"chars": 389,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HIL002',\n "
},
{
"path": "lib/GroupModel/HML001.js",
"chars": 393,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HML001',\n "
},
{
"path": "lib/GroupModel/HML002.js",
"chars": 389,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HML002',\n "
},
{
"path": "lib/GroupModel/HML003.js",
"chars": 389,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HML003',\n "
},
{
"path": "lib/GroupModel/HML004.js",
"chars": 386,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HML004',\n "
},
{
"path": "lib/GroupModel/HML005.js",
"chars": 387,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HML005',\n "
},
{
"path": "lib/GroupModel/HML006.js",
"chars": 391,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HML006',\n "
},
{
"path": "lib/GroupModel/HML007.js",
"chars": 391,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: 'HML007',\n "
},
{
"path": "lib/GroupModel/Unknown.js",
"chars": 359,
"preview": "'use strict';\n\nlet AbstractGroupModel = require('./AbstractGroupModel');\n\nconst DETAILS = {\n id: null,\n manu"
},
{
"path": "lib/Huejay.js",
"chars": 201,
"preview": "'use strict';\n\nmodule.exports = {\n version: require('../package.json').version,\n discover: require('./Discovery').dis"
},
{
"path": "lib/LightModel/AbstractLightModel.js",
"chars": 1156,
"preview": "'use strict';\n\n/**\n * Abstract light model\n */\nclass AbstractLightModel {\n /**\n * Constructor\n *\n * @param {Objec"
},
{
"path": "lib/LightModel/Factory.js",
"chars": 441,
"preview": "'use strict';\n\n/**\n * Factory for Light Models\n */\nclass Factory {\n /**\n * Create light model\n *\n * @param {strin"
},
{
"path": "lib/LightModel/LCT001.js",
"chars": 435,
"preview": "'use strict';\n\nlet AbstractLightModel = require('./AbstractLightModel');\n\nconst DETAILS = {\n id: 'LCT001',\n "
},
{
"path": "lib/LightModel/LCT002.js",
"chars": 436,
"preview": "'use strict';\n\nlet AbstractLightModel = require('./AbstractLightModel');\n\nconst DETAILS = {\n id: 'LCT002',\n "
},
{
"path": "lib/LightModel/LCT003.js",
"chars": 436,
"preview": "'use strict';\n\nlet AbstractLightModel = require('./AbstractLightModel');\n\nconst DETAILS = {\n id: 'LCT003',\n "
}
]
// ... and 103 more files (download for full content)
About this extraction
This page contains the full source code of the sqmk/huejay GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 303 files (318.8 KB), approximately 89.3k tokens, and a symbol index with 1096 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.