Skip to content

Commit 067a054

Browse files
authored
[items] Fix sendCommandIfDifferent fails for Dimmer/Number Items with string commands (#421)
Fixes #410. Signed-off-by: Florian Hotze <[email protected]>
1 parent e4787cc commit 067a054

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

Diff for: src/items/items.js

+7
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,13 @@ class Item {
261261
}
262262
}
263263

264+
// value is number as string and current state is numeric and both are equal
265+
if (typeof value === 'string' && !isNaN(value) && this.numericState !== null) {
266+
if (parseFloat(value) === this.numericState) {
267+
return false;
268+
}
269+
}
270+
264271
// stringified value and string state are equal
265272
value = _toOpenhabPrimitiveType(value);
266273
if (value.toString() === this.state) {

Diff for: types/items/items.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

Diff for: types/rules/operation-builder.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type Item = {
3333
sendCommandIfDifferent(value: any): boolean;
3434
sendIncreaseCommand(value: any): boolean;
3535
sendDecreaseCommand(value: any): boolean;
36-
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF"; /** @private */
36+
getToggleState(): "PAUSE" | "PLAY" | "OPEN" | "CLOSED" | "ON" | "OFF";
3737
sendToggleCommand(): void;
3838
postToggleUpdate(): void;
3939
postUpdate(value: any): void;

Diff for: types/rules/operation-builder.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

0 commit comments

Comments
 (0)