diff --git a/main.js b/main.js index aa8c9f6..ae05df2 100644 --- a/main.js +++ b/main.js @@ -630,18 +630,24 @@ function getStorageRealtimeData(id) { adapter.log.debug('Response to ' + requestType + ip + baseurl + 'GetStorageRealtimeData.cgi?Scope=Device&DeviceId=' + id + ': ' + JSON.stringify(response.data)); if (response.status == 200) { try { - const data = response.data; + let data = response.data; if ('Body' in data) { - if (data.Body.Data === null) { + // check if object is existing and not empty + if (data.Body.Data === null || Object.entries(data.Body.Data).length === 0) { adapter.log.debug('Storage object is not supported: ' + JSON.stringify(data)); return; } + data = data.Body.Data; if (!isObjectsCreated) { - devObjects.createStorageObjects(adapter, id, response.data.Body.Data); + devObjects.createStorageObjects(adapter, id, data); + } + if (Object.prototype.hasOwnProperty.call(data, 'Controller')) { + fillData(adapter, data.Controller, 'storage.' + id); + } + if (Object.prototype.hasOwnProperty.call(data, 'Modules')) { + fillData(adapter, data.Modules, 'storage.' + id + '.module'); } - fillData(adapter, response.data.Body.Data.Controller, 'storage.' + id); - fillData(adapter, response.data.Body.Data.Modules, 'storage.' + id + '.module'); } else { adapter.log.warn(data.Head.Status.Reason + ' storage: ' + id); } @@ -1165,6 +1171,11 @@ function GetArchiveValue(adapter, data, prefix, id, key) { // this function should not be called directly, better is to call through fillData function as this includes a timeout handling function fillDataObject(adapt, apiObject, prefix = '') { + // check if the given object is existing and not empty + if (apiObject === null || Object.entries(apiObject).length === 0) { + adapter.log.debug('fillDataObject: Object is empty!'); + return; + } if (prefix != '' && prefix.endsWith('.') == false) { // make sure the path ends with a . if set prefix = prefix + '.'; @@ -1226,6 +1237,11 @@ function fillDataObject(adapt, apiObject, prefix = '') { // function to be called to fill the data function fillData(adapter, apiObject, prefix = '') { + // check if object is existing and not empty + if (apiObject === null || Object.entries(apiObject).length === 0) { + adapter.log.debug('fillData: Object is null or empty!'); + return; + } setTimeout( function (adapt, data, pref) { fillDataObject(adapt, data, pref); diff --git a/package-lock.json b/package-lock.json index 292fb48..12ca5e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2544,8 +2544,8 @@ } }, "node_modules/google-gax": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/google-gax/-/google-gax-3.6.1.tgz", + "version": "4.3.8", + "resolved": "https://registry.npmjs.org/google-gax/-/google-gax-4.3.8.tgz", "integrity": "sha512-g/lcUjGcB6DSw2HxgEmCDOrI/CByOwqRvsuUvNalHUK2iPPPlmAIpbMbl62u0YufGMr8zgE3JL7th6dCb1Ry+w==", "dev": true, "dependencies": {