diff --git a/solixauto/anker.py b/solixauto/anker.py index a1b9d05..a0e88d9 100644 --- a/solixauto/anker.py +++ b/solixauto/anker.py @@ -108,6 +108,12 @@ def online_hint(info): return None +BLUETOOTH_ONLY_SHORT = ( + "Bluetooth-only models cannot be used as a source. " + "Details: --explain-skipped" +) + + def clean_status(raw): return {key: value for key, value in (raw or {}).items() if key not in IGNORED_KEYS} @@ -390,7 +396,13 @@ async def close_session(api, websession): async def discover( - settle=45, only_pn=None, only_sn=None, skip=None, include_offline=False, verbose=True + settle=45, + only_pn=None, + only_sn=None, + skip=None, + include_offline=False, + explain_skipped=False, + verbose=True, ): paths.ensure_dirs() @@ -419,10 +431,12 @@ async def discover( continue if not include_offline and online_hint(info) is False: - print() - print(f" {serial} - {model_label(part_number_of(info))}") - print(" not cloud connected, skipping without subscribing.") - print(BLUETOOTH_ONLY_HINT) + label = model_label(part_number_of(info)) + print(f" {serial} - {label}: not cloud connected, skipped.") + if explain_skipped: + print(BLUETOOTH_ONLY_HINT) + else: + print(f" {BLUETOOTH_ONLY_SHORT}") continue targets[serial] = info diff --git a/solixauto/cli.py b/solixauto/cli.py index a13bc44..22dd03f 100644 --- a/solixauto/cli.py +++ b/solixauto/cli.py @@ -172,6 +172,7 @@ def cmd_discover_anker(args): only_sn=args.sn, skip=args.skip, include_offline=args.include_offline, + explain_skipped=args.explain_skipped, ) ) print() @@ -1319,6 +1320,11 @@ def build_parser(): action="store_true", help="try devices the cloud reports as not connected", ) + anker_parser.add_argument( + "--explain-skipped", + action="store_true", + help="print the full reason when a device is skipped", + ) anker_parser.set_defaults(func=cmd_discover_anker) shelly_parser = subparsers.add_parser( diff --git a/solixauto/setup.py b/solixauto/setup.py index 86a36e7..a079300 100644 --- a/solixauto/setup.py +++ b/solixauto/setup.py @@ -418,7 +418,7 @@ def run_setup(prompt, choose, confirm): ) print() try: - asyncio.run(anker.discover()) + asyncio.run(anker.discover(explain_skipped=True)) except Exception as err: print(f" Discovery failed: {type(err).__name__}: {err}") return False