Configuration.js
3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
'use strict';
const configurationApi = require('./http/endpoints/configuration')
, ApiDefinition = require('./http/ApiDefinition.js')
, util = require('../util')
;
/**
* Interacts with the Hue Bridge Configuration.
*
* @typedef {import('@peter-murray/hue-bridge-model').model.BridgeConfiguration} BridgeConfiguration
*
* @type {Configuration}
*/
module.exports = class Configuration extends ApiDefinition {
constructor(hueApi) {
super(hueApi);
}
/**
* Obtains the complete configuration from the Hue Bridge in a raw Object format that is returned from the API.
* This function will return all the config along with all the lights, schedules, groups, scenes, resourcelinks, etc...
*
* @returns {Promise<any>} The raw data returned from the Hue Bridge
*/
getAll() {
return this.execute(configurationApi.getFullState);
}
/**
* Gets the unauthenticated configuration data from the bridge.
* @returns {Promise<any>} The unauthenticated configuration data from the bridge.
*/
getUnauthenticatedConfig() {
return this.execute(configurationApi.getUnauthenticatedConfig);
}
/**
* Updates a configuration value for the Hue Bridge.
* @param data {Object | BridgeConfiguration} An Object (or BridgeConfiguration) representing the data that is to be
* updated for the bridge configuration.
* @deprecated Use updateConfiguration() instead
* @returns {Promise<boolean>}
*/
update(data) {
util.deprecatedFunction('5.x', 'configuration.update(data)', 'Use configuration.updateConfiguration(data) instead');
return this.updateConfiguration(data);
}
/**
* Updates a configuration value for the Hue Bridge.
* @param data {Object | BridgeConfiguration} An Object (or BridgeConfiguration) representing the data that is to be
* updated for the bridge configuration.
* @returns {Promise<boolean>}
*/
updateConfiguration(data) {
return this.execute(configurationApi.updateConfiguration, {config: data});
}
/**
* Obtains the configuration of the Hue Bridge.
* @returns {Object} A object representing the configuration properties of the Hue Bridge.
* @deprecated Use getConfiguration() instead.
*/
get() {
util.deprecatedFunction('5.x', 'configuration.get()', 'Use configuration.getConfiguration() instead');
return this.getConfiguration();
}
/**
* Obtains the configuration of the Hue Bridge.
* @returns {Promise<Object>} A object representing the configuration properties of the Hue Bridge.
*/
getConfiguration() {
return this.execute(configurationApi.getConfiguration);
}
/**
* A virtual press of the link button to perform pairing of software/services. This no longer works on the local
* network connection due to security implications which led to it being disabled by Hue developers.
*
* This will function if you are using the library over the remote API/portal though.
*
* @returns {Promise<boolean>}
*/
pressLinkButton() {
return this.execute(configurationApi.updateConfiguration, {linkbutton: true});
}
};