Skip to content

Commit

Permalink
if unit of measurement set, keep number. too.
Browse files Browse the repository at this point in the history
frontend does the same.
  • Loading branch information
Garfonso committed Dec 9, 2023
1 parent cb3811c commit 7338e65
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/converters/genericConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ exports.iobState2EntityState = function (entity, val, attribute) {
return val ? 'on' : 'off';
} else if (type === 'binary_sensor') {
return val ? 'on' : 'off';
} else if (typeof val === 'number' && entity.attributes && numericDeviceClassesIob.includes(entity.attributes.device_class)) {
} else if (typeof val === 'number' && entity.attributes && (numericDeviceClassesIob.includes(entity.attributes.device_class) || entity.attributes.unit_of_measurement)) {
return val; //do not convert timestamps or values that have a unit of measurement..
} else if (typeof val === 'number' && entity.attributes && ['date'].includes(entity.attributes.device_class)) {
const dateStr = new Date(val).toDateString(); //convert to date string
Expand Down

0 comments on commit 7338e65

Please sign in to comment.