Skip to content

Commit

Permalink
make sure number states are filled with number
Browse files Browse the repository at this point in the history
trying to fix #545
  • Loading branch information
Garfonso committed Nov 20, 2024
1 parent c3af6e1 commit 529f9a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/entities/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ function processCommon(name, room, func, obj, entityType, entity_id) {
type: getEntityType(entityType, entity_id, obj),
room: room,
func: func,
ids: [obj._id]
ids: [obj._id],
stateType: obj.common.type
}
};

Expand Down
8 changes: 6 additions & 2 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ class WebServer {
} else if (data.service === 'volume_set') {
this.log.debug('volume_set ' + id);

this.adapter.setForeignState(id, data.service_data.value, false, {user}, () =>
this.adapter.setForeignState(id, Number(data.service_data.value), false, {user}, () =>
this._sendResponse(ws, data.id));
} else if (data.service === 'trigger' || data.service === 'turn_on' || data.service === 'unlock' || data.service === 'press') {
this.log.debug(`${data.service} ${id}`);
Expand All @@ -576,7 +576,7 @@ class WebServer {
if (entity.context.ATTRIBUTES) {
const attr = entity.context.ATTRIBUTES.find(attr => attr.attribute === 'temperature');
if (attr) {
return this.adapter.setForeignState(attr.setId, data.service_data.temperature, false, {user}, () =>
return this.adapter.setForeignState(attr.setId, Number(data.service_data.temperature), false, {user}, () =>
this._sendResponse(ws, data.id));
}
}
Expand All @@ -586,6 +586,7 @@ class WebServer {
} else if (data.service === 'set_operation_mode') {
this.log.debug(`set_operation_mode ${data.service_data.operation_mode}`);

//TODO: just sending false here probably is wrong. The call is supported only be Waterheater entity. So... not really used, right now?
this.adapter.setForeignState(id, false, false, {user}, () =>
this._sendResponse(ws, data.id));
} else if (data.service === 'set_page') {
Expand Down Expand Up @@ -623,6 +624,9 @@ class WebServer {
val = data.service_data[data.service.substring(4)]; //fallback if undefined.
}
}
if (entity.context.stateType === 'number') {
val = Number(val);
}

this.adapter.setForeignState(id, val, false, {user}, () =>
this._sendResponse(ws, data.id));
Expand Down

0 comments on commit 529f9a4

Please sign in to comment.