Skip to content

Commit

Permalink
Add some debug logging
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 committed Sep 16, 2024
1 parent cb67696 commit 7d007ef
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/items/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,21 @@ class Item {
// value and current state both are Quantity and value is less than or equal current state
if (_isQuantity(value) && this.quantityState !== null) {
if (value.lessThanOrEqual(this.quantityState)) {
log.debug('sendIncreaseCommand: Ignoring command {} for Item {} with state {}', value, this.name, this.state);
return false;
}
}

// value and current state are both numeric and value is less than or equal current state
if (typeof value === 'number' && this.numericState !== null) {
if (value <= this.numericState) {
log.debug('sendIncreaseCommand: Ignoring command {} for Item {} with state {}', value, this.name, this.state);
return false;
}
}

// else send the command
log.debug('sendIncreaseCommand: Sending command {} to Item {} with state {}', value, this.name, this.state);
this.sendCommand(value);
return true;
}
Expand All @@ -308,18 +311,21 @@ class Item {
// value and current state both are Quantity and value is greater than or equal current state
if (_isQuantity(value) && this.quantityState !== null) {
if (value.greaterThanOrEqual(this.quantityState)) {
log.debug('sendDecreaseCommand: Ignoring command {} for Item {} with state {}', value, this.name, this.state);
return false;
}
}

// value and current state are both numeric and value is greater than or equal current state
if (typeof value === 'number' && this.numericState !== null) {
if (value >= this.numericState) {
log.debug('sendDecreaseCommand: Ignoring command {} for Item {} with state {}', value, this.name, this.state);
return false;
}
}

// else send the command
log.debug('sendDecreaseCommand: Sending command {} to Item {} with state {}', value, this.name, this.state);
this.sendCommand(value);
return true;
}
Expand Down

0 comments on commit 7d007ef

Please sign in to comment.