qapu-cli 0.80.0__tar.gz → 0.83.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/PKG-INFO +4 -2
  2. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/README.md +3 -1
  3. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/pyproject.toml +1 -1
  4. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/command_packages.py +12 -0
  5. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/main.py +345 -14
  6. qapu_cli-0.83.0/qapu_cli/sso_login.py +123 -0
  7. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/data.py +12 -5
  8. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/dashboard.py +4 -2
  9. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli.egg-info/PKG-INFO +4 -2
  10. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli.egg-info/SOURCES.txt +2 -0
  11. qapu_cli-0.83.0/tests/test_sso_login.py +44 -0
  12. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/tests/test_tui_smoke.py +6 -6
  13. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/__init__.py +0 -0
  14. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/client.py +0 -0
  15. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/__init__.py +0 -0
  16. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/app.py +0 -0
  17. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/app.tcss +0 -0
  18. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/rendering.py +0 -0
  19. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/__init__.py +0 -0
  20. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/catalog.py +0 -0
  21. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/catalog_form.py +0 -0
  22. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/catalog_picker.py +0 -0
  23. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/confirm.py +0 -0
  24. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/device_authorization.py +0 -0
  25. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/device_edit.py +0 -0
  26. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/device_list.py +0 -0
  27. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/equipment_form.py +0 -0
  28. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/group_detail.py +0 -0
  29. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/group_form.py +0 -0
  30. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/group_list.py +0 -0
  31. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/screens/infrastructure.py +0 -0
  32. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/widgets/__init__.py +0 -0
  33. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/tui/widgets/device_table.py +0 -0
  34. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli/visibility.py +0 -0
  35. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli.egg-info/dependency_links.txt +0 -0
  36. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli.egg-info/entry_points.txt +0 -0
  37. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli.egg-info/requires.txt +0 -0
  38. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/qapu_cli.egg-info/top_level.txt +0 -0
  39. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/setup.cfg +0 -0
  40. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/tests/test_command_packages_complete.py +0 -0
  41. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/tests/test_login.py +0 -0
  42. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/tests/test_logout.py +0 -0
  43. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/tests/test_tui_authorization.py +0 -0
  44. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/tests/test_tui_catalog.py +0 -0
  45. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/tests/test_tui_device_edit.py +0 -0
  46. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/tests/test_tui_electrical_parent.py +0 -0
  47. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/tests/test_tui_groups.py +0 -0
  48. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/tests/test_tui_infrastructure.py +0 -0
  49. {qapu_cli-0.80.0 → qapu_cli-0.83.0}/tests/test_visibility.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qapu-cli
3
- Version: 0.80.0
3
+ Version: 0.83.0
4
4
  Summary: CLI client for the Qapu API - built for the Hermes agent, but usable by anyone talking to api.ovoo.com.tr from outside the Swarm.
5
5
  Author: OVOO Technology
6
6
  Classifier: Programming Language :: Python :: 3
@@ -67,7 +67,7 @@ Either way installs a `qapu` command (see `pyproject.toml`'s `[project.scripts]`
67
67
  | `qapu data` | Readings per variable for a device - latest value, last N buffered readings (--last), daily min/avg/max (--days), an explicit --start/--end range, or a live-refreshed view (--watch) (GET /hermes/data/{device_id}). |
68
68
  | `qapu energy` | One day's active/reactive energy breakdown per phase, or --days/--start/--end for a per-day breakdown plus a cumulative Total (GET /hermes/energy/{device_id}). |
69
69
  | `qapu health` | Check CLI/server version, connectivity, and server status (GET /health, no auth required). |
70
- | `qapu login` | Log in and save a Bearer JWT locally for `auth-token *` - `qapu login [username]` (operator/CLI, Username+Password, POST /auth/login/cli) is the **default**, prompting for whatever wasn't given, password always hidden, never a CLI flag. `qapu login --phone <number>` (mobile-app Phone+Pin, POST /auth/login) is an explicit opt-in, never mixed with a username. |
70
+ | `qapu login` | Log in and save a Bearer JWT locally for `auth-token *` - `qapu login [username]` (operator/CLI, Username+Password, POST /auth/login/cli) is the **default**, prompting for whatever wasn't given, password always hidden, never a CLI flag. `qapu login --phone <number>` (mobile-app Phone+Pin, POST /auth/login) is an explicit opt-in, never mixed with a username. `qapu login --browser` logs in on auth.ovoo.com.tr's own page (SSO; no password at all when the browser is already logged in), needs a browser on this machine. |
71
71
  | `qapu logout` | Clear the locally saved Bearer JWT (client-side only) - does **not** clear a saved Hermes API token, see "Auth" below. |
72
72
  | `qapu whoami` | Show the currently logged-in account, from the locally saved credentials. |
73
73
  | `qapu pipeline` | Fleet-wide pipeline throughput for a time window - ingest/data/rule/blockchain packet+event counts (GET /hermes/pipeline/stats). `--watch` live-refreshes in place. |
@@ -85,6 +85,7 @@ Either way installs a `qapu` command (see `pyproject.toml`'s `[project.scripts]`
85
85
  | `qapu device list` | List every device Qapu knows about (GET /hermes/devices). |
86
86
  | `qapu device reliability` | Analyze a device's periodic packet delivery over a time window - total/expected packets, delivery rate, average/min/max interval, estimated missed packets, longest gap (GET /hermes/reliability/{device_id}). |
87
87
  | `qapu score list` | List recent Cinga Score snapshot rows, optionally filtered by device/window type (GET /hermes/scores). |
88
+ | `qapu score fleet-summary --device-ids A,B,C [--window-type ...] [--json]` | Latest four cards per device, worst card first, with the change since the window start (GET /hermes/scores/fleet-summary). |
88
89
  | `qapu score get` | Single snapshot detail (GET /hermes/scores/{score_id}). |
89
90
  | `qapu score bundle` | The AI-facing structured packet for one snapshot (GET /hermes/scores/{score_id}/bundle). |
90
91
  | `qapu score revisions` | Every revision (ACTIVE/SUPERSEDED) of the same logical period (GET /hermes/scores/{score_id}/revisions). |
@@ -99,6 +100,7 @@ Either way installs a `qapu` command (see `pyproject.toml`'s `[project.scripts]`
99
100
  |---|---|
100
101
  | `qapu variable get` | Get one variable's detail (GET /hermes/variables/{variable_id}). |
101
102
  | `qapu variable list` | List the variable catalog (GET /hermes/variables). |
103
+ | `qapu variable stats` | Stored readings per variable - typed table, reading/device counts, first/last time, last 24 h; `--segment`, `--stored-only` (GET /hermes/variables/stats, recomputed hourly by services/windows). |
102
104
 
103
105
  #### `group` - device groups
104
106
 
@@ -50,7 +50,7 @@ Either way installs a `qapu` command (see `pyproject.toml`'s `[project.scripts]`
50
50
  | `qapu data` | Readings per variable for a device - latest value, last N buffered readings (--last), daily min/avg/max (--days), an explicit --start/--end range, or a live-refreshed view (--watch) (GET /hermes/data/{device_id}). |
51
51
  | `qapu energy` | One day's active/reactive energy breakdown per phase, or --days/--start/--end for a per-day breakdown plus a cumulative Total (GET /hermes/energy/{device_id}). |
52
52
  | `qapu health` | Check CLI/server version, connectivity, and server status (GET /health, no auth required). |
53
- | `qapu login` | Log in and save a Bearer JWT locally for `auth-token *` - `qapu login [username]` (operator/CLI, Username+Password, POST /auth/login/cli) is the **default**, prompting for whatever wasn't given, password always hidden, never a CLI flag. `qapu login --phone <number>` (mobile-app Phone+Pin, POST /auth/login) is an explicit opt-in, never mixed with a username. |
53
+ | `qapu login` | Log in and save a Bearer JWT locally for `auth-token *` - `qapu login [username]` (operator/CLI, Username+Password, POST /auth/login/cli) is the **default**, prompting for whatever wasn't given, password always hidden, never a CLI flag. `qapu login --phone <number>` (mobile-app Phone+Pin, POST /auth/login) is an explicit opt-in, never mixed with a username. `qapu login --browser` logs in on auth.ovoo.com.tr's own page (SSO; no password at all when the browser is already logged in), needs a browser on this machine. |
54
54
  | `qapu logout` | Clear the locally saved Bearer JWT (client-side only) - does **not** clear a saved Hermes API token, see "Auth" below. |
55
55
  | `qapu whoami` | Show the currently logged-in account, from the locally saved credentials. |
56
56
  | `qapu pipeline` | Fleet-wide pipeline throughput for a time window - ingest/data/rule/blockchain packet+event counts (GET /hermes/pipeline/stats). `--watch` live-refreshes in place. |
@@ -68,6 +68,7 @@ Either way installs a `qapu` command (see `pyproject.toml`'s `[project.scripts]`
68
68
  | `qapu device list` | List every device Qapu knows about (GET /hermes/devices). |
69
69
  | `qapu device reliability` | Analyze a device's periodic packet delivery over a time window - total/expected packets, delivery rate, average/min/max interval, estimated missed packets, longest gap (GET /hermes/reliability/{device_id}). |
70
70
  | `qapu score list` | List recent Cinga Score snapshot rows, optionally filtered by device/window type (GET /hermes/scores). |
71
+ | `qapu score fleet-summary --device-ids A,B,C [--window-type ...] [--json]` | Latest four cards per device, worst card first, with the change since the window start (GET /hermes/scores/fleet-summary). |
71
72
  | `qapu score get` | Single snapshot detail (GET /hermes/scores/{score_id}). |
72
73
  | `qapu score bundle` | The AI-facing structured packet for one snapshot (GET /hermes/scores/{score_id}/bundle). |
73
74
  | `qapu score revisions` | Every revision (ACTIVE/SUPERSEDED) of the same logical period (GET /hermes/scores/{score_id}/revisions). |
@@ -82,6 +83,7 @@ Either way installs a `qapu` command (see `pyproject.toml`'s `[project.scripts]`
82
83
  |---|---|
83
84
  | `qapu variable get` | Get one variable's detail (GET /hermes/variables/{variable_id}). |
84
85
  | `qapu variable list` | List the variable catalog (GET /hermes/variables). |
86
+ | `qapu variable stats` | Stored readings per variable - typed table, reading/device counts, first/last time, last 24 h; `--segment`, `--stored-only` (GET /hermes/variables/stats, recomputed hourly by services/windows). |
85
87
 
86
88
  #### `group` - device groups
87
89
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "qapu-cli"
3
- version = "0.80.0"
3
+ version = "0.83.0"
4
4
  description = "CLI client for the Qapu API - built for the Hermes agent, but usable by anyone talking to api.ovoo.com.tr from outside the Swarm."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -128,6 +128,7 @@ COMMAND_REQUIRED_PACKAGES: dict[str, frozenset[str]] = {
128
128
  "fota_approvals": frozenset({"hardware-catalog:read"}),
129
129
  "fota_approve": frozenset({"hardware-catalog:write"}),
130
130
  "fota_confirmations": frozenset({"hardware-catalog:read"}),
131
+ "fota_reports": frozenset({"hardware-catalog:read"}),
131
132
  "fota_ftp": frozenset({"device-actuation:write", "hardware-catalog:read"}),
132
133
  "fota_revoke": frozenset({"hardware-catalog:write"}),
133
134
  "fota_http": frozenset({"device-actuation:write", "hardware-catalog:read"}),
@@ -200,6 +201,7 @@ COMMAND_REQUIRED_PACKAGES: dict[str, frozenset[str]] = {
200
201
  "score_bundle": frozenset({"scores:read"}),
201
202
  "score_calculate": frozenset({"scores:write"}),
202
203
  "score_delete": frozenset({"scores:write"}),
204
+ "score_fleet_summary": frozenset({"telemetry:read"}),
203
205
  "score_get": frozenset({"scores:read"}),
204
206
  "score_list": frozenset({"scores:read"}),
205
207
  "score_narrative": frozenset({"scores:write"}),
@@ -253,6 +255,16 @@ COMMAND_REQUIRED_PACKAGES: dict[str, frozenset[str]] = {
253
255
  "user_update": frozenset({"users:write"}),
254
256
  "variable_get": frozenset({"platform-config:read"}),
255
257
  "variable_list": frozenset({"platform-config:read"}),
258
+ "variable_stats": frozenset({"platform-config:read"}),
259
+ # Notifications (2026-11-11) - hermes_notifications.py routes (not in the hermes.py route table the
260
+ # derivation reads): always visible, Hermes enforces devices:read / users:* / notifications:*
261
+ "notification_channel_set": frozenset(),
262
+ "notification_channels": frozenset(),
263
+ "notification_log": frozenset(),
264
+ "notification_set": frozenset(),
265
+ "notification_settings": frozenset(),
266
+ "notification_type_update": frozenset(),
267
+ "notification_types": frozenset(),
256
268
  "whoami": frozenset(),
257
269
  }
258
270
 
@@ -25,7 +25,7 @@ from rich.panel import Panel
25
25
  from rich.table import Table
26
26
  from rich.tree import Tree
27
27
 
28
- from qapu_cli import client
28
+ from qapu_cli import client, sso_login
29
29
 
30
30
  app = typer.Typer(no_args_is_help=True, help="Qapu API client CLI.")
31
31
  device_app = typer.Typer(no_args_is_help=True, help="Device-related commands.")
@@ -118,6 +118,8 @@ device_context_app = typer.Typer(no_args_is_help=True, help="A device's own appe
118
118
  app.add_typer(device_context_app, name="device-context", rich_help_panel="Cihaz & Altyapı")
119
119
  auth_token_app = typer.Typer(no_args_is_help=True, help="services/auth API token commands (create/list/revoke) - package-scoped Bearer tokens for services/mcp etc. Requires `qapu login` first.")
120
120
  app.add_typer(auth_token_app, name="auth-token", rich_help_panel="Oturum & Sistem")
121
+ notification_app = typer.Typer(no_args_is_help=True, help="Notifications (2026-11-11): event types, channel switches, your own / a user's notification settings, the delivery log.")
122
+ app.add_typer(notification_app, name="notification", rich_help_panel="Kullanıcı & Yetki")
121
123
 
122
124
  console = Console()
123
125
 
@@ -171,11 +173,10 @@ SEGMENTS = {
171
173
  }
172
174
 
173
175
  # There Is No Real "Online/Offline" Field on a Device - Derived Here from
174
- # How Recently `Update_Time` Moved, Since `data`'s process_message() Calls
175
- # Device.update() on Every Packet a Device Sends (Confirmed via
176
- # database/models.py's `onupdate=func.now()` on that column). A device
177
- # whose metadata was hand-edited recently would also count as "Online" by
178
- # this measure - an accepted, minor false positive, not a real signal.
176
+ # its Last Packet (Last_Pack_Time = devices.last_connection_time, Written by
177
+ # services/data per Packet). Until 2026-11-06 This Read Update_Time, Which
178
+ # any Edit of the Device Also Moves: a Burnt Device Looked Online for 30
179
+ # min After its Tariff was Set.
179
180
  ONLINE_THRESHOLD_MINUTES = 30
180
181
 
181
182
 
@@ -365,6 +366,7 @@ def login(
365
366
  username: Optional[str] = typer.Argument(None, help="Operator/CLI username (POST /auth/login/cli) - the DEFAULT login path. Prompted interactively if omitted."),
366
367
  phone: Optional[str] = typer.Option(None, "--phone", help="Mobile-app-style login instead (Phone+Pin, POST /auth/login) - explicit opt-in only, use WITHOUT the username argument. For debugging a mobile account from the CLI; not the default."),
367
368
  pin: Optional[str] = typer.Option(None, "--pin", help="Account PIN for --phone login - prompted securely (not echoed) if not given on the command line. Only valid together with --phone."),
369
+ browser: bool = typer.Option(False, "--browser", help="Log in on auth.ovoo.com.tr in the browser (SSO - no password here when the browser is already logged in). Needs a browser on this machine."),
368
370
  ):
369
371
  """Log in - `qapu login [username]` (operator/CLI, Username+Password, POST /auth/login/cli) is the DEFAULT. `qapu login --phone <number>` (mobile-app Phone+Pin, POST /auth/login) is an explicit, opt-in alternative for debugging a mobile account - never mixed with the username argument. Saves a Bearer JWT locally for `auth-token *`.
370
372
 
@@ -376,8 +378,25 @@ def login(
376
378
  if username and phone:
377
379
  typer.echo("Error: `[username]` ve `--phone` aynı anda verilemez - birini seçin.", err=True)
378
380
  raise typer.Exit(code=1)
381
+ if browser and (username or phone or pin):
382
+ typer.echo("Error: `--browser` tek başına kullanılır - kullanıcı adı/telefon tarayıcıda girilir.", err=True)
383
+ raise typer.Exit(code=1)
379
384
 
380
- if phone:
385
+ refresh_token = None
386
+ if browser:
387
+ # SSO (2026-10-29): Code+PKCE on auth's own Page, Back to a Loopback
388
+ # Listener; the Access Token Works on auth Like the Login JWT
389
+ tokens = sso_login.browser_login(echo=lambda text: console.print(f"[dim]{text}[/dim]"))
390
+ refresh_token = tokens.get("refresh_token")
391
+ try:
392
+ profile = sso_login.me(tokens["access_token"])
393
+ except Exception:
394
+ sso_login.revoke(refresh_token)
395
+ typer.echo("Error: giriş yapıldı ama hesap bilgisi alınamadı.", err=True)
396
+ raise typer.Exit(code=1)
397
+ result = {"Access_Token": tokens["access_token"], "User": {"ID": profile.get("ID"), "First_Name": profile.get("First_Name"), "Last_Name": profile.get("Last_Name")}}
398
+ identifier = profile.get("Username") or profile.get("Email") or str(profile.get("ID"))
399
+ elif phone:
381
400
  # Mobile-App-Style Login - Phone+Pin, POST /auth/login. Explicit
382
401
  # Opt-in Only (2026-10-05: "cli a giriş user name password ile
383
402
  # olacak, mevcutta tel/pin gibi gördüm" - the Bare Command's
@@ -444,6 +463,9 @@ def login(
444
463
  else:
445
464
  console.print("[dim]Hesabınıza henüz hiçbir yetki paketi tanımlanmamış - Hermes komutları için bir yönetici paket tanımlamalı.[/dim]")
446
465
 
466
+ # The CLI Keeps its Hermes Token, not the Browser Login's Refresh Token
467
+ sso_login.revoke(refresh_token)
468
+
447
469
 
448
470
  @app.command("logout", rich_help_panel="Oturum & Sistem")
449
471
  def logout(revoke: bool = typer.Option(False, "--revoke", help="Also revoke this machine's saved Hermes API token server-side (not just the login session) before clearing it locally - for when you're done with this machine/account pairing for good, not just ending a session. Without this flag, logout is unchanged: client-side only, the Hermes token is deliberately preserved so other `qapu` commands keep working. Logging back in afterward auto-mints a fresh one against your account's current packages either way.")):
@@ -524,11 +546,13 @@ def whoami(as_json: bool = typer.Option(False, "--json")):
524
546
  console.print("[dim]Yetkiler alınamadı (sunucuya ulaşılamadı).[/dim]")
525
547
 
526
548
 
527
- # Resolve Whether a Device Counts as "Online" by the Update_Time Heuristic
549
+ # Resolve Whether a Device Counts as "Online": its Last Packet Within the
550
+ # Threshold. Never Update_Time - any Edit of the Device (a Tariff, a Name)
551
+ # Moves That and Made a Silent Device Look Online (2026-11-06).
528
552
  def _is_online(device: dict[str, Any]) -> bool:
529
553
 
530
554
  # Resolve the Raw Timestamp String
531
- update_time_raw = device.get("Update_Time")
555
+ update_time_raw = device.get("Last_Pack_Time")
532
556
 
533
557
  # No Timestamp at all - Treat as Offline
534
558
  if not update_time_raw:
@@ -665,7 +689,7 @@ def _build_device_table(devices: list[dict[str, Any]]) -> Table:
665
689
  online = _is_online(d)
666
690
  status_label = "[green]Online[/green]" if online else "[red]Offline[/red]"
667
691
  firmware = d.get("Version") or "-"
668
- last_connection = _relative_time(d.get("Update_Time"))
692
+ last_connection = _relative_time(d.get("Last_Pack_Time"))
669
693
 
670
694
  # Add the Row
671
695
  table.add_row(device_id, name, system_type, status_label, firmware, last_connection)
@@ -869,7 +893,7 @@ def device_get(
869
893
  # Bağlantı - Device_Detail_Schema has no Last_Connection_IP; Last_Pack_Time
870
894
  # (Last Raw Packet Ingested) is the Real Field Available Here
871
895
  console.print(_device_section_table("Bağlantı", [
872
- ("Son Bağlantı", _relative_time(d.get("Update_Time"))),
896
+ ("Kayıt Güncelleme", _relative_time(d.get("Update_Time"))),
873
897
  ("Son Paket", _relative_time(d.get("Last_Pack_Time"))),
874
898
  ("Firmware", d.get("Version")),
875
899
  ]))
@@ -1283,7 +1307,13 @@ def device_purge_history(
1283
1307
  ("Timeline Olayları", result.get(f"Timeline_Events_{suffix}")),
1284
1308
  ("Analytics Days (Redis)", result.get(f"Analytics_Days_{suffix}")),
1285
1309
  ("Blockchain Blocks", result.get(f"Blockchain_Blocks_{suffix}")),
1310
+ # The Rest of the History (2026-10-30) - Raw Packets, Scores, Windows, ...
1311
+ *[(table, count) for table, count in (result.get(f"History_{suffix}") or {}).items()],
1312
+ ("Yeniden Hesaplanan Pencere", result.get("Windows_To_Recompute" if dry_run else "Windows_Recomputed")),
1313
+ ("Redis Buffer Kayıtları", (result.get("Redis_Found" if dry_run else "Redis_Reset") or {}).get("Buffer_Entries")),
1286
1314
  ]))
1315
+ if result.get("History_Error"):
1316
+ console.print(f"[red]{result['History_Error']}[/red]")
1287
1317
  console.print(f"\n[{'yellow' if dry_run else 'red'}]{result.get('Note')}[/{'yellow' if dry_run else 'red'}]")
1288
1318
  if dry_run:
1289
1319
  console.print("[dim]Gerçekten silmek için aynı komuta --confirm ekleyin.[/dim]")
@@ -1780,6 +1810,50 @@ def _looks_like_score_row_id(value: str) -> bool:
1780
1810
  return value.isdigit() and len(value) <= 9
1781
1811
 
1782
1812
 
1813
+ # Compact Fleet Ranking (2026-10-28, GET /hermes/scores/fleet-summary)
1814
+ @score_app.command("fleet-summary")
1815
+ def score_fleet_summary(
1816
+ device_ids: str = typer.Option(..., "--device-ids", help="Comma-separated device IDs (max 200)."),
1817
+ window_type: Optional[str] = typer.Option(None, "--window-type", help="ROLLING_24H (default) | DAILY_FIXED | WEEKLY_FIXED."),
1818
+ as_json: bool = typer.Option(False, "--json", help="Print raw JSON instead of a table."),
1819
+ ):
1820
+ """Latest Cinga Score cards for the given devices, worst card first (GET /hermes/scores/fleet-summary)."""
1821
+
1822
+ params: dict[str, Any] = {"device_ids": device_ids}
1823
+ if window_type is not None:
1824
+ params["window_type"] = window_type
1825
+ result = client.get("/hermes/scores/fleet-summary", params=params)
1826
+
1827
+ if as_json:
1828
+ typer.echo(json.dumps(result, indent=2, ensure_ascii=False))
1829
+ return
1830
+
1831
+ def cell(card: dict) -> str:
1832
+ score = card.get("Score")
1833
+ if score is None:
1834
+ status_text = card.get("Status") or "-"
1835
+ return f"[dim]{status_text.replace('NOT_APPLICABLE_', 'N/A ').lower()}[/dim]"
1836
+ change = card.get("Change")
1837
+ trend = f" [dim]{change:+.1f}[/dim]" if isinstance(change, (int, float)) and change != 0 else ""
1838
+ flag = f" [yellow]{card['Status'].lower()}[/yellow]" if card.get("Status") else ""
1839
+ return f"{_colorize_score(score)}{trend}{flag}"
1840
+
1841
+ table = Table(title=f"Filo skor özeti ({result.get('Window_Type')}, en kötüden iyiye)")
1842
+ for column in ("CİHAZ", "AD", "EN KÖTÜ", "REAKTİF", "ŞEBEKE", "MOTOR", "YÜK"):
1843
+ table.add_column(column)
1844
+ for entry in result.get("Devices", []):
1845
+ worst = f"{entry.get('Worst_Card')} {entry.get('Worst_Score'):.1f}" if entry.get("Worst_Card") else "-"
1846
+ table.add_row(
1847
+ entry.get("Device_ID") or "-", (entry.get("Name") or "-")[:28], worst,
1848
+ cell(entry.get("Reactive") or {}), cell(entry.get("Grid") or {}), cell(entry.get("Motor_Stress") or {}), cell(entry.get("Load_Behavior") or {}),
1849
+ )
1850
+ console.print(table)
1851
+ for item in result.get("No_Score", []):
1852
+ console.print(f"[dim]Skor yok: {item.get('Device_ID')} {item.get('Name') or ''} ({item.get('Reason')})[/dim]")
1853
+ for item in result.get("Errors", []):
1854
+ console.print(f"[red]Hata: {item.get('Device_ID')} - {item.get('Error')}[/red]")
1855
+
1856
+
1783
1857
  @score_app.command("get")
1784
1858
  def score_get(
1785
1859
  id_or_device: str = typer.Argument(..., help="Snapshot row ID, OR a Device ID (resolves to that device's latest snapshot) - with --watch/--days/--start/--end, always treated as a Device ID."),
@@ -2434,6 +2508,67 @@ def variable_get(
2434
2508
  console.print(table)
2435
2509
 
2436
2510
 
2511
+ # Build the Variable Storage-Statistics Table
2512
+ def _build_variable_stats_table(items: list[dict[str, Any]]) -> Table:
2513
+ table = Table(show_header=True, header_style="bold")
2514
+ table.add_column("DEĞİŞKEN", no_wrap=True)
2515
+ table.add_column("TABLO", no_wrap=True)
2516
+ table.add_column("ÖLÇÜM", justify="right", no_wrap=True)
2517
+ table.add_column("CİHAZ", justify="right", no_wrap=True)
2518
+ table.add_column("24 SA", justify="right", no_wrap=True)
2519
+ table.add_column("İLK", no_wrap=True)
2520
+ table.add_column("SON", no_wrap=True)
2521
+ for item in items:
2522
+ if not item.get("Stored"):
2523
+ storage = "[dim]saklanmıyor[/dim]"
2524
+ else:
2525
+ # measurements_energy -> energy, synthesis_energy -> energy*
2526
+ storage = (item.get("Table") or "-").split("_", 1)[-1] + ("[dim]*[/dim]" if item.get("Synthesized") else "")
2527
+ table.add_row(
2528
+ item.get("Variable_ID") or "-", storage,
2529
+ f"{item.get('Reading_Count') or 0:,}".replace(",", "."), str(item.get("Device_Count") or 0), f"{item.get('Last_24h_Count') or 0:,}".replace(",", "."),
2530
+ (item.get("First_Time") or "-")[:10], (item.get("Last_Time") or "-")[:16].replace("T", " "),
2531
+ )
2532
+ return table
2533
+
2534
+
2535
+ # Per-Variable Storage Statistics
2536
+ @variable_app.command("stats")
2537
+ def variable_stats(
2538
+ as_json: bool = typer.Option(False, "--json", help="Print raw JSON instead of a table."),
2539
+ segment: Optional[str] = typer.Option(None, "--segment", help=f"Filter by segment name: {', '.join(SEGMENTS)}."),
2540
+ stored_only: bool = typer.Option(False, "--stored-only", help="Only variables that have a typed-table column."),
2541
+ limit: Optional[int] = typer.Option(None, "--limit", help="Cap the number of variables shown (replaces interactive pagination)."),
2542
+ ):
2543
+ """How many stored readings each variable has (GET /hermes/variables/stats) - recomputed hourly, most readings first."""
2544
+
2545
+ # Resolve the Segment Filter to its ID, if Given
2546
+ params: dict[str, Any] = {}
2547
+ if segment:
2548
+ segment_key = segment.strip().lower()
2549
+ if segment_key not in SEGMENTS:
2550
+ typer.echo(f"Error: unknown segment '{segment}'. Choose one of: {', '.join(SEGMENTS)}.", err=True)
2551
+ raise typer.Exit(code=1)
2552
+ params["segment_id"] = SEGMENTS[segment_key]
2553
+
2554
+ # Fetch the Stored Statistics
2555
+ result: dict[str, Any] = client.get("/hermes/variables/stats", params=params)
2556
+ if as_json:
2557
+ typer.echo(json.dumps(result, indent=2, ensure_ascii=False))
2558
+ return
2559
+ if not result.get("Calculated_At"):
2560
+ console.print("[yellow]İstatistik henüz hesaplanmadı (windows servisi saatte bir hesaplar).[/yellow]")
2561
+ return
2562
+
2563
+ # Most Readings First, Unstored Last
2564
+ items = [item for item in result.get("Items") or [] if item.get("Stored") or not stored_only]
2565
+ items.sort(key=lambda item: (not item.get("Stored"), -(item.get("Reading_Count") or 0), item.get("Variable_ID") or ""))
2566
+ if limit is not None:
2567
+ items = items[:limit]
2568
+ console.print(f"[dim]Hesaplandı: {result['Calculated_At'][:16].replace('T', ' ')} (* = sentez tablosu)[/dim]")
2569
+ _print_paginated(items, _build_variable_stats_table, limit=limit, noun="değişken")
2570
+
2571
+
2437
2572
  # Cosmetic Grouping/Bar Helpers for `data`'s Latest-Value Views (2026-09-04) -
2438
2573
  # a Flat, Alphabetically-Sorted Table Mixes Raw Per-Phase Readings (VRMS_R/
2439
2574
  # S/T) with Their Own Derived/Computed Siblings (VRMS_A/EQ/IMB/SR), which
@@ -3269,6 +3404,8 @@ _REACTIVE_PENALTY_STATUS_STYLE = {
3269
3404
  "YAKLAŞIYOR": "yellow",
3270
3405
  "CEZA_SINIRINDA_VEYA_AŞIYOR": "red",
3271
3406
  "VERİ_YOK": "dim",
3407
+ "VERİ_YETERSİZ": "dim",
3408
+ "DÜŞÜK_TÜKETİM": "dim",
3272
3409
  }
3273
3410
 
3274
3411
 
@@ -3285,7 +3422,7 @@ _REACTIVE_PENALTY_STATUS_STYLE = {
3285
3422
  def reactive_penalty(
3286
3423
  device_id: str = typer.Argument(..., help="Device ID."),
3287
3424
  month: Optional[str] = typer.Option(None, "--month", help="YYYY-MM, defaults to the current calendar month."),
3288
- contracted_power_kva: Optional[float] = typer.Option(None, "--contracted-power-kva", help="Device's actual sözleşme gücü in kVA, if known - picks the correct EPDK tariff tier (<50 kVA: %33/%20, >=50 kVA: %20/%15). Assumed >=50 kVA (stricter) when omitted, since Qapu has no field for this."),
3425
+ contracted_power_kva: Optional[float] = typer.Option(None, "--contracted-power-kva", help="Sözleşme gücü in kVA - overrides the device's recorded Contracted_Power_kVA and picks the EPDK tariff tier (<50 kVA: %33/%20, >=50 kVA: %20/%15). With neither, >=50 kVA (stricter) is assumed."),
3289
3426
  as_json: bool = typer.Option(False, "--json", help="Print raw JSON instead of a human-readable summary."),
3290
3427
  ):
3291
3428
  """Month-to-date reactive/active energy ratio (tan φ) against the real distribution-company penalty threshold, with a recent-pace projection to month end (GET /hermes/reactive-penalty/{device_id})."""
@@ -7232,7 +7369,7 @@ def _build_fleet_status_group(devices: list[dict[str, Any]], live: bool, as_of:
7232
7369
  name = d.get("Name") or "-"
7233
7370
  online = _is_online(d)
7234
7371
  status_label = "[green]● Online[/green]" if online else "[red]● Offline[/red]"
7235
- last_connection = _elapsed_seconds_label(d.get("Update_Time")) if live else _relative_time(d.get("Update_Time"))
7372
+ last_connection = _elapsed_seconds_label(d.get("Last_Pack_Time")) if live else _relative_time(d.get("Last_Pack_Time"))
7236
7373
  table.add_row(device_id, name, status_label, last_connection)
7237
7374
 
7238
7375
  return Group(title, summary, table)
@@ -7246,7 +7383,7 @@ def fleet_status(
7246
7383
  interval: float = typer.Option(10.0, "--interval", help="Seconds between refreshes in --watch mode."),
7247
7384
  as_json: bool = typer.Option(False, "--json", help="Print raw JSON instead of the summary table. Not combinable with --watch."),
7248
7385
  ):
7249
- """Fleet-wide (or group/project-scoped) online/offline summary, by the same Update_Time heuristic `device list --status` uses (GET /hermes/devices)."""
7386
+ """Fleet-wide (or group/project-scoped) online/offline summary, by the last packet time, as `device list --status` uses (GET /hermes/devices)."""
7250
7387
 
7251
7388
  if as_json and watch:
7252
7389
  typer.echo("Error: --json ve --watch birlikte kullanılamaz.", err=True)
@@ -7673,6 +7810,26 @@ def fota_approvals(as_json: bool = typer.Option(False, "--json")):
7673
7810
  _print_paginated(items, _simple_table_builder([("VERSION", "Version"), ("APPROVED", "Approved"), ("CHANNEL", "Channel"), ("APPROVED_AT", "Approved_At"), ("REVOKED_AT", "Revoked_At"), ("NOTE", "Note")]), limit=None, noun="sürüm")
7674
7811
 
7675
7812
 
7813
+ @fota_app.command("reports")
7814
+ def fota_reports(
7815
+ device_id: Optional[str] = typer.Option(None, "--device"),
7816
+ report_status: Optional[str] = typer.Option(None, "--status", help="Success or Failure"),
7817
+ limit: int = typer.Option(50, "--limit"),
7818
+ as_json: bool = typer.Option(False, "--json"),
7819
+ ):
7820
+ """FOTA results devices reported after fotaftp/fotahttp, newest first (GET /hermes/firmware-reports)."""
7821
+ params: dict[str, Any] = {"limit": limit}
7822
+ if device_id:
7823
+ params["device_id"] = device_id
7824
+ if report_status:
7825
+ params["status"] = report_status
7826
+ items: list[dict[str, Any]] = client.get("/hermes/firmware-reports", params=params)
7827
+ if as_json:
7828
+ typer.echo(json.dumps(items, indent=2))
7829
+ return
7830
+ _print_paginated(items, _simple_table_builder([("DEVICE", "Device_ID"), ("COMMAND", "Command"), ("STATUS", "Status"), ("VERSION", "Version"), ("SECONDS", "Download_Seconds"), ("ERROR", "Error"), ("RECEIVED", "Received_At")]), limit=limit, noun="rapor")
7831
+
7832
+
7676
7833
  @fota_app.command("confirmations")
7677
7834
  def fota_confirmations(
7678
7835
  device_id: Optional[str] = typer.Option(None, "--device"),
@@ -8163,6 +8320,180 @@ def tui_command():
8163
8320
  run()
8164
8321
 
8165
8322
 
8323
+ # ------------------------------------------------------------
8324
+ # Notifications (2026-11-11, docs/NOTIFICATIONS.md) - Everything is off by
8325
+ # default: a user gets a notification only on channels turned on in their
8326
+ # preferences (scope type > category > severity, ordered list - app goes
8327
+ # alongside, the others are a fallback chain).
8328
+
8329
+ def _csv_channels(value: Optional[str]) -> Optional[list[str]]:
8330
+ if value is None:
8331
+ return None
8332
+ return [item.strip() for item in value.split(",") if item.strip()]
8333
+
8334
+
8335
+ def _settings_path(user_id: Optional[int]) -> str:
8336
+ return f"/hermes/users/{user_id}/notification-settings" if user_id is not None else "/hermes/me/notification-settings"
8337
+
8338
+
8339
+ @notification_app.command("types")
8340
+ def notification_types(all_types: bool = typer.Option(False, "--all", help="Include silent app data messages."), as_json: bool = typer.Option(False, "--json")):
8341
+ """List notification types with category, severity and channels (GET /hermes/notification-types)."""
8342
+ result = client.get("/hermes/notification-types", params={"visible_only": "false" if all_types else "true"})
8343
+ items = result.get("Items", [])
8344
+ if as_json:
8345
+ typer.echo(json.dumps(result, indent=2, ensure_ascii=False))
8346
+ return
8347
+ table = Table(show_lines=False)
8348
+ for column in ("ID", "AD", "KATEGORİ", "ÖNEM", "İZİNLİ KANALLAR", "VARSAYILAN", "SESSİZ SAAT", "BAŞLIK"):
8349
+ table.add_column(column)
8350
+ for item in items:
8351
+ table.add_row(str(item["ID"]), item["Name"], item["Category"], item["Severity"], ",".join(item["Allowed_Channels"]) or "-", ",".join(item["Default_Channels"]) or "-", "deler" if item["Bypass_Quiet_Hours"] else "-", item.get("Title") or "-")
8352
+ console.print(table)
8353
+
8354
+
8355
+ @notification_app.command("type-update")
8356
+ def notification_type_update(
8357
+ type_id: int = typer.Argument(...),
8358
+ category: Optional[str] = typer.Option(None, "--category"),
8359
+ severity: Optional[str] = typer.Option(None, "--severity", help="bilgi / uyari / kritik"),
8360
+ allowed: Optional[str] = typer.Option(None, "--allowed", help="Comma list, e.g. app,email,whatsapp,sms"),
8361
+ default: Optional[str] = typer.Option(None, "--default", help="Comma list (must fit inside --allowed); empty string = none"),
8362
+ user_can_disable: Optional[bool] = typer.Option(None, "--user-can-disable/--user-cannot-disable"),
8363
+ bypass_quiet_hours: Optional[bool] = typer.Option(None, "--bypass-quiet-hours/--respect-quiet-hours"),
8364
+ dedup_minutes: Optional[int] = typer.Option(None, "--dedup-minutes"),
8365
+ title: Optional[str] = typer.Option(None, "--title"),
8366
+ body_text: Optional[str] = typer.Option(None, "--body"),
8367
+ ):
8368
+ """Ovoo staff: change a notification type - only the options passed (PUT /hermes/notification-types/{id})."""
8369
+ body: dict[str, Any] = {}
8370
+ for key, value in (("Category", category), ("Severity", severity), ("Allowed_Channels", _csv_channels(allowed)), ("Default_Channels", _csv_channels(default)), ("User_Can_Disable", user_can_disable), ("Bypass_Quiet_Hours", bypass_quiet_hours), ("Dedup_Minutes", dedup_minutes), ("Title", title), ("Body", body_text)):
8371
+ if value is not None:
8372
+ body[key] = value
8373
+ if not body:
8374
+ typer.echo("Nothing to change.")
8375
+ raise typer.Exit(1)
8376
+ _print_detail(client.put(f"/hermes/notification-types/{type_id}", json_body=body))
8377
+
8378
+
8379
+ @notification_app.command("channels")
8380
+ def notification_channels(as_json: bool = typer.Option(False, "--json")):
8381
+ """Channel switches - off = nothing goes out on that channel (GET /hermes/notification-channels)."""
8382
+ items = client.get("/hermes/notification-channels")
8383
+ if as_json:
8384
+ typer.echo(json.dumps(items, indent=2, ensure_ascii=False))
8385
+ return
8386
+ table = Table()
8387
+ for column in ("KANAL", "DURUM", "GÖNDERİCİ", "NOT"):
8388
+ table.add_column(column)
8389
+ for item in items:
8390
+ table.add_row(item["Code"], "[green]AÇIK[/green]" if item["Enabled"] else "[red]KAPALI[/red]", "hazır" if item["Sender_Built"] else "yok", item.get("Note") or "")
8391
+ console.print(table)
8392
+
8393
+
8394
+ @notification_app.command("channel-set")
8395
+ def notification_channel_set(code: str = typer.Argument(..., help="app / email / whatsapp / sms"), enabled: bool = typer.Option(..., "--on/--off")):
8396
+ """Ovoo staff: switch a channel on/off platform-wide (PUT /hermes/notification-channels/{code})."""
8397
+ result = client.put(f"/hermes/notification-channels/{code}", json_body={"Enabled": enabled})
8398
+ typer.echo(f"{result.get('Code', code)}: {'AÇIK' if result.get('Enabled') else 'KAPALI'}")
8399
+
8400
+
8401
+ @notification_app.command("settings")
8402
+ def notification_settings(user_id: Optional[int] = typer.Option(None, "--user", help="Another user's settings (users:read); default = yours."), as_json: bool = typer.Option(False, "--json")):
8403
+ """Show notification settings - preferences, quiet hours, mutes, contacts (GET /hermes/me|users/{id}/notification-settings)."""
8404
+ result = client.get(_settings_path(user_id))
8405
+ if as_json:
8406
+ typer.echo(json.dumps(result, indent=2, ensure_ascii=False))
8407
+ return
8408
+ preferences = result.get("Preferences") or []
8409
+ if preferences:
8410
+ table = Table(title=f"Kullanıcı {result.get('User_ID')} - tercihler")
8411
+ for column in ("KAPSAM", "ANAHTAR", "KANALLAR (sırayla)"):
8412
+ table.add_column(column)
8413
+ for item in preferences:
8414
+ table.add_row(item["Scope"], item["Key"], " -> ".join(item["Channels"]) or "[red]kapalı[/red]")
8415
+ console.print(table)
8416
+ else:
8417
+ console.print("Tercih yok - [yellow]hiçbir bildirim gönderilmez[/yellow] (varsayılan her şey kapalı).")
8418
+ quiet = result.get("Quiet_Hours")
8419
+ contacts = result.get("Contacts") or {}
8420
+ console.print(f"Sessiz saat: {quiet['Start'] + '-' + quiet['End'] if quiet else '-'} Sessize alındı: {_format_time(result.get('Mute_Until')) if result.get('Mute_Until') else '-'} Sessiz cihazlar: {', '.join(result.get('Muted_Devices') or []) or '-'}")
8421
+ console.print(f"İletişim: telefon(uygulama) {len(contacts.get('App') or [])}, e-posta {contacts.get('Email') or '-'}, telefon {contacts.get('Phone') or '-'} Ulaşılabilir: {', '.join(contacts.get('Reachable') or []) or '-'}")
8422
+
8423
+
8424
+ @notification_app.command("set")
8425
+ def notification_set(
8426
+ user_id: Optional[int] = typer.Option(None, "--user", help="Another user's settings (users:write); default = yours."),
8427
+ severity: Optional[str] = typer.Option(None, "--severity", help="bilgi / uyari / kritik"),
8428
+ category: Optional[str] = typer.Option(None, "--category"),
8429
+ type_id: Optional[int] = typer.Option(None, "--type"),
8430
+ channels: Optional[str] = typer.Option(None, "--channels", help="Ordered comma list for the chosen scope, e.g. whatsapp,sms,app; 'off' = turn it off; 'clear' = remove the preference."),
8431
+ quiet: Optional[str] = typer.Option(None, "--quiet", help="Quiet hours HH:MM-HH:MM (local); 'off' removes them."),
8432
+ mute_until: Optional[str] = typer.Option(None, "--mute-until", help="ISO date-time (local if no zone); 'off' unmutes."),
8433
+ mute_device: Optional[list[str]] = typer.Option(None, "--mute-device"),
8434
+ unmute_device: Optional[list[str]] = typer.Option(None, "--unmute-device"),
8435
+ ):
8436
+ """Change notification settings - merges into the current ones (PUT /hermes/me|users/{id}/notification-settings)."""
8437
+ path = _settings_path(user_id)
8438
+ current = client.get(path)
8439
+ body: dict[str, Any] = {}
8440
+ scopes = [(name, key) for name, key in (("severity", severity), ("category", category), ("type", str(type_id) if type_id is not None else None)) if key is not None]
8441
+ if scopes or channels is not None:
8442
+ if len(scopes) != 1 or channels is None:
8443
+ typer.echo("Give exactly one of --severity/--category/--type together with --channels.")
8444
+ raise typer.Exit(1)
8445
+ scope, key = scopes[0]
8446
+ preferences = [item for item in current.get("Preferences") or [] if not (item["Scope"] == scope and item["Key"] == key)]
8447
+ if channels != "clear":
8448
+ preferences.append({"Scope": scope, "Key": key, "Channels": [] if channels == "off" else _csv_channels(channels)})
8449
+ body["Preferences"] = [{"Scope": item["Scope"], "Key": item["Key"], "Channels": item["Channels"]} for item in preferences]
8450
+ if quiet is not None:
8451
+ if quiet == "off":
8452
+ body["Quiet_Hours"] = None
8453
+ else:
8454
+ start, _, end = quiet.partition("-")
8455
+ body["Quiet_Hours"] = {"Start": start.strip(), "End": end.strip()}
8456
+ if mute_until is not None:
8457
+ body["Mute_Until"] = None if mute_until == "off" else mute_until
8458
+ if mute_device or unmute_device:
8459
+ muted = set(current.get("Muted_Devices") or []) | set(mute_device or [])
8460
+ body["Muted_Devices"] = sorted(muted - set(unmute_device or []))
8461
+ if not body:
8462
+ typer.echo("Nothing to change.")
8463
+ raise typer.Exit(1)
8464
+ client.put(path, json_body=body)
8465
+ notification_settings(user_id=user_id, as_json=False)
8466
+
8467
+
8468
+ @notification_app.command("log")
8469
+ def notification_log(
8470
+ user_id: Optional[int] = typer.Option(None, "--user", help="One user's log (staff, notifications:read)."),
8471
+ everyone: bool = typer.Option(False, "--all", help="Every user's log (staff, notifications:read)."),
8472
+ device_id: Optional[str] = typer.Option(None, "--device"),
8473
+ channel: Optional[str] = typer.Option(None, "--channel"),
8474
+ status: Optional[str] = typer.Option(None, "--status", help="SENT / DELIVERED / READ / FAILED / SKIPPED"),
8475
+ limit: int = typer.Option(50, "--limit"),
8476
+ as_json: bool = typer.Option(False, "--json"),
8477
+ ):
8478
+ """Delivery log, newest first - yours by default (GET /hermes/me/notifications or /hermes/notifications/deliveries)."""
8479
+ params = {key: value for key, value in (("device_id", device_id), ("channel", channel), ("status", status), ("limit", limit)) if value is not None}
8480
+ if user_id is not None or everyone:
8481
+ if user_id is not None:
8482
+ params["user_id"] = user_id
8483
+ result = client.get("/hermes/notifications/deliveries", params=params)
8484
+ else:
8485
+ result = client.get("/hermes/me/notifications", params=params)
8486
+ if as_json:
8487
+ typer.echo(json.dumps(result, indent=2, ensure_ascii=False))
8488
+ return
8489
+ table = Table(title=f"{result.get('Total', 0)} kayıt")
8490
+ for column in ("ZAMAN", "KULLANICI", "CİHAZ", "TÜR", "KANAL", "DURUM", "NEDEN"):
8491
+ table.add_column(column)
8492
+ for item in result.get("Items", []):
8493
+ table.add_row(_format_time(item.get("Create_Time")), item.get("User_Name") or str(item.get("User_ID")), item.get("Device_ID") or "-", item.get("Type_Name") or str(item.get("Type_ID")), item["Channel"], item["Status"], item.get("Reason") or "")
8494
+ console.print(table)
8495
+
8496
+
8166
8497
  # Dynamic Per-Command Visibility (Permission System v2, 2026-10-10) - Must
8167
8498
  # Run AFTER Every @app.command()/add_typer() Above has Registered, so
8168
8499
  # Every CommandInfo/TyperInfo Actually Exists to Mutate. See visibility.py's
@@ -0,0 +1,123 @@
1
+ # `qapu login --browser` (2026-10-29, SSO Phase 3, docs/SSO.md) - Log in on
2
+ # auth.ovoo.com.tr's own Page Instead of Typing the Password Into the
3
+ # Terminal: Authorization Code + PKCE as the First-Party Client qapu-cli,
4
+ # With the Code Coming Back to a one-Shot Listener on a Random 127.0.0.1
5
+ # Port (RFC 8252 - Native Apps; auth Accepts any Port for a Registered
6
+ # Loopback URI). An SSO Session Already Open in the Browser Means no
7
+ # Password at all.
8
+
9
+ import base64
10
+ import hashlib
11
+ import secrets
12
+ import time
13
+ import webbrowser
14
+ from http.server import BaseHTTPRequestHandler, HTTPServer
15
+ from typing import Any, Callable, Optional
16
+ from urllib.parse import parse_qs, urlencode, urlsplit
17
+
18
+ import httpx
19
+
20
+ from qapu_cli import client
21
+
22
+ CLIENT_ID = "qapu-cli"
23
+ CALLBACK_PATH = "/callback"
24
+ WAIT_SECONDS = 300
25
+
26
+ _DONE_PAGE = """<!doctype html><html lang="tr"><meta charset="utf-8"><title>qapu</title>
27
+ <body style="font:15px system-ui,sans-serif;display:grid;place-items:center;min-height:90vh">
28
+ <p>{message}</p></body></html>"""
29
+
30
+
31
+ def _pkce() -> tuple[str, str]:
32
+ verifier = secrets.token_urlsafe(64)
33
+ challenge = base64.urlsafe_b64encode(hashlib.sha256(verifier.encode("ascii")).digest()).rstrip(b"=").decode("ascii")
34
+ return verifier, challenge
35
+
36
+
37
+ class _Callback(BaseHTTPRequestHandler):
38
+ result: Optional[dict[str, str]] = None
39
+
40
+ def do_GET(self) -> None:
41
+ parts = urlsplit(self.path)
42
+ if parts.path != CALLBACK_PATH:
43
+ self.send_response(404)
44
+ self.end_headers()
45
+ return
46
+ type(self).result = {key: values[0] for key, values in parse_qs(parts.query).items()}
47
+ message = "Giriş tamamlandı, terminale dönebilirsiniz." if "code" in type(self).result else "Giriş tamamlanamadı, terminale bakın."
48
+ body = _DONE_PAGE.format(message=message).encode("utf-8")
49
+ self.send_response(200)
50
+ self.send_header("Content-Type", "text/html; charset=utf-8")
51
+ self.send_header("Content-Length", str(len(body)))
52
+ self.end_headers()
53
+ self.wfile.write(body)
54
+
55
+ def log_message(self, *args: Any) -> None:
56
+ return
57
+
58
+
59
+ # Printed the Same way as Every Other CLI Error, Then Raised
60
+ def _fail(message: str) -> client.ClientError:
61
+ client._print_error("Giriş Hatası", [message])
62
+ return client.ClientError(message)
63
+
64
+
65
+ def _wait_for_callback(server: HTTPServer, seconds: int) -> Optional[dict[str, str]]:
66
+ deadline = time.monotonic() + seconds
67
+ server.timeout = 1
68
+ while _Callback.result is None and time.monotonic() < deadline:
69
+ server.handle_request()
70
+ return _Callback.result
71
+
72
+
73
+ # Returns the Token Response {access_token, refresh_token, expires_in, scope}
74
+ def browser_login(open_browser: Callable[[str], Any] = webbrowser.open, echo: Callable[[str], Any] = print, wait_seconds: int = WAIT_SECONDS) -> dict[str, Any]:
75
+ auth = client._auth_base_url()
76
+ verifier, challenge = _pkce()
77
+ state = secrets.token_urlsafe(16)
78
+ _Callback.result = None
79
+ server = HTTPServer(("127.0.0.1", 0), _Callback)
80
+ try:
81
+ redirect_uri = f"http://127.0.0.1:{server.server_port}{CALLBACK_PATH}"
82
+ url = f"{auth}/oauth/authorize?" + urlencode({
83
+ "response_type": "code", "client_id": CLIENT_ID, "redirect_uri": redirect_uri,
84
+ "code_challenge": challenge, "code_challenge_method": "S256", "state": state,
85
+ })
86
+ echo(f"Tarayıcıda giriş sayfası açılıyor. Açılmazsa bu adresi açın:\n{url}")
87
+ open_browser(url)
88
+ result = _wait_for_callback(server, wait_seconds)
89
+ finally:
90
+ server.server_close()
91
+ if result is None:
92
+ raise _fail("Giriş zaman aşımına uğradı (5 dakika). Tekrar deneyin.")
93
+ if result.get("state") != state:
94
+ raise _fail("Giriş yanıtı bu isteğe ait değil (state uyuşmuyor). Tekrar deneyin.")
95
+ if "code" not in result:
96
+ raise _fail(f"Giriş reddedildi: {result.get('error_description') or result.get('error') or 'bilinmeyen hata'}")
97
+ try:
98
+ response = httpx.post(f"{auth}/oauth/token", data={
99
+ "grant_type": "authorization_code", "client_id": CLIENT_ID, "code": result["code"],
100
+ "redirect_uri": redirect_uri, "code_verifier": verifier,
101
+ }, timeout=client.REQUEST_TIMEOUT)
102
+ response.raise_for_status()
103
+ return response.json()
104
+ except httpx.HTTPStatusError as e:
105
+ raise client.ClientError(client._report_http_status_error(e, "POST", f"{auth}/oauth/token"))
106
+ except httpx.RequestError as e:
107
+ raise client.ClientError(client._report_request_error(e, "POST", f"{auth}/oauth/token"))
108
+
109
+
110
+ def me(access_token: str) -> dict[str, Any]:
111
+ response = httpx.get(f"{client._auth_base_url()}/auth/me", headers={"Authorization": f"Bearer {access_token}"}, timeout=client.REQUEST_TIMEOUT)
112
+ response.raise_for_status()
113
+ return response.json()
114
+
115
+
116
+ # The CLI Keeps Only its Hermes API Token; the Refresh Token is not Needed
117
+ def revoke(refresh_token: Optional[str]) -> None:
118
+ if not refresh_token:
119
+ return
120
+ try:
121
+ httpx.post(f"{client._auth_base_url()}/oauth/revoke", data={"client_id": CLIENT_ID, "token": refresh_token}, timeout=client.REQUEST_TIMEOUT)
122
+ except httpx.RequestError:
123
+ pass
@@ -95,18 +95,25 @@ def fetch_raw_packets(device_id: str) -> tuple[Optional[list[dict[str, Any]]], O
95
95
  # Silent Swallow (not _detail()-Routed) - This is a Best-Effort, Never-
96
96
  # User-Visible-as-an-Error Cache Fill, Same as fetch_score_detail()'s own
97
97
  # reactive_penalty Fetch Above.
98
- _REGISTER_STRUCTURE_CACHE: dict[int, list[dict[str, Any]]] = {}
98
+ #
99
+ # Resolved per System Type (2026-11-09): since a bit can have one row per
100
+ # type (e.g. PUMP on bit 0 for both Pompa and Tarım), the project-wide list
101
+ # may hold several rows for one bit - asking with the device's own
102
+ # system_type_id returns exactly its rows plus the universal ones.
103
+ _REGISTER_STRUCTURE_CACHE: dict[tuple[int, Optional[int]], list[dict[str, Any]]] = {}
99
104
 
100
105
 
101
- def fetch_register_structure(project_id: Optional[int]) -> list[dict[str, Any]]:
106
+ def fetch_register_structure(project_id: Optional[int], system_type_id: Optional[int] = None) -> list[dict[str, Any]]:
102
107
  if project_id is None:
103
108
  return []
104
- if project_id not in _REGISTER_STRUCTURE_CACHE:
109
+ key = (project_id, system_type_id)
110
+ if key not in _REGISTER_STRUCTURE_CACHE:
111
+ query = f"?system_type_id={system_type_id}" if system_type_id is not None else ""
105
112
  try:
106
- _REGISTER_STRUCTURE_CACHE[project_id] = client.get(f"/hermes/register-structure/{project_id}") or []
113
+ _REGISTER_STRUCTURE_CACHE[key] = client.get(f"/hermes/register-structure/{project_id}{query}") or []
107
114
  except SystemExit:
108
115
  return []
109
- return _REGISTER_STRUCTURE_CACHE[project_id]
116
+ return _REGISTER_STRUCTURE_CACHE[key]
110
117
 
111
118
 
112
119
  def fetch_raw_packet_detail(raw_id: int) -> tuple[Optional[dict[str, Any]], Optional[str]]:
@@ -118,8 +118,10 @@ class DeviceDashboardScreen(Screen):
118
118
  # rendering.status_section() Itself - That Module's own Section
119
119
  # Builders Are Pure Renders of an Already-Fetched Payload, Never
120
120
  # Their own HTTP Calls (See tui/data.py's Threading Rule).
121
- project_id = ((payload.get("device") or {}).get("Project") or {}).get("ID")
122
- payload["bit_definitions"] = tui_data.fetch_register_structure(project_id)
121
+ device = payload.get("device") or {}
122
+ project_id = (device.get("Project") or {}).get("ID")
123
+ system_type_id = (device.get("System_Type") or {}).get("ID")
124
+ payload["bit_definitions"] = tui_data.fetch_register_structure(project_id, system_type_id)
123
125
  self.app.call_from_thread(self._apply_result, payload, error)
124
126
 
125
127
  def _apply_result(self, payload: Optional[dict[str, Any]], error: Optional[str]) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qapu-cli
3
- Version: 0.80.0
3
+ Version: 0.83.0
4
4
  Summary: CLI client for the Qapu API - built for the Hermes agent, but usable by anyone talking to api.ovoo.com.tr from outside the Swarm.
5
5
  Author: OVOO Technology
6
6
  Classifier: Programming Language :: Python :: 3
@@ -67,7 +67,7 @@ Either way installs a `qapu` command (see `pyproject.toml`'s `[project.scripts]`
67
67
  | `qapu data` | Readings per variable for a device - latest value, last N buffered readings (--last), daily min/avg/max (--days), an explicit --start/--end range, or a live-refreshed view (--watch) (GET /hermes/data/{device_id}). |
68
68
  | `qapu energy` | One day's active/reactive energy breakdown per phase, or --days/--start/--end for a per-day breakdown plus a cumulative Total (GET /hermes/energy/{device_id}). |
69
69
  | `qapu health` | Check CLI/server version, connectivity, and server status (GET /health, no auth required). |
70
- | `qapu login` | Log in and save a Bearer JWT locally for `auth-token *` - `qapu login [username]` (operator/CLI, Username+Password, POST /auth/login/cli) is the **default**, prompting for whatever wasn't given, password always hidden, never a CLI flag. `qapu login --phone <number>` (mobile-app Phone+Pin, POST /auth/login) is an explicit opt-in, never mixed with a username. |
70
+ | `qapu login` | Log in and save a Bearer JWT locally for `auth-token *` - `qapu login [username]` (operator/CLI, Username+Password, POST /auth/login/cli) is the **default**, prompting for whatever wasn't given, password always hidden, never a CLI flag. `qapu login --phone <number>` (mobile-app Phone+Pin, POST /auth/login) is an explicit opt-in, never mixed with a username. `qapu login --browser` logs in on auth.ovoo.com.tr's own page (SSO; no password at all when the browser is already logged in), needs a browser on this machine. |
71
71
  | `qapu logout` | Clear the locally saved Bearer JWT (client-side only) - does **not** clear a saved Hermes API token, see "Auth" below. |
72
72
  | `qapu whoami` | Show the currently logged-in account, from the locally saved credentials. |
73
73
  | `qapu pipeline` | Fleet-wide pipeline throughput for a time window - ingest/data/rule/blockchain packet+event counts (GET /hermes/pipeline/stats). `--watch` live-refreshes in place. |
@@ -85,6 +85,7 @@ Either way installs a `qapu` command (see `pyproject.toml`'s `[project.scripts]`
85
85
  | `qapu device list` | List every device Qapu knows about (GET /hermes/devices). |
86
86
  | `qapu device reliability` | Analyze a device's periodic packet delivery over a time window - total/expected packets, delivery rate, average/min/max interval, estimated missed packets, longest gap (GET /hermes/reliability/{device_id}). |
87
87
  | `qapu score list` | List recent Cinga Score snapshot rows, optionally filtered by device/window type (GET /hermes/scores). |
88
+ | `qapu score fleet-summary --device-ids A,B,C [--window-type ...] [--json]` | Latest four cards per device, worst card first, with the change since the window start (GET /hermes/scores/fleet-summary). |
88
89
  | `qapu score get` | Single snapshot detail (GET /hermes/scores/{score_id}). |
89
90
  | `qapu score bundle` | The AI-facing structured packet for one snapshot (GET /hermes/scores/{score_id}/bundle). |
90
91
  | `qapu score revisions` | Every revision (ACTIVE/SUPERSEDED) of the same logical period (GET /hermes/scores/{score_id}/revisions). |
@@ -99,6 +100,7 @@ Either way installs a `qapu` command (see `pyproject.toml`'s `[project.scripts]`
99
100
  |---|---|
100
101
  | `qapu variable get` | Get one variable's detail (GET /hermes/variables/{variable_id}). |
101
102
  | `qapu variable list` | List the variable catalog (GET /hermes/variables). |
103
+ | `qapu variable stats` | Stored readings per variable - typed table, reading/device counts, first/last time, last 24 h; `--segment`, `--stored-only` (GET /hermes/variables/stats, recomputed hourly by services/windows). |
102
104
 
103
105
  #### `group` - device groups
104
106
 
@@ -4,6 +4,7 @@ qapu_cli/__init__.py
4
4
  qapu_cli/client.py
5
5
  qapu_cli/command_packages.py
6
6
  qapu_cli/main.py
7
+ qapu_cli/sso_login.py
7
8
  qapu_cli/visibility.py
8
9
  qapu_cli.egg-info/PKG-INFO
9
10
  qapu_cli.egg-info/SOURCES.txt
@@ -35,6 +36,7 @@ qapu_cli/tui/widgets/device_table.py
35
36
  tests/test_command_packages_complete.py
36
37
  tests/test_login.py
37
38
  tests/test_logout.py
39
+ tests/test_sso_login.py
38
40
  tests/test_tui_authorization.py
39
41
  tests/test_tui_catalog.py
40
42
  tests/test_tui_device_edit.py
@@ -0,0 +1,44 @@
1
+ # `qapu login --browser` (2026-10-29): the Loopback Code Flow, With the
2
+ # "Browser" Played by a Thread That Follows the Authorize URL's redirect_uri
3
+
4
+ import threading
5
+ from unittest.mock import MagicMock, patch
6
+ from urllib.parse import parse_qs, urlencode, urlsplit
7
+
8
+ import httpx
9
+ import pytest
10
+
11
+ from qapu_cli import client, sso_login
12
+
13
+
14
+ def _browser(**answer):
15
+ seen = {}
16
+
17
+ def open_browser(url):
18
+ query = {key: values[0] for key, values in parse_qs(urlsplit(url).query).items()}
19
+ seen.update(query)
20
+ params = {**answer}
21
+ if "state" not in params:
22
+ params["state"] = query["state"]
23
+ threading.Thread(target=lambda: httpx.get(f"{query['redirect_uri']}?{urlencode(params)}", timeout=5)).start()
24
+ return open_browser, seen
25
+
26
+
27
+ def test_the_code_comes_back_to_the_loopback_and_is_exchanged():
28
+ open_browser, seen = _browser(code="CODE")
29
+ token = MagicMock(json=MagicMock(return_value={"access_token": "A", "refresh_token": "R"}), raise_for_status=MagicMock())
30
+ with patch.object(sso_login.httpx, "post", return_value=token) as post:
31
+ assert sso_login.browser_login(open_browser=open_browser, echo=lambda _: None, wait_seconds=10) == {"access_token": "A", "refresh_token": "R"}
32
+ assert seen["client_id"] == "qapu-cli" and seen["code_challenge_method"] == "S256" and seen["redirect_uri"].startswith("http://127.0.0.1:")
33
+ form = post.call_args.kwargs["data"]
34
+ assert form["code"] == "CODE" and form["redirect_uri"] == seen["redirect_uri"] and len(form["code_verifier"]) >= 43
35
+
36
+
37
+ def test_a_foreign_state_or_a_refusal_is_not_accepted():
38
+ open_browser, _ = _browser(code="CODE", state="someone-else")
39
+ with pytest.raises(client.ClientError) as foreign:
40
+ sso_login.browser_login(open_browser=open_browser, echo=lambda _: None, wait_seconds=10)
41
+ open_browser, _ = _browser(error="access_denied", error_description="The user denied access.")
42
+ with pytest.raises(client.ClientError) as refused:
43
+ sso_login.browser_login(open_browser=open_browser, echo=lambda _: None, wait_seconds=10)
44
+ assert "state" in foreign.value.message and "denied" in refused.value.message
@@ -46,7 +46,7 @@ async def test_app_launches_and_lists_devices(monkeypatch, fake_devices):
46
46
  async def test_enter_pushes_dashboard(monkeypatch, fake_devices, fake_dashboard_data):
47
47
  monkeypatch.setattr("qapu_cli.tui.data.fetch_devices", lambda: (fake_devices, None))
48
48
  monkeypatch.setattr("qapu_cli.tui.data.fetch_dashboard", lambda device_id: (fake_dashboard_data, None))
49
- monkeypatch.setattr("qapu_cli.tui.data.fetch_register_structure", lambda project_id: [])
49
+ monkeypatch.setattr("qapu_cli.tui.data.fetch_register_structure", lambda project_id, system_type_id=None: [])
50
50
  app = QapuTUIApp()
51
51
  async with app.run_test() as pilot:
52
52
  await pilot.pause()
@@ -63,7 +63,7 @@ async def test_dashboard_renders_default_section_without_exceptions(monkeypatch,
63
63
  # Network Call During the Test.
64
64
  monkeypatch.setattr("qapu_cli.tui.data.fetch_devices", lambda: (fake_devices, None))
65
65
  monkeypatch.setattr("qapu_cli.tui.data.fetch_dashboard", lambda device_id: (fake_dashboard_data, None))
66
- monkeypatch.setattr("qapu_cli.tui.data.fetch_register_structure", lambda project_id: [])
66
+ monkeypatch.setattr("qapu_cli.tui.data.fetch_register_structure", lambda project_id, system_type_id=None: [])
67
67
  app = QapuTUIApp()
68
68
  async with app.run_test() as pilot:
69
69
  await app.push_screen(DeviceDashboardScreen("TEST-DEVICE-1"))
@@ -79,7 +79,7 @@ async def test_dashboard_renders_default_section_without_exceptions(monkeypatch,
79
79
  async def test_menu_selection_switches_content(monkeypatch, fake_devices, fake_dashboard_data):
80
80
  monkeypatch.setattr("qapu_cli.tui.data.fetch_devices", lambda: (fake_devices, None))
81
81
  monkeypatch.setattr("qapu_cli.tui.data.fetch_dashboard", lambda device_id: (fake_dashboard_data, None))
82
- monkeypatch.setattr("qapu_cli.tui.data.fetch_register_structure", lambda project_id: [])
82
+ monkeypatch.setattr("qapu_cli.tui.data.fetch_register_structure", lambda project_id, system_type_id=None: [])
83
83
  app = QapuTUIApp()
84
84
  async with app.run_test() as pilot:
85
85
  await app.push_screen(DeviceDashboardScreen("TEST-DEVICE-1"))
@@ -96,7 +96,7 @@ async def test_menu_selection_switches_content(monkeypatch, fake_devices, fake_d
96
96
  async def test_stream_section_lazy_fetches_on_selection(monkeypatch, fake_devices, fake_dashboard_data):
97
97
  monkeypatch.setattr("qapu_cli.tui.data.fetch_devices", lambda: (fake_devices, None))
98
98
  monkeypatch.setattr("qapu_cli.tui.data.fetch_dashboard", lambda device_id: (fake_dashboard_data, None))
99
- monkeypatch.setattr("qapu_cli.tui.data.fetch_register_structure", lambda project_id: [])
99
+ monkeypatch.setattr("qapu_cli.tui.data.fetch_register_structure", lambda project_id, system_type_id=None: [])
100
100
  fake_streams = [{"ID": 1, "IP": "1.2.3.4", "ICCID": "890000", "Size": 128, "Process_Time": 0.05, "Device_Time": "2026-09-21T10:00:00", "Stream_Time": "2026-09-21T10:00:00"}]
101
101
  monkeypatch.setattr("qapu_cli.tui.data.fetch_streams", lambda device_id: (fake_streams, None))
102
102
  app = QapuTUIApp()
@@ -114,7 +114,7 @@ async def test_stream_section_lazy_fetches_on_selection(monkeypatch, fake_device
114
114
  async def test_fetch_failure_shows_notification_not_crash(monkeypatch, fake_devices):
115
115
  monkeypatch.setattr("qapu_cli.tui.data.fetch_devices", lambda: (fake_devices, None))
116
116
  monkeypatch.setattr("qapu_cli.tui.data.fetch_dashboard", lambda device_id: (None, "boom"))
117
- monkeypatch.setattr("qapu_cli.tui.data.fetch_register_structure", lambda project_id: [])
117
+ monkeypatch.setattr("qapu_cli.tui.data.fetch_register_structure", lambda project_id, system_type_id=None: [])
118
118
  app = QapuTUIApp()
119
119
  async with app.run_test() as pilot:
120
120
  await app.push_screen(DeviceDashboardScreen("TEST-DEVICE-1"))
@@ -143,7 +143,7 @@ async def test_q_quits_from_device_list(monkeypatch, fake_devices):
143
143
  async def test_q_quits_from_dashboard(monkeypatch, fake_devices, fake_dashboard_data):
144
144
  monkeypatch.setattr("qapu_cli.tui.data.fetch_devices", lambda: (fake_devices, None))
145
145
  monkeypatch.setattr("qapu_cli.tui.data.fetch_dashboard", lambda device_id: (fake_dashboard_data, None))
146
- monkeypatch.setattr("qapu_cli.tui.data.fetch_register_structure", lambda project_id: [])
146
+ monkeypatch.setattr("qapu_cli.tui.data.fetch_register_structure", lambda project_id, system_type_id=None: [])
147
147
  app = QapuTUIApp()
148
148
  async with app.run_test() as pilot:
149
149
  await app.push_screen(DeviceDashboardScreen("TEST-DEVICE-1"))
File without changes
File without changes
File without changes
File without changes