node-red-contrib-huemagic 2.8.2 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +229 -0
- package/README.md +806 -729
- package/examples/Hue Bridge.json +189 -35
- package/examples/Hue Brightness.json +124 -14
- package/examples/Hue Buttons.json +88 -0
- package/examples/Hue Group.json +575 -63
- package/examples/Hue Light.json +805 -58
- package/examples/Hue Magic.json +69 -24
- package/examples/Hue Motion.json +110 -42
- package/examples/Hue Rules.json +105 -37
- package/examples/Hue Scene.json +145 -28
- package/examples/Hue Temperature.json +124 -14
- package/huemagic/animations/001-sunny.json +22 -22
- package/huemagic/animations/002-cloudy.json +46 -46
- package/huemagic/animations/003-nightsky.json +20 -20
- package/huemagic/animations/004-sunrise.json +54 -54
- package/huemagic/animations/005-sunset.json +46 -46
- package/huemagic/animations/006-fireplace.json +74 -74
- package/huemagic/animations/007-spring.json +31 -31
- package/huemagic/animations/008-autmn.json +23 -23
- package/huemagic/animations/009-winter.json +23 -23
- package/huemagic/animations/010-dirtyfog.json +23 -23
- package/huemagic/animations/011-lgbt.json +49 -50
- package/huemagic/animations/012-rasta.json +28 -29
- package/huemagic/animations/013-strobo.json +30 -31
- package/huemagic/animations/014-randomrainbow.json +30 -31
- package/huemagic/animations/015-sos.json +158 -159
- package/huemagic/animations/016-milkyway.json +83 -0
- package/huemagic/animations/017-beach.json +40 -0
- package/huemagic/animations/018-forest.json +43 -0
- package/huemagic/animations/019-christmas.json +30 -0
- package/huemagic/animations/020-superhero.json +56 -0
- package/huemagic/animations/021-neoncity.json +52 -0
- package/huemagic/animations/previews/001-sunny.gif +0 -0
- package/huemagic/animations/previews/002-cloudy.gif +0 -0
- package/huemagic/animations/previews/003-nightsky.gif +0 -0
- package/huemagic/animations/previews/004-sunrise.gif +0 -0
- package/huemagic/animations/previews/005-sunset.gif +0 -0
- package/huemagic/animations/previews/006-fireplace.gif +0 -0
- package/huemagic/animations/previews/007-spring.gif +0 -0
- package/huemagic/animations/previews/008-autmn.gif +0 -0
- package/huemagic/animations/previews/009-winter.gif +0 -0
- package/huemagic/animations/previews/010-dirtyfog.gif +0 -0
- package/huemagic/animations/previews/011-lgbt.gif +0 -0
- package/huemagic/animations/previews/012-rasta.gif +0 -0
- package/huemagic/animations/previews/013-strobo.gif +0 -0
- package/huemagic/animations/previews/014-randomrainbow.gif +0 -0
- package/huemagic/animations/previews/015-sos.gif +0 -0
- package/huemagic/animations/previews/016-milkyway.gif +0 -0
- package/huemagic/animations/previews/017-beach.gif +0 -0
- package/huemagic/animations/previews/018-forest.gif +0 -0
- package/huemagic/animations/previews/019-christmas.gif +0 -0
- package/huemagic/animations/previews/020-superhero.gif +0 -0
- package/huemagic/animations/previews/021-neoncity.gif +0 -0
- package/huemagic/hue-bridge-config.html +105 -61
- package/huemagic/hue-bridge-config.js +629 -319
- package/huemagic/hue-bridge.html +41 -21
- package/huemagic/hue-bridge.js +191 -398
- package/huemagic/hue-brightness.html +130 -49
- package/huemagic/hue-brightness.js +131 -35
- package/huemagic/hue-buttons.html +197 -0
- package/huemagic/hue-buttons.js +152 -0
- package/huemagic/hue-group.html +137 -60
- package/huemagic/hue-group.js +394 -367
- package/huemagic/hue-light.html +133 -59
- package/huemagic/hue-light.js +551 -336
- package/huemagic/hue-magic.html +91 -237
- package/huemagic/hue-magic.js +57 -27
- package/huemagic/hue-motion.html +128 -50
- package/huemagic/hue-motion.js +116 -87
- package/huemagic/hue-rules.html +121 -50
- package/huemagic/hue-rules.js +84 -64
- package/huemagic/hue-scene.html +96 -115
- package/huemagic/hue-scene.js +65 -96
- package/huemagic/hue-temperature.html +130 -49
- package/huemagic/hue-temperature.js +136 -32
- package/huemagic/icons/hue-bridge.png +0 -0
- package/huemagic/icons/hue-bridge.svg +3 -0
- package/huemagic/icons/hue-brightness.png +0 -0
- package/huemagic/icons/hue-brightness.svg +11 -0
- package/huemagic/icons/hue-buttons.png +0 -0
- package/huemagic/icons/hue-buttons.svg +4 -0
- package/huemagic/icons/hue-group.png +0 -0
- package/huemagic/icons/hue-group.svg +12 -0
- package/huemagic/icons/hue-light.png +0 -0
- package/huemagic/icons/hue-light.svg +3 -0
- package/huemagic/icons/hue-magic.png +0 -0
- package/huemagic/icons/hue-magic.svg +3 -0
- package/huemagic/icons/hue-motion.png +0 -0
- package/huemagic/icons/hue-motion.svg +9 -0
- package/huemagic/icons/hue-rules.png +0 -0
- package/huemagic/icons/hue-rules.svg +4 -0
- package/huemagic/icons/hue-scene.png +0 -0
- package/huemagic/icons/hue-scene.svg +5 -0
- package/huemagic/icons/hue-temperature.png +0 -0
- package/huemagic/icons/hue-temperature.svg +7 -0
- package/huemagic/locales/de/hue-bridge-config.html +17 -12
- package/huemagic/locales/de/hue-bridge-config.json +7 -5
- package/huemagic/locales/de/hue-bridge.html +64 -145
- package/huemagic/locales/de/hue-bridge.json +6 -17
- package/huemagic/locales/de/hue-brightness.html +52 -38
- package/huemagic/locales/de/hue-brightness.json +7 -2
- package/huemagic/locales/de/hue-buttons.html +58 -0
- package/huemagic/locales/de/hue-buttons.json +28 -0
- package/huemagic/locales/de/hue-group.html +46 -122
- package/huemagic/locales/de/hue-group.json +4 -2
- package/huemagic/locales/de/hue-light.html +68 -116
- package/huemagic/locales/de/hue-light.json +5 -2
- package/huemagic/locales/de/hue-magic.html +65 -57
- package/huemagic/locales/de/hue-magic.json +2 -1
- package/huemagic/locales/de/hue-motion.html +48 -44
- package/huemagic/locales/de/hue-motion.json +6 -3
- package/huemagic/locales/de/hue-rules.html +68 -73
- package/huemagic/locales/de/hue-rules.json +5 -2
- package/huemagic/locales/de/hue-scene.html +23 -32
- package/huemagic/locales/de/hue-scene.json +5 -2
- package/huemagic/locales/de/hue-temperature.html +53 -36
- package/huemagic/locales/de/hue-temperature.json +7 -2
- package/huemagic/locales/en-US/hue-bridge-config.html +17 -12
- package/huemagic/locales/en-US/hue-bridge-config.json +5 -3
- package/huemagic/locales/en-US/hue-bridge.html +64 -145
- package/huemagic/locales/en-US/hue-bridge.json +5 -16
- package/huemagic/locales/en-US/hue-brightness.html +52 -38
- package/huemagic/locales/en-US/hue-brightness.json +10 -3
- package/huemagic/locales/en-US/hue-buttons.html +58 -0
- package/huemagic/locales/en-US/hue-buttons.json +34 -0
- package/huemagic/locales/en-US/hue-group.html +46 -122
- package/huemagic/locales/en-US/hue-group.json +7 -3
- package/huemagic/locales/en-US/hue-light.html +68 -116
- package/huemagic/locales/en-US/hue-light.json +8 -3
- package/huemagic/locales/en-US/hue-magic.html +65 -57
- package/huemagic/locales/en-US/hue-magic.json +3 -1
- package/huemagic/locales/en-US/hue-motion.html +48 -44
- package/huemagic/locales/en-US/hue-motion.json +9 -4
- package/huemagic/locales/en-US/hue-rules.html +68 -73
- package/huemagic/locales/en-US/hue-rules.json +5 -2
- package/huemagic/locales/en-US/hue-scene.html +23 -32
- package/huemagic/locales/en-US/hue-scene.json +5 -2
- package/huemagic/locales/en-US/hue-temperature.html +53 -36
- package/huemagic/locales/en-US/hue-temperature.json +10 -3
- package/huemagic/utils/api.js +290 -0
- package/huemagic/utils/color.js +382 -0
- package/{utils → huemagic/utils}/merge.js +9 -6
- package/huemagic/utils/messages.js +447 -0
- package/package.json +12 -12
- package/examples/Hue Switch.json +0 -40
- package/examples/Hue Tap.json +0 -40
- package/huemagic/assets/anime.js +0 -8
- package/huemagic/hue-switch.html +0 -119
- package/huemagic/hue-switch.js +0 -113
- package/huemagic/hue-tap.html +0 -119
- package/huemagic/hue-tap.js +0 -74
- package/huemagic/icons/hue-button.png +0 -0
- package/huemagic/icons/hue-switch.png +0 -0
- package/huemagic/icons/hue-tap.png +0 -0
- package/huemagic/locales/de/hue-switch.html +0 -50
- package/huemagic/locales/de/hue-switch.json +0 -31
- package/huemagic/locales/de/hue-tap.html +0 -41
- package/huemagic/locales/de/hue-tap.json +0 -23
- package/huemagic/locales/en-US/hue-switch.html +0 -50
- package/huemagic/locales/en-US/hue-switch.json +0 -31
- package/huemagic/locales/en-US/hue-tap.html +0 -41
- package/huemagic/locales/en-US/hue-tap.json +0 -23
- package/utils/messages.js +0 -571
- package/utils/rgb.js +0 -188
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<script type="text/x-red" data-help-name="hue-tap">
|
|
2
|
-
<p>Hue Tap node to receive button events.</p>
|
|
3
|
-
|
|
4
|
-
<h3>Setup</h3>
|
|
5
|
-
<p>Select the preconfigured Hue Bridge and hit the search button to find all available Hue Tap devices. Type in the name manually or keep the default device name. Note that events will only sent on deploy (once) and if a button is pressed. If necessary, all status updates of this node can be ignored by activating the "Skip events" option.</p>
|
|
6
|
-
|
|
7
|
-
<h3>Tap Events</h3>
|
|
8
|
-
<p>The event message that the Hue Tap sends contains the following data in the <b>msg.payload</b> object:</p>
|
|
9
|
-
<dl class="message-properties">
|
|
10
|
-
<dt>button<span class="property-type">int</span></dt>
|
|
11
|
-
<dd>Pressed button number from 1-4</dd>
|
|
12
|
-
|
|
13
|
-
<dt>buttonAlt<span class="property-type">int</span></dt>
|
|
14
|
-
<dd>Alternative button number (unparsed from the bridge)</dd>
|
|
15
|
-
|
|
16
|
-
<dt>updated<span class="property-type">string</span></dt>
|
|
17
|
-
<dd>ISO 8601 date string of the last time when a button was pressed</dd>
|
|
18
|
-
</dl>
|
|
19
|
-
|
|
20
|
-
<h3>Additional Sensor Info</h3>
|
|
21
|
-
<p>Additional information about the device is going to be sent to the <b>msg.info</b> object:</p>
|
|
22
|
-
<dl class="message-properties">
|
|
23
|
-
<dt>id<span class="property-type">int</span></dt>
|
|
24
|
-
<dd>Numerical id of the sensor as registered on the bridge</dd>
|
|
25
|
-
|
|
26
|
-
<dt>uniqueId<span class="property-type">string</span></dt>
|
|
27
|
-
<dd>Unique Id of the sensor (typically hardware id)</dd>
|
|
28
|
-
|
|
29
|
-
<dt>name<span class="property-type">string</span></dt>
|
|
30
|
-
<dd>Name for the sensor</dd>
|
|
31
|
-
|
|
32
|
-
<dt>type<span class="property-type">string</span></dt>
|
|
33
|
-
<dd>Sensor type (e.g. Daylight, CLIPTemperature, ZGPSwitch)</dd>
|
|
34
|
-
|
|
35
|
-
<dt>model<span class="property-type">object</span></dt>
|
|
36
|
-
<dd>The model object of the sensor includes model specific information like the model.id, model.manufacturer, model.name and model.type</dd>
|
|
37
|
-
</dl>
|
|
38
|
-
|
|
39
|
-
<h3>Last State Information</h3>
|
|
40
|
-
<p>This node also sends the entire last state data (before the update) in the <b>msg.lastState</b> object. It can either contain false (boolean) or the objects payload (msg.lastState.payload) and info (msg.lastState.info). The return value "false" is only sent if there was no last state, e.g. when the node was newly created or restarted.</p>
|
|
41
|
-
</script>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"hue-tap":
|
|
3
|
-
{
|
|
4
|
-
"config":
|
|
5
|
-
{
|
|
6
|
-
"name": "Name",
|
|
7
|
-
"input-name": "Tap name",
|
|
8
|
-
"skipevents": "Skip events",
|
|
9
|
-
"skipevents-node": "Skip events from node",
|
|
10
|
-
"searching": "Searching Hue Taps…",
|
|
11
|
-
"none-found": "No Hue Taps found!",
|
|
12
|
-
"unknown-error": "Something went wrong. Please retry."
|
|
13
|
-
},
|
|
14
|
-
"node":
|
|
15
|
-
{
|
|
16
|
-
"title": "Hue Tap",
|
|
17
|
-
"not-configured": "not configured",
|
|
18
|
-
"waiting": "waiting…",
|
|
19
|
-
"pressed-button": "Button #__button__ pressed",
|
|
20
|
-
"output": "pressed button"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
package/utils/messages.js
DELETED
|
@@ -1,571 +0,0 @@
|
|
|
1
|
-
let moment = require('moment');
|
|
2
|
-
let rgb = require('./rgb');
|
|
3
|
-
let rgbHex = require('rgb-hex');
|
|
4
|
-
let hexRGB = require('hex-rgb');
|
|
5
|
-
let colornames = require("colornames");
|
|
6
|
-
let colornamer = require('color-namer');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
// HUE BRIDGE
|
|
11
|
-
class HueBridgeMessage
|
|
12
|
-
{
|
|
13
|
-
constructor(bridgeInformation, config)
|
|
14
|
-
{
|
|
15
|
-
this.message = {};
|
|
16
|
-
this.message.payload = {};
|
|
17
|
-
this.message.payload.id = bridgeInformation.id;
|
|
18
|
-
this.message.payload.name = bridgeInformation.name;
|
|
19
|
-
this.message.payload.factoryNew = bridgeInformation.factoryNew;
|
|
20
|
-
this.message.payload.replacesBridgeId = bridgeInformation.replacesBridgeId;
|
|
21
|
-
this.message.payload.dataStoreVersion = bridgeInformation.dataStoreVersion;
|
|
22
|
-
this.message.payload.starterKitId = bridgeInformation.starterKitId;
|
|
23
|
-
this.message.payload.softwareVersion = bridgeInformation.softwareVersion;
|
|
24
|
-
this.message.payload.apiVersion = bridgeInformation.apiVersion;
|
|
25
|
-
this.message.payload.zigbeeChannel = bridgeInformation.zigbeeChannel;
|
|
26
|
-
this.message.payload.macAddress = bridgeInformation.macAddress;
|
|
27
|
-
this.message.payload.ipAddress = bridgeInformation.ipAddress;
|
|
28
|
-
this.message.payload.dhcpEnabled = bridgeInformation.dhcpEnabled;
|
|
29
|
-
this.message.payload.netmask = bridgeInformation.netmask;
|
|
30
|
-
this.message.payload.gateway = bridgeInformation.gateway;
|
|
31
|
-
this.message.payload.proxyAddress = bridgeInformation.proxyAddress;
|
|
32
|
-
this.message.payload.proxyPort = bridgeInformation.proxyPort;
|
|
33
|
-
this.message.payload.utcTime = bridgeInformation.utcTime;
|
|
34
|
-
this.message.payload.timeZone = bridgeInformation.timeZone;
|
|
35
|
-
this.message.payload.localTime = bridgeInformation.localTime;
|
|
36
|
-
this.message.payload.portalServicesEnabled = bridgeInformation.portalServicesEnabled;
|
|
37
|
-
this.message.payload.portalConnected = bridgeInformation.portalConnected;
|
|
38
|
-
this.message.payload.linkButtonEnabled = bridgeInformation.linkButtonEnabled;
|
|
39
|
-
this.message.payload.touchlinkEnabled = bridgeInformation.touchlinkEnabled;
|
|
40
|
-
this.message.payload.autoUpdatesEnabled = config.autoupdates;
|
|
41
|
-
|
|
42
|
-
this.message.payload.model = {};
|
|
43
|
-
this.message.payload.model.id = bridgeInformation.model.id;
|
|
44
|
-
this.message.payload.model.manufacturer = bridgeInformation.model.manufacturer;
|
|
45
|
-
this.message.payload.model.name = bridgeInformation.model.name;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get msg()
|
|
49
|
-
{
|
|
50
|
-
return this.message;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
// HUE BRIGHTNESS
|
|
57
|
-
class HueBrightnessMessage
|
|
58
|
-
{
|
|
59
|
-
constructor(sensor, lastState = false)
|
|
60
|
-
{
|
|
61
|
-
var realLUX = sensor.state.lightLevel - 1;
|
|
62
|
-
realLUX = realLUX / 10000;
|
|
63
|
-
realLUX = Math.round(Math.pow(10, realLUX));
|
|
64
|
-
|
|
65
|
-
this.message = {};
|
|
66
|
-
this.message.payload = {};
|
|
67
|
-
this.message.payload.lux = realLUX;
|
|
68
|
-
this.message.payload.lightLevel = sensor.state.lightLevel;
|
|
69
|
-
this.message.payload.dark = sensor.state.dark;
|
|
70
|
-
this.message.payload.daylight = sensor.state.daylight;
|
|
71
|
-
this.message.payload.updated = moment.utc(sensor.state.lastUpdated).local().format();
|
|
72
|
-
|
|
73
|
-
this.message.info = {};
|
|
74
|
-
this.message.info.id = sensor.id;
|
|
75
|
-
this.message.info.uniqueId = sensor.uniqueId;
|
|
76
|
-
this.message.info.name = sensor.name;
|
|
77
|
-
this.message.info.type = sensor.type;
|
|
78
|
-
this.message.info.softwareVersion = sensor.softwareVersion;
|
|
79
|
-
this.message.info.battery = sensor.config.battery;
|
|
80
|
-
|
|
81
|
-
this.message.info.model = {};
|
|
82
|
-
this.message.info.model.id = sensor.model.id;
|
|
83
|
-
this.message.info.model.manufacturer = sensor.model.manufacturer;
|
|
84
|
-
this.message.info.model.name = sensor.model.name;
|
|
85
|
-
this.message.info.model.type = sensor.model.type;
|
|
86
|
-
|
|
87
|
-
// LAST STATE?
|
|
88
|
-
if(lastState != false)
|
|
89
|
-
{
|
|
90
|
-
var lastStateMessage = new HueBrightnessMessage(lastState, false);
|
|
91
|
-
this.message.lastState = lastStateMessage.msg;
|
|
92
|
-
delete this.message.lastState.lastState;
|
|
93
|
-
}
|
|
94
|
-
else
|
|
95
|
-
{
|
|
96
|
-
this.message.lastState = false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
get msg()
|
|
101
|
-
{
|
|
102
|
-
return this.message;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
//
|
|
108
|
-
// HUE GROUP
|
|
109
|
-
class HueGroupMessage
|
|
110
|
-
{
|
|
111
|
-
constructor(group, config, lastState = false)
|
|
112
|
-
{
|
|
113
|
-
this.message = {};
|
|
114
|
-
this.message.payload = {};
|
|
115
|
-
this.message.payload.on = group.on;
|
|
116
|
-
this.message.payload.allOn = group.allOn;
|
|
117
|
-
this.message.payload.anyOn = group.anyOn;
|
|
118
|
-
this.message.payload.brightness = Math.round((100/254)*group.brightness);
|
|
119
|
-
this.message.payload.brightnessLevel = group.brightness;
|
|
120
|
-
|
|
121
|
-
this.message.info = {};
|
|
122
|
-
this.message.info.id = group.id;
|
|
123
|
-
this.message.info.lightIds = group.lightIds.join(', ');
|
|
124
|
-
this.message.info.name = group.name;
|
|
125
|
-
this.message.info.type = group.type;
|
|
126
|
-
this.message.info.class = group.class;
|
|
127
|
-
|
|
128
|
-
if(group.modelId !== undefined)
|
|
129
|
-
{
|
|
130
|
-
this.message.info.model = {};
|
|
131
|
-
this.message.info.model.id = group.model.id;
|
|
132
|
-
this.message.info.model.uniqueId = group.uniqueId;
|
|
133
|
-
this.message.info.model.manufacturer = group.model.manufacturer;
|
|
134
|
-
this.message.info.model.name = group.model.name;
|
|
135
|
-
this.message.info.model.type = group.model.type;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if(group.xy)
|
|
139
|
-
{
|
|
140
|
-
var rgbColor = rgb.convertXYtoRGB(group.xy[0], group.xy[1], group.brightness);
|
|
141
|
-
|
|
142
|
-
this.message.payload.rgb = rgbColor;
|
|
143
|
-
this.message.payload.hex = rgbHex(rgbColor[0], rgbColor[1], rgbColor[2]);
|
|
144
|
-
|
|
145
|
-
if(config.colornamer == true)
|
|
146
|
-
{
|
|
147
|
-
var cNamesArray = colornamer(rgbHex(rgbColor[0], rgbColor[1], rgbColor[2]));
|
|
148
|
-
this.message.payload.color = cNamesArray.basic[0]["name"];
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if(group.colorTemp)
|
|
153
|
-
{
|
|
154
|
-
this.message.payload.colorTemp = group.colorTemp;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
this.message.payload.updated = moment().format();
|
|
158
|
-
|
|
159
|
-
// LAST STATE?
|
|
160
|
-
if(lastState != false)
|
|
161
|
-
{
|
|
162
|
-
var lastStateMessage = new HueGroupMessage(lastState, config, false);
|
|
163
|
-
this.message.lastState = lastStateMessage.msg;
|
|
164
|
-
delete this.message.lastState.lastState;
|
|
165
|
-
}
|
|
166
|
-
else
|
|
167
|
-
{
|
|
168
|
-
this.message.lastState = false;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
get msg()
|
|
173
|
-
{
|
|
174
|
-
return this.message;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
//
|
|
180
|
-
// HUE LIGHT
|
|
181
|
-
class HueLightMessage
|
|
182
|
-
{
|
|
183
|
-
constructor(light, config, lastState = false)
|
|
184
|
-
{
|
|
185
|
-
this.message = {};
|
|
186
|
-
this.message.payload = {};
|
|
187
|
-
this.message.payload.on = (light.reachable) ? light.on : false;
|
|
188
|
-
this.message.payload.brightness = (light.reachable) ? ((light.brightness) ? Math.round((100/254)*light.brightness) : -1) : 0;
|
|
189
|
-
this.message.payload.brightnessLevel = (light.reachable) ? light.brightness : 0;
|
|
190
|
-
this.message.payload.reachable = light.reachable;
|
|
191
|
-
|
|
192
|
-
this.message.info = {};
|
|
193
|
-
this.message.info.id = light.id;
|
|
194
|
-
this.message.info.uniqueId = light.uniqueId;
|
|
195
|
-
this.message.info.name = light.name;
|
|
196
|
-
this.message.info.type = light.type;
|
|
197
|
-
this.message.info.softwareVersion = light.softwareVersion;
|
|
198
|
-
|
|
199
|
-
this.message.info.model = {};;
|
|
200
|
-
this.message.info.model.id = light.model.id;
|
|
201
|
-
this.message.info.model.manufacturer = light.model.manufacturer;
|
|
202
|
-
this.message.info.model.name = light.model.name;
|
|
203
|
-
this.message.info.model.type = light.model.type;
|
|
204
|
-
this.message.info.model.colorGamut = light.model.colorGamut;
|
|
205
|
-
this.message.info.model.friendsOfHue = light.model.friendsOfHue;
|
|
206
|
-
|
|
207
|
-
if(light.xy)
|
|
208
|
-
{
|
|
209
|
-
var rgbColor = rgb.convertXYtoRGB(light.xy[0], light.xy[1], light.brightness);
|
|
210
|
-
|
|
211
|
-
this.message.payload.rgb = rgbColor;
|
|
212
|
-
this.message.payload.hex = rgbHex(rgbColor[0], rgbColor[1], rgbColor[2]);
|
|
213
|
-
|
|
214
|
-
if(config.colornamer == true)
|
|
215
|
-
{
|
|
216
|
-
var cNamesArray = colornamer(rgbHex(rgbColor[0], rgbColor[1], rgbColor[2]));
|
|
217
|
-
this.message.payload.color = cNamesArray.basic[0]["name"];
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if(light.colorTemp)
|
|
222
|
-
{
|
|
223
|
-
this.message.payload.colorTemp = light.colorTemp;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
this.message.payload.updated = moment().format();
|
|
227
|
-
|
|
228
|
-
// LAST STATE?
|
|
229
|
-
if(lastState != false)
|
|
230
|
-
{
|
|
231
|
-
var lastStateMessage = new HueLightMessage(lastState, config, false);
|
|
232
|
-
this.message.lastState = lastStateMessage.msg;
|
|
233
|
-
delete this.message.lastState.lastState;
|
|
234
|
-
}
|
|
235
|
-
else
|
|
236
|
-
{
|
|
237
|
-
this.message.lastState = false;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
get msg()
|
|
242
|
-
{
|
|
243
|
-
return this.message;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
//
|
|
249
|
-
// HUE MOTION
|
|
250
|
-
class HueMotionMessage
|
|
251
|
-
{
|
|
252
|
-
constructor(sensor, active = true, lastState = false)
|
|
253
|
-
{
|
|
254
|
-
this.message = {};
|
|
255
|
-
this.message.payload = {active: active, motion: (sensor.state.presence) ? true : false, updated: (sensor.state.lastUpdated) ? moment.utc(sensor.state.lastUpdated).local().format() : moment().local().format() };
|
|
256
|
-
|
|
257
|
-
this.message.info = {};
|
|
258
|
-
this.message.info.id = sensor.id;
|
|
259
|
-
this.message.info.uniqueId = sensor.uniqueId;
|
|
260
|
-
this.message.info.name = sensor.name;
|
|
261
|
-
this.message.info.type = sensor.type;
|
|
262
|
-
this.message.info.softwareVersion = sensor.softwareVersion;
|
|
263
|
-
this.message.info.battery = sensor.config.battery;
|
|
264
|
-
|
|
265
|
-
this.message.info.model = {};
|
|
266
|
-
this.message.info.model.id = sensor.model.id;
|
|
267
|
-
this.message.info.model.manufacturer = sensor.model.manufacturer;
|
|
268
|
-
this.message.info.model.name = sensor.model.name;
|
|
269
|
-
this.message.info.model.type = sensor.model.type;
|
|
270
|
-
|
|
271
|
-
// LAST STATE?
|
|
272
|
-
if(lastState != false)
|
|
273
|
-
{
|
|
274
|
-
var lastStateMessage = new HueMotionMessage(lastState, active, false);
|
|
275
|
-
this.message.lastState = lastStateMessage.msg;
|
|
276
|
-
delete this.message.lastState.lastState;
|
|
277
|
-
}
|
|
278
|
-
else
|
|
279
|
-
{
|
|
280
|
-
this.message.lastState = false;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
get msg()
|
|
285
|
-
{
|
|
286
|
-
return this.message;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
//
|
|
292
|
-
// HUE RULES
|
|
293
|
-
class HueRulesMessage
|
|
294
|
-
{
|
|
295
|
-
constructor(rule, lastState = false)
|
|
296
|
-
{
|
|
297
|
-
this.message = {};
|
|
298
|
-
this.message.payload = {};
|
|
299
|
-
this.message.payload.triggered = (rule.lastTriggered != null) ? moment.utc(rule.lastTriggered).local().format() : false;
|
|
300
|
-
|
|
301
|
-
this.message.info = {};
|
|
302
|
-
this.message.info.id = rule.id;
|
|
303
|
-
this.message.info.created = moment.utc(rule.created).local().format();
|
|
304
|
-
this.message.info.name = rule.name;
|
|
305
|
-
this.message.info.timesTriggered = rule.timesTriggered;
|
|
306
|
-
this.message.info.owner = rule.owner;
|
|
307
|
-
this.message.info.status = rule.status;
|
|
308
|
-
|
|
309
|
-
this.message.conditions = [];
|
|
310
|
-
for (let condition of rule.conditions)
|
|
311
|
-
{
|
|
312
|
-
var conditionValues = {};
|
|
313
|
-
conditionValues.address = condition.address;
|
|
314
|
-
conditionValues.operator = condition.operator;
|
|
315
|
-
conditionValues.value = condition.value;
|
|
316
|
-
|
|
317
|
-
this.message.conditions.push(conditionValues);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
this.message.actions = [];
|
|
321
|
-
for (let action of rule.actions)
|
|
322
|
-
{
|
|
323
|
-
var actionValues = {};
|
|
324
|
-
actionValues.address = action.address;
|
|
325
|
-
actionValues.method = action.method;
|
|
326
|
-
actionValues.body = action.body;
|
|
327
|
-
|
|
328
|
-
this.message.actions.push(actionValues);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
// LAST STATE?
|
|
332
|
-
if(lastState != false)
|
|
333
|
-
{
|
|
334
|
-
var lastStateMessage = new HueRulesMessage(lastState, false);
|
|
335
|
-
this.message.lastState = lastStateMessage.msg;
|
|
336
|
-
delete this.message.lastState.lastState;
|
|
337
|
-
}
|
|
338
|
-
else
|
|
339
|
-
{
|
|
340
|
-
this.message.lastState = false;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
get msg()
|
|
345
|
-
{
|
|
346
|
-
return this.message;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
//
|
|
352
|
-
// HUE SCENE
|
|
353
|
-
class HueSceneMessage
|
|
354
|
-
{
|
|
355
|
-
constructor(scene)
|
|
356
|
-
{
|
|
357
|
-
this.message = {};
|
|
358
|
-
this.message.payload = {};
|
|
359
|
-
|
|
360
|
-
this.message.payload.id = scene.id;
|
|
361
|
-
this.message.payload.name = scene.name;
|
|
362
|
-
this.message.payload.lightIds = scene.lightIds.join(', ');
|
|
363
|
-
this.message.payload.owner = scene.owner;
|
|
364
|
-
this.message.payload.appData = scene.appData;
|
|
365
|
-
this.message.payload.lastUpdated = scene.lastUpdated;
|
|
366
|
-
this.message.payload.version = scene.version;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
get msg()
|
|
370
|
-
{
|
|
371
|
-
return this.message;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
//
|
|
377
|
-
// HUE SWITCH
|
|
378
|
-
class HueSwitchMessage
|
|
379
|
-
{
|
|
380
|
-
constructor(sensor, lastState = false)
|
|
381
|
-
{
|
|
382
|
-
// DEFINE HUMAN READABLE BUTTON NAME
|
|
383
|
-
var buttonName = "";
|
|
384
|
-
if(sensor.state.buttonEvent < 2000)
|
|
385
|
-
{
|
|
386
|
-
buttonName = "On";
|
|
387
|
-
}
|
|
388
|
-
else if(sensor.state.buttonEvent < 3000)
|
|
389
|
-
{
|
|
390
|
-
buttonName = "Dim Up";
|
|
391
|
-
}
|
|
392
|
-
else if(sensor.state.buttonEvent < 4000)
|
|
393
|
-
{
|
|
394
|
-
buttonName = "Dim Down";
|
|
395
|
-
}
|
|
396
|
-
else
|
|
397
|
-
{
|
|
398
|
-
buttonName = "Off";
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
// DEFINE HUMAN READABLE BUTTON ACTION
|
|
402
|
-
var buttonAction = "";
|
|
403
|
-
var buttonActionRaw = parseInt(sensor.state.buttonEvent.toString().substring(3));
|
|
404
|
-
|
|
405
|
-
if(buttonActionRaw == 0)
|
|
406
|
-
{
|
|
407
|
-
buttonAction = "pressed";
|
|
408
|
-
}
|
|
409
|
-
else if(buttonActionRaw == 1)
|
|
410
|
-
{
|
|
411
|
-
buttonAction = "holded";
|
|
412
|
-
}
|
|
413
|
-
else if(buttonActionRaw == 2)
|
|
414
|
-
{
|
|
415
|
-
buttonAction = "short released";
|
|
416
|
-
}
|
|
417
|
-
else
|
|
418
|
-
{
|
|
419
|
-
buttonAction = "long released";
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
this.message = {};
|
|
423
|
-
this.message.payload = {};
|
|
424
|
-
this.message.payload.button = sensor.state.buttonEvent;
|
|
425
|
-
this.message.payload.name = buttonName;
|
|
426
|
-
this.message.payload.action = buttonAction;
|
|
427
|
-
this.message.payload.updated = moment.utc(sensor.state.lastUpdated).local().format();
|
|
428
|
-
|
|
429
|
-
this.message.info = {};
|
|
430
|
-
this.message.info.id = sensor.id;
|
|
431
|
-
this.message.info.uniqueId = sensor.uniqueId;
|
|
432
|
-
this.message.info.name = sensor.name;
|
|
433
|
-
this.message.info.type = sensor.type;
|
|
434
|
-
this.message.info.softwareVersion = sensor.softwareVersion;
|
|
435
|
-
this.message.info.battery = sensor.config.battery;
|
|
436
|
-
|
|
437
|
-
this.message.info.model = {};
|
|
438
|
-
this.message.info.model.id = sensor.model.id;
|
|
439
|
-
this.message.info.model.manufacturer = sensor.model.manufacturer;
|
|
440
|
-
this.message.info.model.name = sensor.model.name;
|
|
441
|
-
this.message.info.model.type = sensor.model.type;
|
|
442
|
-
|
|
443
|
-
// LAST STATE?
|
|
444
|
-
if(lastState != false)
|
|
445
|
-
{
|
|
446
|
-
var lastStateMessage = new HueSwitchMessage(lastState, false);
|
|
447
|
-
this.message.lastState = lastStateMessage.msg;
|
|
448
|
-
delete this.message.lastState.lastState;
|
|
449
|
-
}
|
|
450
|
-
else
|
|
451
|
-
{
|
|
452
|
-
this.message.lastState = false;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
get msg()
|
|
457
|
-
{
|
|
458
|
-
return this.message;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
//
|
|
464
|
-
// HUE TAP
|
|
465
|
-
class HueTapMessage
|
|
466
|
-
{
|
|
467
|
-
constructor(sensor, lastState = false)
|
|
468
|
-
{
|
|
469
|
-
var buttonNum = 0;
|
|
470
|
-
if(sensor.state.buttonEvent == 34)
|
|
471
|
-
{
|
|
472
|
-
buttonNum = 1;
|
|
473
|
-
}
|
|
474
|
-
else if(sensor.state.buttonEvent == 16)
|
|
475
|
-
{
|
|
476
|
-
buttonNum = 2;
|
|
477
|
-
}
|
|
478
|
-
else if(sensor.state.buttonEvent == 17)
|
|
479
|
-
{
|
|
480
|
-
buttonNum = 3;
|
|
481
|
-
}
|
|
482
|
-
else if(sensor.state.buttonEvent == 18)
|
|
483
|
-
{
|
|
484
|
-
buttonNum = 4;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
this.message = {};
|
|
488
|
-
this.message.payload = {button: buttonNum, buttonAlt: sensor.state.buttonEvent, updated: moment.utc(sensor.state.lastUpdated).local().format()};
|
|
489
|
-
|
|
490
|
-
this.message.info = {};
|
|
491
|
-
this.message.info.id = sensor.id;
|
|
492
|
-
this.message.info.uniqueId = sensor.uniqueId;
|
|
493
|
-
this.message.info.name = sensor.name;
|
|
494
|
-
this.message.info.type = sensor.type;
|
|
495
|
-
|
|
496
|
-
this.message.info.model = {};
|
|
497
|
-
this.message.info.model.id = sensor.model.id;
|
|
498
|
-
this.message.info.model.manufacturer = sensor.model.manufacturer;
|
|
499
|
-
this.message.info.model.name = sensor.model.name;
|
|
500
|
-
this.message.info.model.type = sensor.model.type;
|
|
501
|
-
|
|
502
|
-
// LAST STATE?
|
|
503
|
-
if(lastState != false)
|
|
504
|
-
{
|
|
505
|
-
var lastStateMessage = new HueTapMessage(lastState, false);
|
|
506
|
-
this.message.lastState = lastStateMessage.msg;
|
|
507
|
-
delete this.message.lastState.lastState;
|
|
508
|
-
}
|
|
509
|
-
else
|
|
510
|
-
{
|
|
511
|
-
this.message.lastState = false;
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
get msg()
|
|
516
|
-
{
|
|
517
|
-
return this.message;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
//
|
|
523
|
-
// HUE TEMPERATURE
|
|
524
|
-
class HueTemperatureMessage
|
|
525
|
-
{
|
|
526
|
-
constructor(sensor, lastState = false)
|
|
527
|
-
{
|
|
528
|
-
var deviceValue = sensor.state.temperature*100;
|
|
529
|
-
var celsius = Math.round(sensor.state.temperature * 100) / 100;
|
|
530
|
-
var fahrenheit = Math.round(((celsius * 1.8)+32) * 100) / 100;
|
|
531
|
-
|
|
532
|
-
this.message = {};
|
|
533
|
-
this.message.payload = {celsius: celsius, fahrenheit: fahrenheit, deviceValue: deviceValue, updated: moment.utc(sensor.state.lastUpdated).local().format()};
|
|
534
|
-
|
|
535
|
-
this.message.info = {};
|
|
536
|
-
this.message.info.id = sensor.id;
|
|
537
|
-
this.message.info.uniqueId = sensor.uniqueId;
|
|
538
|
-
this.message.info.name = sensor.name;
|
|
539
|
-
this.message.info.type = sensor.type;
|
|
540
|
-
this.message.info.softwareVersion = sensor.softwareVersion;
|
|
541
|
-
this.message.info.battery = sensor.config.battery;
|
|
542
|
-
|
|
543
|
-
this.message.info.model = {};
|
|
544
|
-
this.message.info.model.id = sensor.model.id;
|
|
545
|
-
this.message.info.model.manufacturer = sensor.model.manufacturer;
|
|
546
|
-
this.message.info.model.name = sensor.model.name;
|
|
547
|
-
this.message.info.model.type = sensor.model.type;
|
|
548
|
-
|
|
549
|
-
// LAST STATE?
|
|
550
|
-
if(lastState != false)
|
|
551
|
-
{
|
|
552
|
-
var lastStateMessage = new HueTemperatureMessage(lastState, false);
|
|
553
|
-
this.message.lastState = lastStateMessage.msg;
|
|
554
|
-
delete this.message.lastState.lastState;
|
|
555
|
-
}
|
|
556
|
-
else
|
|
557
|
-
{
|
|
558
|
-
this.message.lastState = false;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
get msg()
|
|
563
|
-
{
|
|
564
|
-
return this.message;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
//
|
|
569
|
-
// EXPORT
|
|
570
|
-
module.exports = { HueBridgeMessage, HueBrightnessMessage, HueGroupMessage, HueLightMessage, HueMotionMessage, HueRulesMessage, HueSceneMessage, HueSwitchMessage, HueTapMessage, HueTemperatureMessage }
|
|
571
|
-
|