Skip to content

Commit

Permalink
getDatapoints in tools verschoben
Browse files Browse the repository at this point in the history
  • Loading branch information
ka-vaNu committed Dec 26, 2024
1 parent 4504f03 commit 9bf225a
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion lib/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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])}`);
}
Expand All @@ -200,6 +234,7 @@ module.exports = {
setIob,
initCommon,
getBleboxData,
getDatapoints,
simpleObjectUrlGetter,
initIobStates,
setIobStates,
Expand Down

0 comments on commit 9bf225a

Please sign in to comment.