Merge branch 'features' into beta

This commit is contained in:
Evgenii Abramov
2021-05-17 00:41:47 +03:00
9 changed files with 165 additions and 37 deletions

View File

@@ -1,3 +1,5 @@
const {logger} = global;
/* function for convert system values to Yandex (depends of capability or property type) */
function convertToYandexValue(val, actType) {
switch(actType) {
@@ -8,7 +10,7 @@ function convertToYandexValue(val, actType) {
const value = parseFloat(val);
return isNaN(value) ? 0.0 : value;
} catch(e) {
console.error(`Can't parse to float: ${val}`);
logger.log('error', {message: `Can't parse to float: ${val}`});
return 0.0;
}
}
@@ -82,7 +84,7 @@ class Device {
}
}
default: {
console.error(`Unsupported capability type: ${type}`)
logger.log('error', {message: `Unsupported capability type: ${type}`});
return undefined;
}
}
@@ -181,7 +183,7 @@ class Device {
message = `${value}`;
} catch(e) {
topic = false;
console.log(e);
logger.log('error', {message: `${e}`});
}
if (topic) {
@@ -211,7 +213,7 @@ class Device {
const value = this.getMappedValue(val, actType, false);
cp.state = {instance, value: convertToYandexValue(value, actType)};
} catch(e) {
console.error(e);
logger.log('error', {message: `${e}`});
}
}
}