diff --git a/bundles/org.smarthomej.transform.basicprofiles/README.md b/bundles/org.smarthomej.transform.basicprofiles/README.md index 3982ac5438..6da4462631 100644 --- a/bundles/org.smarthomej.transform.basicprofiles/README.md +++ b/bundles/org.smarthomej.transform.basicprofiles/README.md @@ -192,7 +192,7 @@ Use case: Ignore values from a binding unless some other item(s) have a specific | Configuration Parameter | Type | Description | |-------------------------|------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `conditions` | text | Comma separated list of expressions on the format `ITEM_NAME OPERATOR ITEM_STATE`, ie `MyItem EQ OFF`. Use quotes around `ITEM_STATE` to treat value as string ie `'OFF`' | -| `mismatchState` | text | Optional state to pass instead if conditions are NOT met. Use quotes to treat as `StringType` | +| `mismatchState` | text | Optional state to pass instead if conditions are NOT met. Use quotes to treat as `StringType`. Defaults to `UNDEF` | Possible values for token `OPERATOR` in `conditions`: diff --git a/bundles/org.smarthomej.transform.basicprofiles/src/main/java/org/smarthomej/transform/basicprofiles/internal/profiles/StateFilterProfile.java b/bundles/org.smarthomej.transform.basicprofiles/src/main/java/org/smarthomej/transform/basicprofiles/internal/profiles/StateFilterProfile.java index 0c5d3ff158..8cfc753268 100644 --- a/bundles/org.smarthomej.transform.basicprofiles/src/main/java/org/smarthomej/transform/basicprofiles/internal/profiles/StateFilterProfile.java +++ b/bundles/org.smarthomej.transform.basicprofiles/src/main/java/org/smarthomej/transform/basicprofiles/internal/profiles/StateFilterProfile.java @@ -50,7 +50,7 @@ public class StateFilterProfile implements StateProfile { private final ProfileCallback callback; private List> acceptedDataTypes; - private List conditions = new ArrayList<>(); + private List conditions = new ArrayList<>(); @Nullable private State configMismatchState = null; @@ -71,17 +71,17 @@ private List parseConditions(String config) { if (config == null) return List.of(); - List parsedConditions = new ArrayList<>(); + List parsedConditions = new ArrayList<>(); try { String[] expressions = config.split(","); for (String expression : expressions) { String[] parts = expression.trim().split("\s"); if (parts.length == 3) { String itemName = parts[0]; - Condition.ComparisonType conditionType = Condition.ComparisonType + StateCondition.ComparisonType conditionType = StateCondition.ComparisonType .valueOf(parts[1].toUpperCase(Locale.ROOT)); String value = parts[2]; - parsedConditions.add(new Condition(itemName, conditionType, value)); + parsedConditions.add(new StateCondition(itemName, conditionType, value)); } else { logger.warn("Malformed condition expression: '{}'", expression); } @@ -130,7 +130,7 @@ public void onStateUpdateFromHandler(State state) { private State checkCondition(State state) { if (!conditions.isEmpty()) { boolean allConditionsMet = true; - for (Condition condition : conditions) { + for (StateCondition condition : conditions) { logger.debug("Evaluting condition: {}", condition); try { Item item = itemRegistry.getItem(condition.itemName); @@ -172,7 +172,7 @@ State parseState(@Nullable String stateString) { } } - class Condition { + class StateCondition { String itemName; ComparisonType comparisonType; @@ -180,7 +180,7 @@ class Condition { boolean quoted = false; - public Condition(String itemName, ComparisonType comparisonType, String value) { + public StateCondition(String itemName, ComparisonType comparisonType, String value) { this.itemName = itemName; this.comparisonType = comparisonType; this.value = value; @@ -219,7 +219,7 @@ enum ComparisonType { @Override public String toString() { - return "Condition{" + "itemName='" + itemName + '\'' + ", comparisonType=" + comparisonType + ", value='" + return "StateCondition{" + "itemName='" + itemName + '\'' + ", comparisonType=" + comparisonType + ", value='" + value + '\'' + '}'; } }