@kronos-integration/service-influxdb 1.0.2 → 1.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/service-influxdb",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -0,0 +1,30 @@
1
+ import { Point } from "@influxdata/influxdb-client";
2
+ import { ReceiveEndpoint } from "@kronos-integration/endpoint";
3
+
4
+ export class PointEndpoint extends ReceiveEndpoint {
5
+ constructor(name, owner, options) {
6
+ super(name, owner, options);
7
+ }
8
+
9
+ get org() {
10
+ return this.owner.org;
11
+ }
12
+
13
+ get bucket() {
14
+ return this.owner.bucket;
15
+ }
16
+
17
+ get writeClient() {
18
+ return this.owner.client.getWriteApi(this.org, this.bucket, "ns");
19
+ }
20
+
21
+ async receive(value) {
22
+ const num = Number.parseFloat(value.toString());
23
+
24
+ console.log(num);
25
+
26
+ const point = new Point("power").floatField("ac", num);
27
+
28
+ this.writeClient.writePoint(point);
29
+ }
30
+ }
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  prepareAttributesDefinitions,
3
3
  url_attribute,
4
- token_attribute
4
+ token_attribute,
5
+ default_attribute
5
6
  } from "pacc";
6
7
  import { Service } from "@kronos-integration/service";
7
8
  import { InfluxDB } from "@influxdata/influxdb-client";
@@ -32,6 +33,14 @@ export class ServiceInfluxdb extends Service {
32
33
  token: {
33
34
  ...token_attribute,
34
35
  env: "INFLUXDB_TOKEN"
36
+ },
37
+ org: {
38
+ ...default_attribute,
39
+ env: "INFLUXDB_ORG"
40
+ },
41
+ bucket: {
42
+ ...default_attribute,
43
+ env: "INFLUXDB_BUCKET"
35
44
  }
36
45
  },
37
46
  Service.attributes
@@ -0,0 +1,8 @@
1
+ export class PointEndpoint extends ReceiveEndpoint {
2
+ constructor(name: any, owner: any, options: any);
3
+ get org(): any;
4
+ get bucket(): any;
5
+ get writeClient(): any;
6
+ receive(value: any): Promise<void>;
7
+ }
8
+ import { ReceiveEndpoint } from "@kronos-integration/endpoint";