Skip to content

[Rules] Support nested AND / OR / NOT condition groups #4

Description

@emi-ran

Feature

Support nested AND / OR / NOT condition groups. Current Automation.conditions: List<RuleCondition> has flat AND semantics, so it cannot express: Wi-Fi = Home AND (time = night OR battery < 20%).

Proposed model

  • Replace or version the flat list with a serializable condition expression tree: AllOf, AnyOf, Not, and leaf RuleCondition.
  • Preserve existing rules by migrating each non-empty flat list to AllOf(leaves).
  • Put expression evaluation in a pure engine component with short-circuit semantics and unit tests.
  • Build a bounded Compose editor supporting grouping, reorder, delete, and visible nesting. Avoid arbitrary complexity if depth must be capped; document cap.
  • Export/import must preserve the expression tree and retain current encrypted-backup validation-before-mutation guarantees.

Acceptance criteria

  • Existing rules preserve exact behavior after migration.
  • User can create Wi-Fi = Home AND (night OR battery below 20%) and a NOT group.
  • Invalid empty groups cannot be saved.
  • History/rule detail show a human-readable expression without sensitive values.

Verification

  • Migration fixtures for old JSON, current export/import, malformed groups, and nested evaluation.
  • Test repeated event, cooldown, permission-denial, and no-match paths on Xiaomi 15T Pro / HyperOS 3.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions