Falls es noch jemand anderes braucht, ich habe mir ein Script erstellt:
// returns device id of state, device or channel-id
function getDeviceId(id) {
return id.match(/(.+[a-zA-Z0-9]{24})/g);
}
// check if id has influx enabled
function isInfluxEnabled(fullList, id, checkAliasToo) {
if(fullList[id] != undefined && fullList[id].enabled && (checkAliasToo == null || checkAliasToo == fullList[id].aliasId)) {
console.log("angeschaltet: " + getObject(getDeviceId(id)).common.name);
return true;
}
// default
return false;
}
// enable influxdb
function enableInflux(id, alias) {
sendTo('influxdb.0', 'enableHistory', {
id: id,
options: {
changesOnly: true,
debounceTime: 0,
blockTime: 0,
changesRelogInterval: 0,
retention: 31536000,
maxLength: 3,
changesMinDelta: 0,
aliasId: alias
}
}, function (result) {
if (result.error) {
console.log(result.error);
}
if (result.success) {
// successfully enabled
}
});
}
// disable infludb
function disableInflux(id) {
sendTo('influxdb.0', 'disableHistory', {
id: id,
}, function (result) {
if (result.error) {
console.log(result.error);
}
if (result.success) {
// successfully disabled
}
});
}
const deviceBase = "hmip.*.devices.*"; // hmip.0.devices.3014F711A000201D89AC42E3
const dataPoints = {".channels.1.valveActualTemperature" : 1, ".channels.1.temperatureOffset" : 0, ".channels.0.lowBat" : 0}; // 0=disable; 1=enable
// get full list of enabled influx datapoints
sendTo('influxdb.0', 'getEnabledDPs', {}, function (fullList) {
//console.log(fullList);
// loop through all datapoints
for (const [dataPoint, enable] of Object.entries(dataPoints)) {
// get all devices
var devices = $('state[id=' +deviceBase+dataPoint+']');
console.log("Number of Devices found: " + devices.length);
// loop through all devices
devices.each(function (id, i){
// alias
var aliasId = getObject(getDeviceId(id)).common.name + dataPoint;
if( enable == 1) {
// enable influx
if( !isInfluxEnabled(fullList, id, aliasId)) {
console.log("ENABLE: " + aliasId);
enableInflux(id, aliasId)
}
} else {
// disable influx
console.log("DISABLE: " + aliasId);
disableInflux(id);
}
}); // devices
} // datapoints
});