* add another type conversion
This commit is contained in:
+1
-1
@@ -156,7 +156,7 @@ function HASS(options, log) {
|
|||||||
log.error(`Invalid answer: ${msg}`);
|
log.error(`Invalid answer: ${msg}`);
|
||||||
} else {
|
} else {
|
||||||
if (response.type === 'result' && requests[response.id]) {
|
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') {
|
if (typeof requests[response.id].cb === 'function') {
|
||||||
requests[response.id].cb(!response.success, response.result);
|
requests[response.id].cb(!response.success, response.result);
|
||||||
delete requests[response.id];
|
delete requests[response.id];
|
||||||
|
|||||||
@@ -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)}`)
|
adapter.log.debug(`Found Entity state ${obj._id}: ${JSON.stringify(obj.common)} / ${JSON.stringify(obj.native)}`)
|
||||||
objs.push(obj);
|
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) {
|
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)}`)
|
adapter.log.debug(`Found Entity attribute ${obj._id}: ${JSON.stringify(obj.common)} / ${JSON.stringify(obj.native)}`)
|
||||||
|
|
||||||
objs.push(obj);
|
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];
|
let val = entity.attributes[attr];
|
||||||
if ((typeof val === 'object' && val !== null) || Array.isArray(val)) {
|
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});
|
adapter.setForeignState(id + attr, {val, ack: true, lc, ts});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user