* add another type conversion

This commit is contained in:
Ingo Fischer
2021-09-03 11:51:07 +02:00
parent f0925ea83b
commit 338c36de70
2 changed files with 16 additions and 4 deletions
+1 -1
View File
@@ -156,7 +156,7 @@ function HASS(options, log) {
log.error(`Invalid answer: ${msg}`);
} else {
if (response.type === 'result' && requests[response.id]) {
log.debug(`got answer for ${requests[response.id].type} success = ${response.success}, result = ${response.result}`);
log.debug(`got answer for ${requests[response.id].type} success = ${response.success}, result = ${JSON.stringify(response.result)}`);
if (typeof requests[response.id].cb === 'function') {
requests[response.id].cb(!response.success, response.result);
delete requests[response.id];
+15 -3
View File
@@ -244,7 +244,13 @@ function parseStates(entities, services, callback) {
}
adapter.log.debug(`Found Entity state ${obj._id}: ${JSON.stringify(obj.common)} / ${JSON.stringify(obj.native)}`)
objs.push(obj);
states.push({id: obj._id, lc: lc, ts: ts, val: entity.state, ack: true})
let val = entity.state;
if ((typeof val === 'object' && val !== null) || Array.isArray(val)) {
val = JSON.stringify(val);
}
states.push({id: obj._id, lc, ts, val, ack: true})
}
if (entity.attributes) {
@@ -288,7 +294,13 @@ function parseStates(entities, services, callback) {
adapter.log.debug(`Found Entity attribute ${obj._id}: ${JSON.stringify(obj.common)} / ${JSON.stringify(obj.native)}`)
objs.push(obj);
states.push({id: obj._id, lc: lc, ts: ts, val: entity.attributes[attr], ack: true});
let val = entity.attributes[attr];
if ((typeof val === 'object' && val !== null) || Array.isArray(val)) {
val = JSON.stringify(val);
}
states.push({id: obj._id, lc, ts, val, ack: true});
}
}
}
@@ -355,7 +367,7 @@ function main() {
}
let val = entity.attributes[attr];
if ((typeof val === 'object' && val !== null) || Array.isArray(val)) {
val = JSON.stringify(entity.attributes[attr]);
val = JSON.stringify(val);
}
adapter.setForeignState(id + attr, {val, ack: true, lc, ts});
}