From 84b5a4520fb45be2265406efb911f1c0bc25c552 Mon Sep 17 00:00:00 2001 From: virtualmarc Date: Thu, 4 Jan 2024 22:17:42 +0100 Subject: [PATCH] fixed rssi --- README.md | 4 ++++ build/main.js | 16 +++++++++++++--- io-package.json | 6 +++++- package-lock.json | 4 ++-- package.json | 2 +- src/main.ts | 13 ++++++++++++- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 089f0b4..e527340 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,10 @@ Get sensor data from the Airthings Cloud (via Airthings Hub). * (virtualmarc) hopefully fixed interval +### 1.1.2 + +* (virtualmarc) fixed rssi + ## License MIT License diff --git a/build/main.js b/build/main.js index da0a705..7a00bc6 100644 --- a/build/main.js +++ b/build/main.js @@ -30,7 +30,8 @@ const EXCLUDED_TYPES = [ const EXCLUDED_SAMPLES = [ 'time', 'battery', - 'relayDeviceType' + 'relayDeviceType', + 'rssi' ]; class AirthingsCloud extends utils.Adapter { constructor(options = {}) { @@ -350,6 +351,15 @@ class AirthingsCloud extends utils.Adapter { from: this.namespace }, true); } + if (data.rssi) { + yield this.setStateAsync(`${deviceId}.rssi`, { + val: data.rssi, + ack: true, + ts, + lc: ts, + from: this.namespace + }, true); + } for (const sampleKey in data) { if (!EXCLUDED_SAMPLES.includes(sampleKey)) { yield this.setObjectNotExistsAsync(`${deviceId}.samples.${sampleKey}`, { @@ -393,7 +403,7 @@ class AirthingsCloud extends utils.Adapter { } yield this.syncDevices(); yield this.updateSamples(); - setInterval(this.updateTimer, this.config.update_interval * 60000); + this.updateTimerId = this.setInterval(() => this.updateTimer(), this.config.update_interval * 60000); }); } /** @@ -402,7 +412,7 @@ class AirthingsCloud extends utils.Adapter { onUnload(callback) { try { if (this.updateTimerId) { - clearInterval(this.updateTimerId); + this.clearInterval(this.updateTimerId); } callback(); } diff --git a/io-package.json b/io-package.json index d8de22b..73307f8 100644 --- a/io-package.json +++ b/io-package.json @@ -1,7 +1,7 @@ { "common": { "name": "airthings-cloud", - "version": "1.1.1", + "version": "1.1.2", "news": { "1.0.0": { "en": "initial release", @@ -14,6 +14,10 @@ "1.1.1": { "en": "hopefully fixed interval", "de": "Hoffentlich das Intervall korrigiert" + }, + "1.1.2": { + "en": "fixed rssi", + "de": "Signalstärke korrigiert" } }, "title": "Airthings Cloud", diff --git a/package-lock.json b/package-lock.json index d897f8a..c1401f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "iobroker.airthings-cloud", - "version": "1.1.0", + "version": "1.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "iobroker.airthings-cloud", - "version": "1.1.0", + "version": "1.1.2", "license": "MIT", "dependencies": { "@iobroker/adapter-core": "^3.0.4" diff --git a/package.json b/package.json index 07e2731..a9fdb22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iobroker.airthings-cloud", - "version": "1.1.1", + "version": "1.1.2", "description": "Get sensor data from the Airthings Cloud.", "author": { "name": "virtualmarc", diff --git a/src/main.ts b/src/main.ts index 68e1cde..46e63f8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -24,7 +24,8 @@ const EXCLUDED_TYPES: string[] = [ const EXCLUDED_SAMPLES: string[] = [ 'time', 'battery', - 'relayDeviceType' + 'relayDeviceType', + 'rssi' ]; // Load your modules here, e.g.: @@ -397,6 +398,16 @@ class AirthingsCloud extends utils.Adapter { }, true); } + if (data.rssi) { + await this.setStateAsync(`${deviceId}.rssi`, { + val: data.rssi, + ack: true, + ts, + lc: ts, + from: this.namespace + }, true); + } + for (const sampleKey in data) { if (!EXCLUDED_SAMPLES.includes(sampleKey)) { await this.setObjectNotExistsAsync(`${deviceId}.samples.${sampleKey}`, {