node-red-contrib-alice 0.6.2 → 0.6.6
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/nodes/alice-sensor.html +54 -11
- package/nodes/alice-sensor.js +10 -5
- package/nodes/alice-togle.js +6 -5
- package/nodes/alice.html +30 -17
- package/nodes/alice.js +7 -3
- package/package.json +2 -2
package/nodes/alice-sensor.html
CHANGED
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
var val = $('#node-input-instance').find(":selected").val();
|
|
27
27
|
switch (val) {
|
|
28
28
|
case 'amperage':
|
|
29
|
-
// $('#node-input-stype').val("devices.properties.float");
|
|
30
29
|
$('#node-input-unit')
|
|
31
30
|
.find('option')
|
|
32
31
|
.remove()
|
|
@@ -36,7 +35,6 @@
|
|
|
36
35
|
.prop('disabled', 'disabled');
|
|
37
36
|
break;
|
|
38
37
|
case 'battery_level':
|
|
39
|
-
// $('#node-input-stype').val("devices.properties.float");
|
|
40
38
|
$('#node-input-unit')
|
|
41
39
|
.find('option')
|
|
42
40
|
.remove()
|
|
@@ -46,7 +44,6 @@
|
|
|
46
44
|
.prop('disabled', 'disabled');
|
|
47
45
|
break;
|
|
48
46
|
case 'co2_level':
|
|
49
|
-
// $('#node-input-stype').val("devices.properties.float");
|
|
50
47
|
$('#node-input-unit')
|
|
51
48
|
.find('option')
|
|
52
49
|
.remove()
|
|
@@ -56,7 +53,6 @@
|
|
|
56
53
|
.prop('disabled', 'disabled');
|
|
57
54
|
break;
|
|
58
55
|
case 'humidity':
|
|
59
|
-
// $('#node-input-stype').val("devices.properties.float");
|
|
60
56
|
$('#node-input-unit')
|
|
61
57
|
.find('option')
|
|
62
58
|
.remove()
|
|
@@ -66,7 +62,6 @@
|
|
|
66
62
|
.prop('disabled', 'disabled');
|
|
67
63
|
break;
|
|
68
64
|
case 'power':
|
|
69
|
-
// $('#node-input-stype').val("devices.properties.float");
|
|
70
65
|
$('#node-input-unit')
|
|
71
66
|
.find('option')
|
|
72
67
|
.remove()
|
|
@@ -76,7 +71,6 @@
|
|
|
76
71
|
.prop('disabled', 'disabled');
|
|
77
72
|
break;
|
|
78
73
|
case 'temperature':
|
|
79
|
-
// $('#node-input-stype').val("devices.properties.float");
|
|
80
74
|
$('#node-input-unit')
|
|
81
75
|
.find('option')
|
|
82
76
|
.remove()
|
|
@@ -92,7 +86,6 @@
|
|
|
92
86
|
}
|
|
93
87
|
break;
|
|
94
88
|
case 'voltage':
|
|
95
|
-
// $('#node-input-stype').val("devices.properties.float");
|
|
96
89
|
$('#node-input-unit')
|
|
97
90
|
.find('option')
|
|
98
91
|
.remove()
|
|
@@ -102,7 +95,6 @@
|
|
|
102
95
|
.prop('disabled', 'disabled');
|
|
103
96
|
break;
|
|
104
97
|
case 'water_level':
|
|
105
|
-
// $('#node-input-stype').val("devices.properties.float");
|
|
106
98
|
$('#node-input-unit')
|
|
107
99
|
.find('option')
|
|
108
100
|
.remove()
|
|
@@ -111,8 +103,16 @@
|
|
|
111
103
|
.val('unit.percent')
|
|
112
104
|
.prop('disabled', 'disabled');
|
|
113
105
|
break;
|
|
106
|
+
case 'illumination':
|
|
107
|
+
$('#node-input-unit')
|
|
108
|
+
.find('option')
|
|
109
|
+
.remove()
|
|
110
|
+
.end()
|
|
111
|
+
.append('<option value="unit.illumination.lux">Lux (lx)</option>')
|
|
112
|
+
.val('unit.illumination.lux')
|
|
113
|
+
.prop('disabled', 'disabled');
|
|
114
|
+
break;
|
|
114
115
|
case 'pressure':
|
|
115
|
-
// $('#node-input-stype').val("devices.properties.float");
|
|
116
116
|
$('#node-input-unit')
|
|
117
117
|
.find('option')
|
|
118
118
|
.remove()
|
|
@@ -129,6 +129,42 @@
|
|
|
129
129
|
$('#node-input-unit').val('unit.pressure.bar');
|
|
130
130
|
}
|
|
131
131
|
break;
|
|
132
|
+
case 'pm1_density':
|
|
133
|
+
$('#node-input-unit')
|
|
134
|
+
.find('option')
|
|
135
|
+
.remove()
|
|
136
|
+
.end()
|
|
137
|
+
.append('<option value="unit.density.mcg_m3">μg/m3</option>')
|
|
138
|
+
.val('unit.density.mcg_m3')
|
|
139
|
+
.prop('disabled', 'disabled');
|
|
140
|
+
break;
|
|
141
|
+
case 'pm2.5_density':
|
|
142
|
+
$('#node-input-unit')
|
|
143
|
+
.find('option')
|
|
144
|
+
.remove()
|
|
145
|
+
.end()
|
|
146
|
+
.append('<option value="unit.density.mcg_m3">μg/m3</option>')
|
|
147
|
+
.val('unit.density.mcg_m3')
|
|
148
|
+
.prop('disabled', 'disabled');
|
|
149
|
+
break;
|
|
150
|
+
case 'pm10_density':
|
|
151
|
+
$('#node-input-unit')
|
|
152
|
+
.find('option')
|
|
153
|
+
.remove()
|
|
154
|
+
.end()
|
|
155
|
+
.append('<option value="unit.density.mcg_m3">μg/m3</option>')
|
|
156
|
+
.val('unit.density.mcg_m3')
|
|
157
|
+
.prop('disabled', 'disabled');
|
|
158
|
+
break;
|
|
159
|
+
case 'tvoc':
|
|
160
|
+
$('#node-input-unit')
|
|
161
|
+
.find('option')
|
|
162
|
+
.remove()
|
|
163
|
+
.end()
|
|
164
|
+
.append('<option value="unit.density.mcg_m3">μg/m3</option>')
|
|
165
|
+
.val('unit.density.mcg_m3')
|
|
166
|
+
.prop('disabled', 'disabled');
|
|
167
|
+
break;
|
|
132
168
|
default:
|
|
133
169
|
$('#node-input-unit').prop('disabled', 'disabled');
|
|
134
170
|
break;
|
|
@@ -154,14 +190,19 @@
|
|
|
154
190
|
<select id="node-input-instance" style="width: 70%;">
|
|
155
191
|
<!-- <option value="contact">Contact</option> -->
|
|
156
192
|
<!-- <option value="motion">Motion</option> -->
|
|
193
|
+
<option value="amperage">Amperage</option>
|
|
157
194
|
<option value="battery_level">Battery level</option>
|
|
158
195
|
<option value="co2_level">CO2 level</option>
|
|
159
196
|
<option value="humidity">Humidity</option>
|
|
160
|
-
<option value="
|
|
197
|
+
<option value="illumination">Illumination</option>
|
|
198
|
+
<option value="pm1_density">PM 1 density</option>
|
|
199
|
+
<option value="pm2.5_density">PM 2.5_density</option>
|
|
200
|
+
<option value="pm10_density">PM 10 density</option>
|
|
161
201
|
<option value="power">Power</option>
|
|
162
202
|
<option value="pressure">Pressure</option>
|
|
203
|
+
<option value="temperature">Temperature</option>
|
|
204
|
+
<option value="tvoc">TVOC</option>
|
|
163
205
|
<option value="voltage">Voltage</option>
|
|
164
|
-
<option value="amperage">Amperage</option>
|
|
165
206
|
<option value="water_level">Water level</option>
|
|
166
207
|
</select>
|
|
167
208
|
</div>
|
|
@@ -182,6 +223,8 @@
|
|
|
182
223
|
<option value="unit.ampere">Ampere (A)</option>
|
|
183
224
|
<option value="unit.volt">Volt (V)</option>
|
|
184
225
|
<option value="unit.watt">Watt (W)</option>
|
|
226
|
+
<option value="unit.illumination.lux">Lux (lx)</option>
|
|
227
|
+
<option value="unit.density.mcg_m3">μg/m3</option>
|
|
185
228
|
</select>
|
|
186
229
|
</div>
|
|
187
230
|
</script>
|
package/nodes/alice-sensor.js
CHANGED
|
@@ -57,16 +57,21 @@ function AliceSensor(config){
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
this.on('input', (msg, send, done)=>{
|
|
60
|
-
if (this.stype =='devices.properties.bool' && typeof msg.payload != 'boolean'){
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
};
|
|
60
|
+
// if (this.stype =='devices.properties.bool' && typeof msg.payload != 'boolean'){
|
|
61
|
+
// this.error("Wrong type! msg.payload must be boolean.");
|
|
62
|
+
// if (done) {done();}
|
|
63
|
+
// return;
|
|
64
|
+
// };
|
|
65
65
|
if (this.stype =='devices.properties.float' && typeof msg.payload != 'number'){
|
|
66
66
|
this.error("Wrong type! msg.payload must be number.");
|
|
67
67
|
if (done) {done();}
|
|
68
68
|
return;
|
|
69
69
|
};
|
|
70
|
+
if (this.unit == 'unit.percent'){
|
|
71
|
+
msg.payload = +msg.payload.toFixed(0);
|
|
72
|
+
}else {
|
|
73
|
+
msg.payload = +msg.payload.toFixed(2);
|
|
74
|
+
};
|
|
70
75
|
if (msg.payload === this.value){
|
|
71
76
|
this.debug("Value not changed. Cancel update");
|
|
72
77
|
if (done) {done();}
|
package/nodes/alice-togle.js
CHANGED
|
@@ -21,6 +21,7 @@ module.exports = function(RED) {
|
|
|
21
21
|
let capab = {
|
|
22
22
|
type: this.ctype,
|
|
23
23
|
retrievable: true,
|
|
24
|
+
reportable: true,
|
|
24
25
|
parameters: {
|
|
25
26
|
instance: this.instance,
|
|
26
27
|
},
|
|
@@ -54,21 +55,21 @@ module.exports = function(RED) {
|
|
|
54
55
|
});
|
|
55
56
|
|
|
56
57
|
this.device.on(this.id,(val)=>{
|
|
58
|
+
this.debug("Received a new value from Yandex...");
|
|
57
59
|
this.send({
|
|
58
60
|
payload: val
|
|
59
61
|
});
|
|
60
|
-
let state
|
|
61
|
-
state:{
|
|
62
|
+
let state={
|
|
62
63
|
value: val,
|
|
63
64
|
updatedfrom: "node-red",
|
|
64
65
|
updated: this.device.getTime()
|
|
65
|
-
}
|
|
66
|
-
};
|
|
66
|
+
};
|
|
67
67
|
if (this.response){
|
|
68
|
+
this.debug("Automatic confirmation is true, sending confirmation to Yandex ...");
|
|
68
69
|
this.device.updateCapabState(this.id,state)
|
|
69
70
|
.then (res=>{
|
|
70
71
|
this.value = val;
|
|
71
|
-
this.status({fill:"green",shape:"dot",text:
|
|
72
|
+
this.status({fill:"green",shape:"dot",text:val});
|
|
72
73
|
})
|
|
73
74
|
.catch(err=>{
|
|
74
75
|
this.error("Error on update capability state: " + err.message);
|
package/nodes/alice.html
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
|
|
2
|
-
<script defer src="https://www.gstatic.com/firebasejs/7.14.5/firebase-app.js"></script>
|
|
2
|
+
<!-- <script defer src="https://www.gstatic.com/firebasejs/7.14.5/firebase-app.js"></script>
|
|
3
3
|
<script defer src="https://www.gstatic.com/firebasejs/7.14.5/firebase-auth.js"></script>
|
|
4
|
-
<script defer src="https://www.gstatic.com/firebasejs/7.14.5/firebase-firestore.js"></script>
|
|
4
|
+
<script defer src="https://www.gstatic.com/firebasejs/7.14.5/firebase-firestore.js"></script> -->
|
|
5
|
+
|
|
6
|
+
<script src="https://www.gstatic.com/firebasejs/9.0.2/firebase-app-compat.js"></script>
|
|
7
|
+
<script src="https://www.gstatic.com/firebasejs/9.0.2/firebase-firestore-compat.js"></script>
|
|
8
|
+
<script src="https://www.gstatic.com/firebasejs/9.0.2/firebase-auth-compat.js"></script>
|
|
5
9
|
|
|
6
10
|
<script type="text/javascript">
|
|
7
11
|
const firebaseConfig = {
|
|
@@ -14,6 +18,9 @@
|
|
|
14
18
|
appId: "1:1049686868440:web:e5f5ef6a70ead338b6f2ad",
|
|
15
19
|
measurementId: "G-MD0L6R9N79"
|
|
16
20
|
};
|
|
21
|
+
var firebaseApp;
|
|
22
|
+
var firebaseDb;
|
|
23
|
+
var firebaseAuth;
|
|
17
24
|
RED.nodes.registerType('alice-service',{
|
|
18
25
|
category: 'config',
|
|
19
26
|
defaults: {
|
|
@@ -26,6 +33,11 @@
|
|
|
26
33
|
label: function() {
|
|
27
34
|
return this.name || "Alice-Credentials";
|
|
28
35
|
},
|
|
36
|
+
oneditprepare:function(){
|
|
37
|
+
firebaseApp = firebase.initializeApp(firebaseConfig);
|
|
38
|
+
firebaseDb = firebaseApp.firestore();
|
|
39
|
+
firebaseAuth = firebaseApp.auth();
|
|
40
|
+
},
|
|
29
41
|
oneditsave: function(){
|
|
30
42
|
nodename = $('#node-config-input-email').val();
|
|
31
43
|
$('#node-config-input-name').val(nodename);
|
|
@@ -60,12 +72,13 @@
|
|
|
60
72
|
};
|
|
61
73
|
function SingUp(){
|
|
62
74
|
// Initialize Firebase
|
|
63
|
-
if (!firebase.apps.length) {
|
|
64
|
-
firebase.initializeApp(firebaseConfig);
|
|
65
|
-
};
|
|
75
|
+
// if (!firebase.apps.length) {
|
|
76
|
+
// firebase.initializeApp(firebaseConfig);
|
|
77
|
+
// };
|
|
78
|
+
|
|
66
79
|
var email = document.getElementById("register_email").value;
|
|
67
80
|
var password = document.getElementById("register_password").value;
|
|
68
|
-
|
|
81
|
+
firebaseAuth.createUserWithEmailAndPassword(email, password)
|
|
69
82
|
.then(function(r){
|
|
70
83
|
document.getElementById("node-config-input-email").value = email;
|
|
71
84
|
document.getElementById("node-config-input-password").value = password;
|
|
@@ -77,12 +90,12 @@
|
|
|
77
90
|
})
|
|
78
91
|
};
|
|
79
92
|
function Restore(){
|
|
80
|
-
// Initialize Firebase
|
|
81
|
-
if (!firebase.apps.length) {
|
|
82
|
-
|
|
83
|
-
};
|
|
93
|
+
// // Initialize Firebase
|
|
94
|
+
// if (!firebase.apps.length) {
|
|
95
|
+
// firebase.initializeApp(firebaseConfig);
|
|
96
|
+
// };
|
|
84
97
|
var emailAddress = document.getElementById("restore_email").value;
|
|
85
|
-
|
|
98
|
+
firebaseAuth.sendPasswordResetEmail(emailAddress).then(function() {
|
|
86
99
|
RED.notify("Password recovery email was sent successfully! Please check your email.", 'info');
|
|
87
100
|
Activete();
|
|
88
101
|
}).catch(function(error) {
|
|
@@ -90,16 +103,16 @@
|
|
|
90
103
|
});
|
|
91
104
|
}
|
|
92
105
|
function DeleteAllDevices() {
|
|
93
|
-
if (!firebase.apps.length) {
|
|
94
|
-
|
|
95
|
-
};
|
|
96
|
-
var db = firebase.firestore();
|
|
106
|
+
// if (!firebase.apps.length) {
|
|
107
|
+
// firebase.initializeApp(firebaseConfig);
|
|
108
|
+
// };
|
|
109
|
+
// var db = firebase.firestore();
|
|
97
110
|
var email = document.getElementById("delete_email").value;
|
|
98
111
|
var password = document.getElementById("delete_password").value;
|
|
99
|
-
|
|
112
|
+
firebaseAuth.signInWithEmailAndPassword(email, password)
|
|
100
113
|
.then((res)=>{
|
|
101
114
|
var user = res.user;
|
|
102
|
-
|
|
115
|
+
firebaseDb.collection('users').doc(user.uid).collection('devices').get()
|
|
103
116
|
.then(querySnapshot=>{
|
|
104
117
|
querySnapshot.forEach(doc=>{
|
|
105
118
|
doc.ref.collection('capabilities').get().then(capabSnapshot=>{
|
package/nodes/alice.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
// import firebase from 'firebase/compat/app';
|
|
2
|
+
// import 'firebase/compat/auth';
|
|
3
|
+
// import 'firebase/compat/firestore';
|
|
1
4
|
module.exports = function(RED) {
|
|
2
5
|
//Sevice node, Alice-Service (credential)
|
|
3
6
|
function AliceService(config) {
|
|
4
7
|
RED.nodes.createNode(this,config);
|
|
5
8
|
this.debug("Starting Alice service...");
|
|
6
|
-
var firebase = require('firebase/app');
|
|
7
|
-
require('firebase/auth');
|
|
8
|
-
require('firebase/firestore');
|
|
9
|
+
var firebase = require('firebase/compat/app');
|
|
10
|
+
require('firebase/compat/auth');
|
|
11
|
+
require('firebase/compat/firestore');
|
|
12
|
+
|
|
9
13
|
var mqtt = require('mqtt');
|
|
10
14
|
var fb;
|
|
11
15
|
const email = this.credentials.email;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-alice",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "alice.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/efa2000/node-red-contrib-alice#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"firebase": "
|
|
38
|
+
"firebase": "9.0.1",
|
|
39
39
|
"mqtt": "^4.2.6"
|
|
40
40
|
}
|
|
41
41
|
}
|