Skip to content

Commit

Permalink
fixed rssi
Browse files Browse the repository at this point in the history
  • Loading branch information
virtualmarc committed Jan 4, 2024
1 parent 0262f4c commit 84b5a45
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions build/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const EXCLUDED_TYPES = [
const EXCLUDED_SAMPLES = [
'time',
'battery',
'relayDeviceType'
'relayDeviceType',
'rssi'
];
class AirthingsCloud extends utils.Adapter {
constructor(options = {}) {
Expand Down Expand Up @@ -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}`, {
Expand Down Expand Up @@ -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);
});
}
/**
Expand All @@ -402,7 +412,7 @@ class AirthingsCloud extends utils.Adapter {
onUnload(callback) {
try {
if (this.updateTimerId) {
clearInterval(this.updateTimerId);
this.clearInterval(this.updateTimerId);
}
callback();
}
Expand Down
6 changes: 5 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"common": {
"name": "airthings-cloud",
"version": "1.1.1",
"version": "1.1.2",
"news": {
"1.0.0": {
"en": "initial release",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 12 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const EXCLUDED_TYPES: string[] = [
const EXCLUDED_SAMPLES: string[] = [
'time',
'battery',
'relayDeviceType'
'relayDeviceType',
'rssi'
];

// Load your modules here, e.g.:
Expand Down Expand Up @@ -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}`, {
Expand Down

0 comments on commit 84b5a45

Please sign in to comment.