node-red-contrib-periph-gas 1.1.0 → 1.2.1

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
@@ -2,15 +2,24 @@
2
2
 
3
3
  Node-RED nodes for gas sensor chips — part of the [Periph](https://github.com/tuhde/Periph) library.
4
4
 
5
- > **Coming soon.** Nodes will be added as chips in this category are implemented.
6
-
7
5
  ## Install
8
6
 
7
+ Open Node-RED, go to **Manage Palette → Install** and search for `node-red-contrib-periph-gas`.
8
+
9
+ Or from the command line in your Node-RED user directory:
10
+
9
11
  ```sh
10
12
  npm install node-red-contrib-periph-gas
11
13
  ```
12
14
 
15
+ ## Nodes
16
+
17
+ | Node | Kind | Description |
18
+ |------|------|-------------|
19
+ | `ens160-device` | config | Bus configuration for an ENS160 |
20
+ | `periph-ens160` | input | Reads air quality (AQI, TVOC, eCO2) from an ENS160 digital multi-gas sensor. |
21
+
13
22
  ## Links
14
23
 
15
24
  - [GitHub](https://github.com/tuhde/Periph)
16
- - [All supported chips](https://github.com/tuhde/Periph#supported-chips)
25
+ - [periph JS driver](https://www.npmjs.com/package/periph)
@@ -35,7 +35,7 @@
35
35
  <script type="text/javascript">
36
36
  RED.nodes.registerType('periph-ens160', {
37
37
  category: 'Peripheral',
38
- color: '#a6bbcf',
38
+ color: '#C084FC',
39
39
  defaults: {
40
40
  name: { value: '' },
41
41
  device: { value: '', type: 'ens160-device', required: true }
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports = function(RED) {
4
- const { I2CTransport } = require('periph/src/transport/i2c');
4
+ const { I2CConnection } = require('periph/src/connection/i2c');
5
5
  const { ENS160Full } = require('periph/src/chips/gas/ens160');
6
6
 
7
7
  function ENS160DeviceNode(config) {
@@ -9,14 +9,14 @@ module.exports = function(RED) {
9
9
  const node = this;
10
10
  try {
11
11
  const addr = parseInt(config.addr) || 0x52;
12
- const transport = new I2CTransport(parseInt(config.bus), addr);
13
- node.driver = new ENS160Full(transport);
14
- node.transport = transport;
12
+ const connection = new I2CConnection(parseInt(config.bus), addr);
13
+ node.driver = new ENS160Full(connection);
14
+ node.connection = connection;
15
15
  } catch (e) {
16
16
  node.error('ENS160 init failed: ' + e.message);
17
17
  }
18
18
  node.on('close', function() {
19
- if (node.transport) node.transport.close();
19
+ if (node.connection) node.connection.close();
20
20
  });
21
21
  }
22
22
  RED.nodes.registerType('ens160-device', ENS160DeviceNode);
@@ -26,7 +26,7 @@ module.exports = function(RED) {
26
26
  const node = this;
27
27
  node.device = RED.nodes.getNode(config.device);
28
28
 
29
- node.on('input', function(msg, send, done) {
29
+ node.on('input', async function(msg, send, done) {
30
30
  if (!node.device || !node.device.driver) {
31
31
  node.error('No ENS160 device configured', msg);
32
32
  done();
@@ -34,7 +34,7 @@ module.exports = function(RED) {
34
34
  }
35
35
  try {
36
36
  const d = node.device.driver;
37
- const status = d.status();
37
+ const status = await d.status();
38
38
  if (status !== 0) {
39
39
  node.warn('ENS160 data not valid (status=' + status + ')');
40
40
  msg.payload = { status: status };
@@ -42,7 +42,7 @@ module.exports = function(RED) {
42
42
  done();
43
43
  return;
44
44
  }
45
- const data = d.readAirQuality();
45
+ const data = await d.readAirQuality();
46
46
  msg.payload = {
47
47
  aqi: data.aqi,
48
48
  tvocPpb: data.tvocPpb,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-periph-gas",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Node-RED nodes for gas sensor chips",
5
5
  "keywords": [
6
6
  "node-red",