forked from peter-murray/node-hue-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatingClipSensors.js
155 lines (113 loc) · 6.09 KB
/
creatingClipSensors.js
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
'use strict';
const v3 = require('../../../index').v3;
// If using this code outside of this library the above should be replaced with
// const v3 = require('node-hue-api').v3;
const model = v3.model;
//**********************************************************************************************************************
// Create a CLIPGenericFlag Sensor
//
const genericFlagSensor = model.createCLIPGenericFlagSensor();
genericFlagSensor.modelid = 'software';
genericFlagSensor.swversion = '1.0';
genericFlagSensor.uniqueid = '00:00:00:01';
genericFlagSensor.manufacturername = 'node-hue-api';
genericFlagSensor.name = 'my-generic-flag-sensor';
// Set the state attribute, flag
genericFlagSensor.flag = false;
// Display the details of the sensor
console.log(JSON.stringify(genericFlagSensor.getHuePayload(), null, 2));
//**********************************************************************************************************************
//**********************************************************************************************************************
// Create a CLIPGenericStatus Sensor
//
const genericStatusSensor = model.createCLIPGenericStatusSensor();
genericStatusSensor.modelid = 'software';
genericStatusSensor.swversion = '1.0';
genericStatusSensor.uniqueid = '00:00:00:01';
genericStatusSensor.manufacturername = 'node-hue-api';
genericStatusSensor.name = 'my-generic-status-sensor';
genericStatusSensor.status = 100;
// Display the payload of the sensor object that can be stored in the Hue Bridge
console.log(JSON.stringify(genericStatusSensor.getHuePayload(), null, 2));
//**********************************************************************************************************************
//**********************************************************************************************************************
// Create a CLIP Humidity Sensor
//
const humiditySensor = model.createCLIPHumiditySensor();
humiditySensor.modelid = 'software';
humiditySensor.swversion = '1.0';
humiditySensor.uniqueid = '00:00:00:01';
humiditySensor.manufacturername = 'node-hue-api';
humiditySensor.name = 'My Humidity Sensor';
humiditySensor.humidity = 2000; // This is 20% as it stores values in 0.01% steps
// Display the payload of the sensor object that can be stored in the Hue Bridge
console.log(JSON.stringify(humiditySensor.getHuePayload(), null, 2));
//**********************************************************************************************************************
//**********************************************************************************************************************
// Create a CLIP Light Level Sensor
//
const lightLevelSensor = model.createCLIPLightlevelSensor();
lightLevelSensor.modelid = 'software';
lightLevelSensor.swversion = '1.0';
lightLevelSensor.uniqueid = '00:00:00:01';
lightLevelSensor.manufacturername = 'node-hue-api';
lightLevelSensor.name = 'Lounge Light Level';
lightLevelSensor.lightlevel = 0;
lightLevelSensor.dark = true;
lightLevelSensor.daylight = false;
// Display the payload of the sensor object that can be stored in the Hue Bridge
console.log(JSON.stringify(lightLevelSensor.getHuePayload(), null, 2));
//**********************************************************************************************************************
//**********************************************************************************************************************
// Create a CLIP Open Close Sensor
//
const openCloseSensor = model.createCLIPOpenCloseSensor();
openCloseSensor.modelid = 'software';
openCloseSensor.swversion = '1.0';
openCloseSensor.uniqueid = '00:00:00:01';
openCloseSensor.manufacturername = 'node-hue-api';
openCloseSensor.name = 'Lounge Door';
openCloseSensor.open = false;
// Display the payload of the sensor object that can be stored in the Hue Bridge
console.log(JSON.stringify(openCloseSensor.getHuePayload(), null, 2));
//**********************************************************************************************************************
//**********************************************************************************************************************
// Create a CLIP Presence Sensor
//
const presenceSensor = model.createCLIPPresenceSensor();
presenceSensor.modelid = 'software';
presenceSensor.swversion = '1.0';
presenceSensor.uniqueid = '00:00:00:01';
presenceSensor.manufacturername = 'node-hue-api';
presenceSensor.name = 'Lounge Presence';
presenceSensor.presence = true;
// Display the payload of the sensor object that can be stored in the Hue Bridge
console.log(JSON.stringify(presenceSensor.getHuePayload(), null, 2));
//**********************************************************************************************************************
//**********************************************************************************************************************
// Create a CLIP Switch Sensor
//
const switchSensor = model.createCLIPSwitchSensor();
switchSensor.modelid = 'software';
switchSensor.swversion = '1.0';
switchSensor.uniqueid = '00:00:00:01';
switchSensor.manufacturername = 'node-hue-api';
switchSensor.name = 'Lounge Wall Switch';
switchSensor.buttonevent = 2000;
// Display the payload of the sensor object that can be stored in the Hue Bridge
console.log(JSON.stringify(switchSensor.getHuePayload(), null, 2));
//**********************************************************************************************************************
//**********************************************************************************************************************
// Create a CLIP Temperature Sensor
//
const tempSensor = model.createCLIPTemperatureSensor();
tempSensor.modelid = 'software';
tempSensor.swversion = '1.0';
tempSensor.uniqueid = '00:00:00:01';
tempSensor.manufacturername = 'node-hue-api';
tempSensor.name = 'Lounge Temperature';
// Set temperature to 38.5 degrees
tempSensor.temperature = 3850;
// Display the payload of the sensor object that can be stored in the Hue Bridge
console.log(JSON.stringify(tempSensor.getHuePayload(), null, 2));
//**********************************************************************************************************************