Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/rg15 #51

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 102 additions & 41 deletions lib/decoding/sensebox_home.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
"use strict";

Check failure on line 1 in lib/decoding/sensebox_home.js

View workflow job for this annotation

GitHub Actions / Lint code

Strings must use singlequote

/**
* This decoding profile decodes the measurements for the sensors of the
Expand All @@ -8,136 +8,197 @@
* @license MIT
*/

const { bytesToInt, findSensorIds } = require('./helpers');
const { bytesToInt, findSensorIds } = require("./helpers");

Check failure on line 11 in lib/decoding/sensebox_home.js

View workflow job for this annotation

GitHub Actions / Lint code

Strings must use singlequote

// alternative titles recognized for the sensors
const sensorMatchings = {
temperature: {
title: ['temperatur', 'temperature'],
title: ["temperatur", "temperature"],

Check failure on line 16 in lib/decoding/sensebox_home.js

View workflow job for this annotation

GitHub Actions / Lint code

Strings must use singlequote

Check failure on line 16 in lib/decoding/sensebox_home.js

View workflow job for this annotation

GitHub Actions / Lint code

Strings must use singlequote
},
humidity: {
title: ['rel. luftfeuchte', 'luftfeuchtigkeit', 'humidity']
title: ["rel. luftfeuchte", "luftfeuchtigkeit", "humidity"],

Check failure on line 19 in lib/decoding/sensebox_home.js

View workflow job for this annotation

GitHub Actions / Lint code

Strings must use singlequote

Check failure on line 19 in lib/decoding/sensebox_home.js

View workflow job for this annotation

GitHub Actions / Lint code

Strings must use singlequote

Check failure on line 19 in lib/decoding/sensebox_home.js

View workflow job for this annotation

GitHub Actions / Lint code

Strings must use singlequote
},
pressure: {
title: ['luftdruck', 'druck', 'pressure', 'air pressure']
title: ["luftdruck", "druck", "pressure", "air pressure"],

Check failure on line 22 in lib/decoding/sensebox_home.js

View workflow job for this annotation

GitHub Actions / Lint code

Strings must use singlequote

Check failure on line 22 in lib/decoding/sensebox_home.js

View workflow job for this annotation

GitHub Actions / Lint code

Strings must use singlequote

Check failure on line 22 in lib/decoding/sensebox_home.js

View workflow job for this annotation

GitHub Actions / Lint code

Strings must use singlequote
},
lightintensity: {
title: ['licht', 'helligkeit', 'beleuchtungsstärke', 'einstrahlung', 'light', 'light intensity']
title: [
"licht",
"helligkeit",
"beleuchtungsstärke",
"einstrahlung",
"light",
"light intensity",
],
},
uvlight: {
title: ['uv', 'uv-a', 'uv-intensität', 'uv-intensity']
title: ["uv", "uv-a", "uv-intensität", "uv-intensity"],
},
pm10: {
title: ['pm10', 'pm 10']
title: ["pm10", "pm 10"],
},
pm25: {
title: ['pm2.5', 'pm 2.5']
title: ["pm2.5", "pm 2.5"],
},
soiltemperature: {
title: ['soiltemperature', 'soil temperature', 'temperature soil', 'bodentemperatur', 'boden temperatur', 'temperatur boden']
title: [
"soiltemperature",
"soil temperature",
"temperature soil",
"bodentemperatur",
"boden temperatur",
"temperatur boden",
],
},
soilmoisture: {
title: ['soilmoisture', 'soil moisture', 'moisture soil', 'bodenfeuchte', 'boden feuchte', 'feuchte boden', 'bodenfeuchtigkeit', 'boden feuchtigkeit', 'feuchtigkeit boden']
title: [
"soilmoisture",
"soil moisture",
"moisture soil",
"bodenfeuchte",
"boden feuchte",
"feuchte boden",
"bodenfeuchtigkeit",
"boden feuchtigkeit",
"feuchtigkeit boden",
],
},
soundlevel: {
title: ['soundlevel', 'sound level', 'lautstärke', 'schallpegel', 'schall pegel']
title: [
"soundlevel",
"sound level",
"lautstärke",
"schallpegel",
"schall pegel",
],
},
bmetemperature: {
title: ['lufttemperatur']
title: ["lufttemperatur"],
},
bmehumidity: {
title: ['luftfeuchte']
title: ["luftfeuchte"],
},
bmepressure: {
title: ['atm. luftdruck']
title: ["atm. luftdruck"],
},
bmevoc: {
title: ['VOC']
title: ["VOC"],
},
windspeed: {
title: ['windgeschwindigkeit', 'wind weschwindigkeit', 'windspeed', 'wind speed']
title: [
"windgeschwindigkeit",
"wind weschwindigkeit",
"windspeed",
"wind speed",
],
},
co2: {
title: ['co2', 'CO₂', 'co 2']
}
title: ["co2", "CO₂", "co 2"],
},
rg15_total: {
title: ["Niederschlag (gesamt)"],
},
rg15_event: {
title: ["Niederschlag (letztes Ereignis)"],
},
rg15_intensity: {
title: ["Regenintensität"],
},
};

const transformers = {
temperature: {
bytes: 2,
transformer: bytes => parseFloat((bytesToInt(bytes) / 771 - 18).toFixed(1))
transformer: (bytes) =>
parseFloat((bytesToInt(bytes) / 771 - 18).toFixed(1)),
},
humidity: {
bytes: 2,
transformer: bytes => parseFloat((bytesToInt(bytes) / 1e2).toFixed(1))
transformer: (bytes) => parseFloat((bytesToInt(bytes) / 1e2).toFixed(1)),
},
pressure: {
bytes: 2,
transformer: bytes => parseFloat((bytesToInt(bytes) / 81.9187 + 300).toFixed(1))
transformer: (bytes) =>
parseFloat((bytesToInt(bytes) / 81.9187 + 300).toFixed(1)),
},
lightintensity: {
bytes: 3,
transformer (bytes) {
transformer(bytes) {
const [mod, ...times] = bytes;

return bytesToInt(times) * 255 + bytesToInt([mod]);
}
},
},
uvlight: {
bytes: 3,
transformer (bytes) {
transformer(bytes) {
const [mod, ...times] = bytes;

return bytesToInt(times) * 255 + bytesToInt([mod]);
}
},
},
pm10: {
bytes: 2,
transformer: bytes => parseFloat((bytesToInt(bytes) / 10).toFixed(1))
transformer: (bytes) => parseFloat((bytesToInt(bytes) / 10).toFixed(1)),
},
pm25: {
bytes: 2,
transformer: bytes => parseFloat((bytesToInt(bytes) / 10).toFixed(1))
transformer: (bytes) => parseFloat((bytesToInt(bytes) / 10).toFixed(1)),
},
soiltemperature: {
bytes: 2,
transformer: bytes => parseFloat((bytesToInt(bytes) / 771 - 18).toFixed(1))
transformer: (bytes) =>
parseFloat((bytesToInt(bytes) / 771 - 18).toFixed(1)),
},
soilmoisture: {
bytes: 2,
transformer: bytes => parseFloat((bytesToInt(bytes) / 1e2).toFixed(1))
transformer: (bytes) => parseFloat((bytesToInt(bytes) / 1e2).toFixed(1)),
},
soundlevel: {
bytes: 2,
transformer: bytes => parseFloat((bytesToInt(bytes) / 10).toFixed(1))
transformer: (bytes) => parseFloat((bytesToInt(bytes) / 10).toFixed(1)),
},
bmetemperature: {
bytes: 2,
transformer: bytes => parseFloat((bytesToInt(bytes) / 771 - 18).toFixed(1))
transformer: (bytes) =>
parseFloat((bytesToInt(bytes) / 771 - 18).toFixed(1)),
},
bmehumidity: {
bytes: 2,
transformer: bytes => parseFloat((bytesToInt(bytes) / 1e2).toFixed(1))
transformer: (bytes) => parseFloat((bytesToInt(bytes) / 1e2).toFixed(1)),
},
bmepressure: {
bytes: 2,
transformer: bytes => parseFloat((bytesToInt(bytes) / 81.9187 + 300).toFixed(1))
transformer: (bytes) =>
parseFloat((bytesToInt(bytes) / 81.9187 + 300).toFixed(1)),
},
bmevoc: {
bytes: 3,
transformer (bytes) {
transformer(bytes) {
const [mod, ...times] = bytes;

return bytesToInt(times) * 255 + bytesToInt([mod]);
}
},
},
windspeed: {
bytes: 2,
transformer: bytes => parseFloat((bytesToInt(bytes) / 10).toFixed(1))
transformer: (bytes) => parseFloat((bytesToInt(bytes) / 10).toFixed(1)),
},
co2: {
bytes: 2,
transformer: bytes => bytesToInt(bytes)
transformer: (bytes) => bytesToInt(bytes),
},
rg15_total: {
bytes: 2,
transformer: (bytes) => parseFloat(bytesToInt(bytes) / 10).toFixed(1),
},
rg15_event: {
bytes: 2,
transformer: (bytes) => parseFloat(bytesToInt(bytes) / 10).toFixed(1),
},
rg15_intensity: {
bytes: 2,
transformer: (bytes) => parseFloat(bytesToInt(bytes) / 10).toFixed(1),
},
};

Expand All @@ -147,7 +208,7 @@
* @param {Box} box - The box to retrieve sensorIds from
* @return {Array} A bufferTransformer for the box
*/
const createBufferTransformer = function createBufferTransformer (box) {
const createBufferTransformer = function createBufferTransformer(box) {
const sensorMap = findSensorIds(box.sensors, sensorMatchings);

const transformer = [];
Expand All @@ -157,7 +218,7 @@
transformer.push({
sensorId: sensorMap[key],
bytes: transformers[key].bytes,
transformer: transformers[key].transformer
transformer: transformers[key].transformer,
});
}
}
Expand All @@ -166,5 +227,5 @@
};

module.exports = {
createBufferTransformer
createBufferTransformer,
};
Loading