From 2a9e9cda4c292ca4093256c4cced0082968110e4 Mon Sep 17 00:00:00 2001 From: Sterling Archer Date: Wed, 12 Aug 2026 09:53:46 -0700 Subject: [PATCH] Only preview notifications for rules that would act --- solixauto/engine.py | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/solixauto/engine.py b/solixauto/engine.py index 0a9eeb7..ef4df55 100644 --- a/solixauto/engine.py +++ b/solixauto/engine.py @@ -969,6 +969,9 @@ def _print_rule_table( states = engine.states if engine else None for index, rule in enumerate(profile.active_rules()): + acting = False + errored = False + if states: state = states[index] satisfied = state.last_value @@ -976,36 +979,46 @@ def _print_rule_table( ripe = state.ripe(now) if now else False if state.error: verdict = f"ERROR {state.error}" + errored = True elif not satisfied: - verdict = "false" + verdict = "no" elif ripe: - verdict = f"TRUE and ripe -> would {rule.action}" + verdict = f"YES, ready now -> would {rule.action}" + acting = True else: remaining = (rule.dwell or 0) - held - verdict = f"true, waiting {format_duration(remaining)} of dwell" + verdict = ( + f"YES, holding {format_duration(remaining)} more before acting" + ) + acting = True else: try: satisfied = rule.evaluate(variables) - verdict = ( - f"true -> would {rule.action} after {format_duration(rule.dwell)}" - if satisfied - else "false" - ) + if satisfied: + verdict = ( + f"YES -> would {rule.action} after " + f"{format_duration(rule.dwell)}" + ) + acting = True + else: + verdict = "no" except Exception as err: verdict = f"ERROR {type(err).__name__}: {err}" + errored = True - print(f" [{rule.priority:>3}] {rule.name}") + marker = " *" if acting else (" " if not errored else " !") + print(f" {marker} [{rule.priority:>3}] {rule.name}") print(f" when {rule.when_source}") print(f" {verdict}") desired = rule.desired_state() - if desired is not None: + if acting and desired is not None: if engine: message = _render_live_notification(engine, rule, variables, desired) else: message = _preview_notification(profile, rule, variables, desired) if message: - print(f" notify: {message}") + print(f" would notify: {message}") def _render_live_notification(engine, rule, variables, desired):