From 9bf225a292f23f10f4721b9df05d2c43067e9041 Mon Sep 17 00:00:00 2001 From: ka-vaNu Date: Thu, 26 Dec 2024 16:28:05 +0100 Subject: [PATCH] getDatapoints in tools verschoben --- lib/tools.js | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/tools.js b/lib/tools.js index 8f51fe0..6c63f77 100644 --- a/lib/tools.js +++ b/lib/tools.js @@ -2,6 +2,13 @@ const axios = require('axios'); const dot = require('dot-object'); +const gatebox = require('./gatebox'); +const shutterbox = require('./shutterbox'); +const switchbox = require('./switchbox'); +const tempsensor = require('./tempsensor'); +const multisensor = require('./multisensor'); +const saunabox = require('./saunabox'); +const tvlift = require('./tvlift'); let iob = {}; @@ -57,6 +64,33 @@ function findVal(obj, prop) { return null; } +/** + * + * @param type Type of device to get Datapoints from + * @returns array of datapoints + */ +function getDatapoints(type) { + switch (type) { + case 'gatebox': + return gatebox.datapoints; + case 'shutterbox': + return shutterbox.datapoints; + case 'tvlift': + return tvlift.datapoints; + case 'switchbox': + return switchbox.datapoints; + case 'tempsensor': + return tempsensor.datapoints; + case 'multisensor': + return multisensor.datapoints; + case 'saunabox': + return saunabox.datapoints; + default: + break; + } + return false; +} + /** * * @param device object of the device to request data @@ -186,7 +220,7 @@ async function initCommon(name, apiType) { if (iob.extLog) { iob.log.info(`initCommon: name: ${name} type: ${apiType}`); } - iob.datapoints[name] = iob.getDatapoints(apiType); + iob.datapoints[name] = getDatapoints(apiType); if (iob.extLog) { iob.log.info(`initCommon: datapoints: ${JSON.stringify(iob.datapoints[name])}`); } @@ -200,6 +234,7 @@ module.exports = { setIob, initCommon, getBleboxData, + getDatapoints, simpleObjectUrlGetter, initIobStates, setIobStates,