node-red-contrib-googlehome 0.0.14 → 1.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/README.md CHANGED
@@ -17,4 +17,6 @@ You will need an account [here](https://googlehome.hardill.me.uk). Once you have
17
17
  account you can define a number of devices. You can then configure a node to represent
18
18
  that device in a Node-RED flow.
19
19
 
20
- The full documentation can be found [here](https://googlehome.hardill.me.uk/docs)
20
+ The full documentation can be found [here](https://googlehome.hardill.me.uk/docs)
21
+
22
+ Minimum NodeJS version is now 20 (uses `fetch` to replace `request`)
package/googlehome.html CHANGED
@@ -12,11 +12,11 @@
12
12
  -->
13
13
  <script type="text/html" data-template-name="google-home-conf">
14
14
  <div class="form-row">
15
- <label for="node-config-input-username"><i class="icon-tag"></i> Username</label>
15
+ <label for="node-config-input-username"><i class="fa fa-user"></i> Username</label>
16
16
  <input type="text" id="node-config-input-username">
17
17
  </div>
18
18
  <div class="form-row">
19
- <label for="node-config-input-password"><i class="icon-tag"></i> Password</label>
19
+ <label for="node-config-input-password"><i class="fa fa-key"></i> Password</label>
20
20
  <input type="password" id="node-config-input-password">
21
21
  </div>
22
22
  </script>
@@ -64,11 +64,11 @@
64
64
 
65
65
  <script type="text/html" data-template-name="google-home">
66
66
  <div class="form-row">
67
- <label for="node-input-conf"><i class="icon-tag"></i> Account</label>
67
+ <label for="node-input-conf"><i class="fa fa-tag"></i> Account</label>
68
68
  <input type="text" id="node-input-conf">
69
69
  </div>
70
70
  <div class="form-row">
71
- <label for="node-input-device"><i class="icon-tag"></i> Device</label>
71
+ <label for="node-input-device"><i class="fa fa-tag"></i> Device</label>
72
72
  <select id="node-input-device">
73
73
  </select>
74
74
  <a id="node-input-device-refresh" class="btn"><i class="fa fa-refresh"></i></a>
@@ -79,11 +79,11 @@
79
79
  <label for="node-input-acknowledge" style="width: 70%"> Auto Acknowledge</span>
80
80
  </div>
81
81
  <div class="form-row">
82
- <label for="node-input-topic"><i class="icon-tag"></i> Topic</label>
82
+ <label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
83
83
  <input type="text" id="node-input-topic">
84
84
  </div>
85
85
  <div class="form-row">
86
- <label for="node-input-name"><i class="icon-tag"></i> Name</label>
86
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
87
87
  <input type="text" id="node-input-name">
88
88
  </div>
89
89
  </script>
@@ -210,17 +210,17 @@
210
210
 
211
211
  <script type="text/html" data-template-name="google-home-response">
212
212
  <div class="form-row">
213
- <label for="node-input-conf"><i class="icon-tag"></i> Account</label>
213
+ <label for="node-input-conf"><i class="fa fa-tag"></i> Account</label>
214
214
  <input type="text" id="node-input-conf">
215
215
  </div>
216
216
  <div class="form-row">
217
- <label for="node-input-device"><i class="icon-tag"></i> Device</label>
217
+ <label for="node-input-device"><i class="fa fa-tag"></i> Device</label>
218
218
  <select id="node-input-device">
219
219
  </select>
220
220
  <a id="node-input-device-refresh" class="btn"><i class="fa fa-refresh"></i></a>
221
221
  </div>
222
222
  <div class="form-row">
223
- <label for="node-input-name"><i class="icon-tag"></i> Name</label>
223
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
224
224
  <input type="text" id="node-input-name">
225
225
  </div>
226
226
  </script>
package/googlehome.js CHANGED
@@ -23,7 +23,6 @@ module.exports = function(RED) {
23
23
  const fs = require('fs');
24
24
  const mqtt = require('mqtt');
25
25
  const path = require('path');
26
- const request = require('request');
27
26
 
28
27
  var devices = {};
29
28
  var status = {};
@@ -214,6 +213,7 @@ module.exports = function(RED) {
214
213
  //console.log("replying to a command")
215
214
  var resp = {
216
215
  requestId: msg._requestId,
216
+ status: msg.status,
217
217
  id: msg.deviceId,
218
218
  execution: msg.payload
219
219
  }
@@ -254,21 +254,25 @@ module.exports = function(RED) {
254
254
 
255
255
  function getDevices(username, password, id) {
256
256
  if (username && password) {
257
- request.get({
258
- url: devicesURL,
259
- auth: {
260
- username: username,
261
- password: password
257
+ fetch(devicesURL, {
258
+ method: 'GET',
259
+ headers: {
260
+ 'Authorization': `Basic ${Buffer.from(username + ':' + password, "utf-8").toString('base64')}`
262
261
  }
263
- }, function(err,res,body) {
264
- if (!err && res.statusCode == 200) {
265
- var devs = JSON.parse(body);
266
- devices[id] = devs
262
+ })
263
+ .then(res => {
264
+ if (res.status === 200) {
265
+ return res.json()
267
266
  } else {
268
- //console.("err: " + err);
269
267
  RED.log.log("Problem looking up " + username + "'s devices");
270
268
  }
271
- });
269
+ })
270
+ .then(json => {
271
+ devices[id] = json
272
+ })
273
+ .catch( err => {
274
+ console.log(err)
275
+ })
272
276
  }
273
277
  }
274
278
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-googlehome",
3
- "version": "0.0.14",
3
+ "version": "1.0.0",
4
4
  "description": "A Smart Home Action for Google Home",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,7 +26,9 @@
26
26
  "author": "hardillb@gmail.com",
27
27
  "license": "Apache-2.0",
28
28
  "dependencies": {
29
- "mqtt": "^4.2.6",
30
- "request": "^2.83.0"
29
+ "mqtt": "^5.15.1"
30
+ },
31
+ "engines": {
32
+ "node": ">=18.x"
31
33
  }
32
34
  }