node-red-contrib-alice 2.1.4 → 2.2.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.
@@ -66,6 +66,12 @@
66
66
  <option value="devices.types.sensor.button">Sensor button</option>
67
67
  <option value="devices.types.sensor.gas">Sensor gas</option>
68
68
  <option value="devices.types.sensor.smoke">Sensor smoke</option>
69
+ <option value="devices.types.smart_meter">Counter</option>
70
+ <option value="devices.types.smart_meter.cold_water">Cold Water counter</option>
71
+ <option value="devices.types.smart_meter.hot_water">Hot Water counter</option>
72
+ <option value="devices.types.smart_meter.electricity">Electricity counter</option>
73
+ <option value="devices.types.smart_meter.gas">Gas counter</option>
74
+ <option value="devices.types.smart_meter.heat">Heat Water counter</option>
69
75
  <option value="devices.types.pet_drinking_fountain">Pet drinking fountain</option>
70
76
  <option value="devices.types.pet_feeder">Pet feeder</option>
71
77
  <option value="devices.types.other">Other</option>
@@ -1,6 +1,5 @@
1
1
  const axios = require('axios');
2
2
 
3
-
4
3
  module.exports = function(RED) {
5
4
  // ***************************** Alice DEVICE ****************************
6
5
  function AliceDevice(config){
@@ -86,7 +86,6 @@
86
86
  .end()
87
87
  .append('<option value="unit.temperature.celsius">Celsius</option>')
88
88
  .append('<option value="unit.temperature.kelvin">Kelvin</option>')
89
- // .val('unit.temperature.celsius')
90
89
  .prop('disabled', false);
91
90
  if (this.unit && this.unit.includes("unit.temperature")){
92
91
  $('#node-input-unit').val(this.unit);
@@ -174,6 +173,51 @@
174
173
  .val('unit.density.mcg_m3')
175
174
  .prop('disabled', 'disabled');
176
175
  break;
176
+ case 'electricity_meter':
177
+ $('#node-input-unit')
178
+ .find('option')
179
+ .remove()
180
+ .end()
181
+ .append('<option value="unit.kilowatt_hour">kW⋅h</option>')
182
+ .val('unit.kilowatt_hour')
183
+ .prop('disabled', 'disabled');
184
+ break;
185
+ case 'gas_meter':
186
+ $('#node-input-unit')
187
+ .find('option')
188
+ .remove()
189
+ .end()
190
+ .append('<option value="unit.cubic_meter">m3</option>')
191
+ .val('unit.cubic_meter')
192
+ .prop('disabled', 'disabled');
193
+ break;
194
+ case 'heat_meter':
195
+ $('#node-input-unit')
196
+ .find('option')
197
+ .remove()
198
+ .end()
199
+ .append('<option value="unit.gigacalorie">Gcal</option>')
200
+ .val('unit.gigacalorie')
201
+ .prop('disabled', 'disabled');
202
+ break;
203
+ case 'water_meter':
204
+ $('#node-input-unit')
205
+ .find('option')
206
+ .remove()
207
+ .end()
208
+ .append('<option value="unit.cubic_meter">m3</option>')
209
+ .val('unit.cubic_meter')
210
+ .prop('disabled', 'disabled');
211
+ break;
212
+ case 'meter':
213
+ $('#node-input-unit')
214
+ .find('option')
215
+ .remove()
216
+ .end()
217
+ // .append('<option value="unit.gigacalorie">Gcal</option>')
218
+ // .val('unit.gigacalorie')
219
+ .prop('disabled', 'disabled');
220
+ break;
177
221
  default:
178
222
  $('#node-input-unit').prop('disabled', 'disabled');
179
223
  break;
@@ -212,15 +256,13 @@
212
256
  <option value="tvoc">TVOC</option>
213
257
  <option value="voltage">Voltage</option>
214
258
  <option value="water_level">Water level</option>
259
+ <option value="electricity_meter">Electricity counter</option>
260
+ <option value="gas_meter">Gas counter</option>
261
+ <option value="water_meter">Water counter</option>
262
+ <option value="meter">Universal counter</option>
215
263
  </select>
216
264
  </div>
217
- <!-- <div class="form-row">
218
- <label for="node-input-stype">Data Type</label>
219
- <select id="node-input-stype" style="width: 70%;" disabled>
220
- <option value="devices.properties.float">Number (float)</option>
221
- <option value="devices.properties.bool">Boolean (true/false)</option>
222
- </select>
223
- </div> -->
265
+
224
266
  <div class="form-row">
225
267
  <label for="node-input-unit">Unit</label>
226
268
  <select id="node-input-unit" style="width: 70%;">
package/nodes/alice.html CHANGED
@@ -56,6 +56,7 @@
56
56
  });
57
57
  };
58
58
  function GetToken(code){
59
+ console.log(this.id);
59
60
  RED.notify("Request has been sent. Please, wait",{type:"compact"});
60
61
  $('#verification_code').prop('disabled', true);
61
62
  $('#submit_button').prop('disabled', true);
@@ -84,8 +85,19 @@
84
85
  $('#submit_button').prop('disabled', false);
85
86
  });
86
87
  }
87
- function ClearDataOnGateway(jToken) {
88
-
88
+ function ClearDevicesConfigOnGateway(email) {
89
+ RED.notify("Request has been sent. Please, wait",{type:"compact"});
90
+ const suburl = btoa(email);
91
+ $.ajax({
92
+ url: "/noderedhome/"+suburl+"/clearalldevice",
93
+ type:"GET"
94
+ })
95
+ .done(result=>{
96
+ RED.notify("All configs have been successfully cleared", {type:"success"});
97
+ })
98
+ .fail(error=>{
99
+ RED.notify("Error when deleting configs on the gateway", {type:"error"});
100
+ })
89
101
  };
90
102
  function pay(id, email) {
91
103
  console.log("Start pay");
@@ -203,11 +215,6 @@
203
215
  <span> - By purchasing a subscription, you agree to the terms of the <a href="https://nodered-home.ru/public_offer.pdf" target="_blank">public offer</a></span><br>
204
216
  <span> - View and manage your subscriptions <a href="https://my.cloudpayments.ru/ru/unsubscribe" target="_blank">here</a></span>
205
217
  <div style="text-align: end">
206
- <!-- <label for="node-input-subList" style="text-align: start">Period:</label>
207
- <select id="node-input-subList" style="width:70%; margin-top:10px; margin-bottom:10px;">
208
- <option value=1>1 month - 199 rubles</option>
209
- <option value=12>12 month - 2 300 rubles</option>
210
- </select> -->
211
218
  <button id="subscribe-button"
212
219
  onclick="pay($('#node-config-input-id').val(), $('#node-config-input-email').val())"
213
220
  class="ui-button">Buy a subscription
@@ -217,21 +224,18 @@
217
224
  </div>
218
225
  </div>
219
226
  <hr>
220
- <div name="Clearing" style="display: none;">
221
- <div class="form-row"><b>Сlear all data on the gateway</b></div>
222
- <div class="form-row">
223
- <p>1. Click the clear button</p>
224
- <p>2. Wait for the success message</p>
225
- <p>3. Сlose the window and do a full deploy</p>
226
- <button
227
- style="margin-left: 150px; margin-top: 10px;"
228
- onclick="ClearDataOnGateway($('#node-config-input-token').val())"
229
- class="ui-button">
230
- Сlear data on the gateway
231
- </button>
232
- </div>
227
+ <div name="Clearing">
228
+ <div class="form-row"><b>Сlear all data and configs on the gateway</b></div>
233
229
  <div class="form-tips" id="node-tip">
234
- <span>Tip: Сlear all data on the gateway may take up to 15 seconds, please wait for success or error message.</span>
230
+ <span>Tip: Сlear all data on the gateway may take up to 15 seconds, please wait for success or error message. When finished, make a full deployment to update the settings on the gateway.</span>
231
+ <div style="text-align: end">
232
+ <button
233
+ style="margin-left: 150px; margin-top: 10px;"
234
+ onclick="ClearDevicesConfigOnGateway($('#node-config-input-email').val())"
235
+ class="ui-button">
236
+ Сlear data on the gateway
237
+ </button>
238
+ </div>
235
239
  </div>
236
240
  </div>
237
241
  </script>
package/nodes/alice.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const mqtt = require('mqtt');
2
+ const axios = require('axios');
2
3
 
3
4
  module.exports = function(RED) {
4
5
  //Sevice node, Alice-Service (credential)
@@ -11,6 +12,29 @@ module.exports = function(RED) {
11
12
  const password = this.credentials.password;
12
13
  const token = this.credentials.token;
13
14
 
15
+ const suburl = Buffer.from(email).toString('base64');
16
+ RED.httpAdmin.get("/noderedhome/"+suburl+"/clearalldevice",(req,res)=>{
17
+ const option = {
18
+ method: 'POST',
19
+ url: 'https://api.nodered-home.ru/gtw/device/clearallconfigs',
20
+ headers: {
21
+ 'content-type': 'application/json',
22
+ 'Authorization': "Bearer "+this.getToken()
23
+ },
24
+ data: {}
25
+ };
26
+ axios.request(option)
27
+ .then(result=>{
28
+ this.trace("All devices configs deleted on gateway successfully");
29
+ // console.log(result)
30
+ res.sendStatus(200);
31
+ })
32
+ .catch(error=>{
33
+ this.debug("Error when delete All devices configs deleted on gateway: "+error.message);
34
+ res.sendStatus(500);
35
+ });
36
+ });
37
+
14
38
  this.isOnline = false;
15
39
  if (!token){
16
40
  this.error("Authentication is required!!!");
@@ -97,3 +121,5 @@ module.exports = function(RED) {
97
121
  });
98
122
  };
99
123
 
124
+
125
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-alice",
3
- "version": "2.1.4",
3
+ "version": "2.2.0",
4
4
  "description": "",
5
5
  "main": "alice.js",
6
6
  "scripts": {