Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve log messages in ItemStateConditionHandler #3535

Merged
merged 1 commit into from
Apr 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,13 @@ public boolean isSatisfied(Map<String, Object> inputs) {
String state = (String) module.getConfiguration().get(STATE);
String operator = (String) module.getConfiguration().get(OPERATOR);
if (operator == null || state == null || itemName == null) {
logger.error("Module is not well configured: itemName={} operator={} state = {}", itemName, operator,
state);
logger.error("Module is not well configured: itemName={} operator={} state = {} for rule {}", itemName,
operator, state, ruleUID);
return false;
}
try {
logger.debug("ItemStateCondition '{}' checking if {} {} {}", module.getId(), itemName, operator, state);
logger.debug("ItemStateCondition '{}' checking if {} {} {} for rule {}", module.getId(), itemName, operator,
state, ruleUID);
switch (operator) {
case "=":
return equalsToItemState(itemName, state);
Expand All @@ -149,7 +150,7 @@ public boolean isSatisfied(Map<String, Object> inputs) {
return greaterThanOrEqualsToItemState(itemName, state);
}
} catch (ItemNotFoundException e) {
logger.error("Item with name {} not found in ItemRegistry.", itemName);
logger.error("Item with name {} not found in ItemRegistry for condition of rule {}.", itemName, ruleUID);
}
return false;
}
Expand All @@ -170,8 +171,8 @@ private boolean lessThanOrEqualsToItemState(String itemName, String state) throw
// state, but warn the user
if (!Units.ONE.equals(qtState.getUnit())) {
logger.warn(
"Received a QuantityType state '{}' with unit for item {}, but the condition is defined as a plain number without unit ({}), please consider adding a unit to the condition.",
qtState, itemName, state);
"Received a QuantityType state '{}' with unit for item {}, but the condition is defined as a plain number without unit ({}), please consider adding a unit to the condition for rule {}.",
qtState, itemName, state, ruleUID);
}
return qtState.compareTo(
new QuantityType<>(((DecimalType) compareState).toBigDecimal(), qtState.getUnit())) <= 0;
Expand Down Expand Up @@ -209,8 +210,8 @@ private boolean greaterThanOrEqualsToItemState(String itemName, String state) th
// state, but warn the user
if (!Units.ONE.equals(qtState.getUnit())) {
logger.warn(
"Received a QuantityType state '{}' with unit for item {}, but the condition is defined as a plain number without unit ({}), please consider adding a unit to the condition.",
qtState, itemName, state);
"Received a QuantityType state '{}' with unit for item {}, but the condition is defined as a plain number without unit ({}), please consider adding a unit to the condition for rule {}.",
qtState, itemName, state, ruleUID);
}
return qtState.compareTo(
new QuantityType<>(((DecimalType) compareState).toBigDecimal(), qtState.getUnit())) >= 0;
Expand Down Expand Up @@ -245,8 +246,8 @@ private boolean equalsToItemState(String itemName, String state) throws ItemNotF
} else {
// log a warning if the unit of the state differs from ONE
logger.warn(
"Received a QuantityType state '{}' with unit for item {}, but the condition is defined as a plain number without unit ({}), comparison will fail unless a unit is added to the condition.",
itemState, itemName, state);
"Received a QuantityType state '{}' with unit for item {}, but the condition is defined as a plain number without unit ({}), comparison will fail unless a unit is added to the condition for rule {}.",
itemState, itemName, state, ruleUID);
return false;
}
}
Expand Down