homebridge-quickline-tv 0.0.0-stage → 1.3.4

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,69 @@
1
+ # Changelog
2
+
3
+ ## 1.3.4
4
+ - Erste Version über die automatische Veröffentlichung (npm Trusted Publishing).
5
+ - README: Installation über die Homebridge-Plugin-Suche.
6
+ - Anleitung und Werkzeuge verwenden Platzhalter statt Beispiel-IPs.
7
+
8
+ ## 1.3.3
9
+ - Neue Option „Alle getesteten Apps“ (`"apps": ["all"]`).
10
+
11
+ ## 1.3.2
12
+ - Play Suisse im App-Katalog (`https://www.playsuisse.ch/de/show`).
13
+ - README: ADB-Anleitung zeigt auch die Pfade, die manche Apps verlangen.
14
+
15
+ ## 1.3.1
16
+ - KiKA im App-Katalog (`ardkika://kika.de/`, mit dem Link-Finder gefunden).
17
+ - Link-Finder probiert zusätzlich Links mit Adresse und Schrägstrich (z.B. `name://name.ch/`).
18
+
19
+ ## 1.3.0
20
+ - App-Katalog: Apps in den Einstellungen anhaken statt Links abtippen (Netflix, YouTube, Prime Video, Play SRF, Sky, ZDFtivi, Toggo; ungetestet: Disney+, Spotify, Plex).
21
+ - Eingang „Quickline“ ist immer dabei.
22
+ - Neues Werkzeug `bin/find-link.js`: findet den Deep Link einer App automatisch.
23
+ - README mit Anleitung „Neue App hinzufügen“ und GitHub-Vorlagen für App-Meldungen und Fehler.
24
+
25
+ ## 1.2.1
26
+ - Test-Werkzeug: `wait <Sekunden>` für langsam startende Apps.
27
+
28
+ ## 1.2.0
29
+ - Eingang „Quickline“ öffnet die Quickline-App direkt über `content://ch.quickline.tv.uhd` (per ADB aus der App ausgelesen).
30
+ - Senderwahl öffnet zuerst Quickline und tippt dann die Sendernummer.
31
+
32
+ ## 1.1.4
33
+ - Tasten mit Codes ausserhalb der offiziellen Android-Liste können gesendet werden (Betreiber-Tasten).
34
+
35
+ ## 1.1.3
36
+ - Test-Werkzeug: Suchlauf `scan` findet den Tastencode, der Quickline öffnet.
37
+ - Tastennamen DIGIT_1 bis DIGIT_9.
38
+
39
+ ## 1.1.2
40
+ - Eingang „Live TV“ heisst jetzt „Quickline“.
41
+ - Neues Test-Werkzeug `bin/send.js`, um Tasten und App-Links direkt an die Box zu schicken.
42
+ - Weitere Tastennamen: ESCAPE, LAST_CHANNEL, TV_INPUT, DVR, LIVE_TV.
43
+
44
+ ## 1.1.1
45
+ - Apps starten über Deep Links (`https://www.youtube.com`, `https://www.netflix.com/title`) statt über Play-Store-Links; die Quickline-Box trennt bei `market://`-Links die Verbindung.
46
+ - Live TV nutzt standardmässig die TV-Taste und wird an der Quickline-App erkannt.
47
+
48
+ ## 1.1.0
49
+ - Eigene, robuste Verbindung zur Box statt der Verbindung aus `androidtv-remote`:
50
+ - mehrere oder lange Nachrichten pro Datenpaket werden korrekt verarbeitet (vorher blieb die Verbindung hängen)
51
+ - Fehlermeldungen der Box oder unlesbare Pakete bringen die Child Bridge nicht mehr zum Absturz
52
+ - genau eine Verbindung mit automatischem Wiederverbinden
53
+ - `androidtv-remote` wird nur noch für die Kopplung verwendet.
54
+
55
+ ## 1.0.3
56
+ - Unvollständige Eingänge aus der Konfiguration werden ignoriert; bleibt keiner übrig, gelten die Standard-Eingänge.
57
+ - Eingänge werden beim Start im Log aufgelistet.
58
+
59
+ ## 1.0.2
60
+ - „TV-Einstellungen anzeigen“ öffnet die Einstellungen der Box.
61
+ - Eingänge lassen sich in der Home-App ein- und ausblenden.
62
+ - Ein/Aus-Zustand der Box wird im Log angezeigt.
63
+
64
+ ## 1.0.1
65
+ - Live TV startet direkt die Quickline-App (`ch.quickline.tv.uhd`) und wird in Apple Home als aktiver Eingang erkannt.
66
+ - Senderwahl öffnet Live TV nur, wenn es nicht schon läuft.
67
+
68
+ ## 1.0.0
69
+ - Erste Version: Ein/Aus, Eingänge (Live TV, Apps, Lieblingssender), Fernbedienung, Lautstärke/Stumm.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 homebridge-quickline-tv contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,145 @@
1
- # Temporary Holding Version
1
+ # homebridge-quickline-tv
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Bringt die **Quickline TV-Box** (Android TV, Sagemcom M387_QL) als TV-Gerät in Apple Home:
4
+
5
+ - Ein/Aus, auch in Szenen und Automationen
6
+ - Eingänge: **Quickline** (Live TV), **Apps** aus einem Katalog zum Anhaken und **Lieblingssender** per Sendernummer
7
+ - Fernbedienung im iPhone-Kontrollzentrum (Pfeile, OK, Zurück, Play/Pause, Info)
8
+ - Lautstärke und Stummschalten über die Lautstärketasten des iPhones
9
+ - Sender hoch/runter über die Vor-/Zurück-Tasten der Fernbedienung im Kontrollzentrum
10
+
11
+ Das Plugin spricht das **Android-TV-Remote-Protokoll**, wie die Google-TV-App auf dem Handy.
12
+ Auf der Box muss dafür nichts freigeschaltet werden.
13
+
14
+ ## Voraussetzungen
15
+
16
+ - Quickline TV-Box mit Android TV (getestet mit der Sagemcom M387_QL)
17
+ - Homebridge 1.6 oder neuer (auch 2.x), Node.js 18.15 oder neuer
18
+ - Box und Homebridge im selben Netzwerk
19
+ - Eine feste IP-Adresse für die Box (im Router reservieren)
20
+
21
+ ## Installation
22
+
23
+ In der Homebridge-Oberfläche unter **Plugins** nach **„Quickline“** suchen und **homebridge-quickline-tv** installieren.
24
+
25
+ Oder im Terminal:
26
+
27
+ ```bash
28
+ # Homebridge-Docker / Raspberry-Pi-Image (Homebridge-Terminal)
29
+ hb-service add homebridge-quickline-tv
30
+ # sonst
31
+ sudo npm install -g homebridge-quickline-tv
32
+ ```
33
+
34
+ ## Einrichten
35
+
36
+ In den Befehlen unten steht `<IP-der-Box>` für die IP-Adresse deiner Quickline-Box, zum Beispiel `192.168.1.100`.
37
+ Ersetze den Platzhalter samt spitzen Klammern durch deine Adresse.
38
+
39
+ 1. **Plugin konfigurieren:** In den Plugin-Einstellungen eine Box hinzufügen, Name und IP-Adresse eintragen,
40
+ Apps anhaken und auf Wunsch Lieblingssender eintragen. Speichern und Homebridge neu starten.
41
+ 2. **Koppeln (einmalig):** Fernseher und Box einschalten. Im Homebridge-Log steht ein Befehl wie
42
+ ```bash
43
+ node "/homebridge/node_modules/homebridge-quickline-tv/bin/pair.js" <IP-der-Box> "/var/lib/homebridge/quickline-tv"
44
+ ```
45
+ Diesen im Homebridge-Terminal ausführen und den Code eingeben, der auf dem Fernseher erscheint.
46
+ Homebridge verbindet sich danach innert ca. 10 Sekunden von selbst.
47
+ 3. **In Apple Home hinzufügen:** Home-App → **+** → *Gerät hinzufügen* → *Weitere Optionen…* →
48
+ das Gerät mit dem **Fernseher-Symbol** wählen. Der Code dafür steht im Log in der Zeile
49
+ `Please add [… ] manually in Home app. Setup Code: …`.
50
+ Läuft das Plugin als Child Bridge, erscheint ein zweiter Eintrag mit Punkte-Symbol. Den braucht es nicht.
51
+
52
+ ## App-Katalog
53
+
54
+ Die Quickline-Box startet Apps **nur über einen Deep Link**. Play-Store-Links (`market://…`) lehnt sie ab.
55
+ Darum bringt das Plugin einen Katalog mit erprobten Links mit. In den Einstellungen hakst du an, was du installiert hast,
56
+ oder wählst **„Alle getesteten Apps“** (in der `config.json`: `"apps": ["all"]`):
57
+
58
+ | App | Link | Status |
59
+ |---|---|---|
60
+ | Quickline | `content://ch.quickline.tv.uhd` | ✅ immer dabei |
61
+ | Netflix | `https://www.netflix.com/title` | ✅ getestet |
62
+ | YouTube | `https://www.youtube.com` | ✅ getestet |
63
+ | Prime Video | `https://app.primevideo.com` | ✅ getestet |
64
+ | Play Suisse | `https://www.playsuisse.ch/de/show` | ✅ getestet (öffnet ggf. die Anmeldeseite) |
65
+ | Play SRF | `playsrf://home` | ✅ getestet |
66
+ | Sky | `sky-ch-tv://entry-point` | ✅ getestet |
67
+ | ZDFtivi | `zdftivi://` | ✅ getestet |
68
+ | Toggo | `toggo://` | ✅ getestet |
69
+ | KiKA | `ardkika://kika.de/` | ✅ getestet |
70
+ | Disney+ | `https://www.disneyplus.com` | ❔ ungetestet |
71
+ | Spotify | `spotify://` | ❔ ungetestet |
72
+ | Plex | `plex://` | ❔ ungetestet |
73
+
74
+ Bisher **ohne funktionierenden Link**: blue TV, YouTube Music. Hinweise sind willkommen.
75
+
76
+ ## Neue App hinzufügen
77
+
78
+ Steht eine App nicht im Katalog, trägst du sie unter **Eigene Eingänge** mit Name und App-Link ein.
79
+ So findest du den Link:
80
+
81
+ 1. **Bekannte Links nachschlagen:** Viele Links sind im
82
+ [Home-Assistant-Leitfaden zu App-Links](https://community.home-assistant.io/t/android-tv-remote-app-links-deep-linking-guide/567921) gesammelt.
83
+ 2. **Link-Finder:** Öffne die App einmal von Hand auf der Box. Im Homebridge-Log steht dann `Aktuelle App: <Paketname>`.
84
+ Danach im Homebridge-Terminal, mit dem Paketnamen und einem Stichwort (meist der App-Name):
85
+ ```bash
86
+ node /homebridge/node_modules/homebridge-quickline-tv/bin/find-link.js <IP-der-Box> /var/lib/homebridge/quickline-tv com.plexapp.android plex
87
+ ```
88
+ Das Werkzeug probiert typische Links durch (`plex://`, `plex://home`, `https://app.plex.tv`, …) und meldet den,
89
+ mit dem die App startet. Eigene Vermutungen kannst du am Ende anhängen. Tipp: Manche Apps brauchen eine
90
+ Adresse samt Schrägstrich hinter dem `://`, KiKA zum Beispiel `ardkika://kika.de/`.
91
+ 3. **Per ADB auslesen** (für Fortgeschrittene): Auf der Box unter Geräteeinstellungen → Info 7× auf „Build“ klicken,
92
+ in den Entwickleroptionen USB-Debugging einschalten, dann am PC:
93
+ ```bash
94
+ adb connect <IP-der-Box>:5555
95
+ adb shell dumpsys package <Paketname> | grep -E "Scheme:|Authority:|Path:"
96
+ ```
97
+ Die Ausgabe zeigt die Link-Bestandteile, auf die die App reagiert. Stehen dort `Path:`-Zeilen, braucht der Link
98
+ diesen Pfad, bei Play Suisse etwa `https://www.playsuisse.ch/de/show`. Zum Testen:
99
+ ```bash
100
+ node /homebridge/node_modules/homebridge-quickline-tv/bin/send.js <IP-der-Box> /var/lib/homebridge/quickline-tv link "plex://" wait 8
101
+ ```
102
+ USB-Debugging danach wieder ausschalten.
103
+
104
+ **Funktionierenden Link gefunden?** Melde ihn bitte als
105
+ [Issue auf GitHub](https://github.com/Protodjango/homebridge-quickline-tv/issues), mit App-Name, Paketname und Link.
106
+ Dann kommt er in den Katalog der nächsten Version.
107
+
108
+ ## Beispiel `config.json`
109
+
110
+ ```json
111
+ {
112
+ "platform": "QuicklineTV",
113
+ "name": "Quickline TV",
114
+ "devices": [
115
+ {
116
+ "name": "Quickline TV",
117
+ "host": "192.168.1.100",
118
+ "apps": ["netflix", "youtube", "playsrf", "sky"],
119
+ "inputs": [
120
+ { "name": "Plex", "type": "app", "appLink": "plex://", "package": "com.plexapp.android" }
121
+ ],
122
+ "channels": [
123
+ { "name": "SRF 1", "number": 1 },
124
+ { "name": "SRF zwei", "number": 2 }
125
+ ]
126
+ }
127
+ ]
128
+ }
129
+ ```
130
+
131
+ Die Sendernummern sind die aus deiner Quickline-Senderliste.
132
+
133
+ ## Tipps & Grenzen
134
+
135
+ - **Ein/Aus** ist eine Umschalttaste. Weicht der Zustand einmal ab, korrigiert er sich beim nächsten Statusupdate der Box.
136
+ - **Lautstärke** regelt, was die Box regelt. Ist die Quickline-Fernbedienung auf deinen Fernseher eingerichtet
137
+ (HDMI-CEC), ist es dessen Lautstärke.
138
+ - **Neue oder umbenannte Eingänge** übernimmt die Home-App manchmal erst, wenn man das Gerät entfernt und neu hinzufügt.
139
+ - Tasten für eigene Eingänge: `HOME, BACK, MENU, INFO, GUIDE, SETTINGS, CHANNEL_UP, CHANNEL_DOWN, DPAD_CENTER, MEDIA_PLAY_PAUSE`
140
+ oder eine Android-Keycode-Nummer.
141
+
142
+ ## Danksagung
143
+
144
+ Die Protokolldefinition (`lib/proto/remotemessage.proto`) und die Kopplung stammen aus
145
+ [androidtv-remote](https://github.com/louis49/androidtv-remote) von louis49 (MIT-Lizenz).
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /*
5
+ * Link-Finder: probiert typische Deep Links für eine App durch und meldet den, mit dem sie startet.
6
+ *
7
+ * node bin/find-link.js <IP> <Speicherordner> <Paketname> <Stichwort> [eigene Links ...]
8
+ * node bin/find-link.js <IP-der-Box> /var/lib/homebridge/quickline-tv com.plexapp.android plex
9
+ *
10
+ * Den Paketnamen zeigt das Homebridge-Log als „Aktuelle App: …“, wenn die App auf der Box läuft.
11
+ */
12
+
13
+ const { RemoteClient } = require('../lib/remote');
14
+ const { loadCert } = require('../lib/connection');
15
+
16
+ const QUICKLINE_LINK = 'content://ch.quickline.tv.uhd';
17
+ const QUICKLINE_APP = 'ch.quickline.tv.uhd';
18
+
19
+ const [host, storageDir, pkg, word, ...extra] = process.argv.slice(2);
20
+ if (!host || !storageDir || !pkg || !word) {
21
+ console.log('Aufruf: node bin/find-link.js <IP> <Speicherordner> <Paketname> <Stichwort> [eigene Links ...]');
22
+ console.log('Beispiel: node bin/find-link.js <IP-der-Box> /var/lib/homebridge/quickline-tv com.plexapp.android plex');
23
+ process.exit(1);
24
+ }
25
+
26
+ const cert = loadCert(storageDir, host);
27
+ if (!cert) {
28
+ console.log(`Kein Zertifikat in ${storageDir} gefunden – zuerst koppeln (bin/pair.js).`);
29
+ process.exit(1);
30
+ }
31
+
32
+ const w = word.toLowerCase();
33
+ const candidates = [...new Set([
34
+ ...extra,
35
+ `${w}://`, `${w}://home`, `${w}://start`, `${w}://main`, `${w}://open`,
36
+ `${w}tv://`, `${w}-tv://`, `${w}tv://home`,
37
+ `${w}://${w}.ch/`, `${w}://${w}.de/`, `${w}://${w}.com/`, `${w}://home/`,
38
+ `https://www.${w}.com`, `https://app.${w}.com`, `https://${w}.com`, `https://tv.${w}.com`,
39
+ `https://www.${w}.tv`, `https://app.${w}.tv`, `https://${w}.tv`,
40
+ `https://www.${w}.ch`, `https://app.${w}.ch`, `https://www.${w}.de`,
41
+ ])];
42
+
43
+ const log = { debug: () => {}, info: () => {}, warn: () => {}, error: () => {} };
44
+ const wait = (ms) => new Promise((r) => setTimeout(r, ms));
45
+
46
+ /** Verbindet, öffnet Quickline, schickt den Link und wartet, welche App startet. */
47
+ function tryLink(link) {
48
+ return new Promise((resolve) => {
49
+ const client = new RemoteClient(host, 6466, cert, log);
50
+ let app = '';
51
+ let done = false;
52
+ const finish = (result) => {
53
+ if (done) return;
54
+ done = true;
55
+ client.close();
56
+ resolve(result);
57
+ };
58
+ client.on('app', (a) => {
59
+ app = a;
60
+ if (a === pkg) finish('ok');
61
+ });
62
+ client.on('close', () => finish('abgelehnt'));
63
+ client.on('ready', async () => {
64
+ await wait(800);
65
+ if (app !== QUICKLINE_APP) {
66
+ client.sendAppLink(QUICKLINE_LINK);
67
+ await wait(4000);
68
+ }
69
+ try { client.sendAppLink(link); } catch (_) { finish('ungültig'); return; }
70
+ await wait(9000);
71
+ finish(app && app !== QUICKLINE_APP ? `öffnet ${app}` : 'nichts');
72
+ });
73
+ setTimeout(() => finish('keine Antwort'), 25000);
74
+ client.connect();
75
+ });
76
+ }
77
+
78
+ (async () => {
79
+ console.log(`Suche einen Link für ${pkg} (${candidates.length} Kandidaten, ca. ${Math.ceil(candidates.length * 15 / 60)} Minuten) …\n`);
80
+ for (const link of candidates) {
81
+ process.stdout.write(`${link} → `);
82
+ const result = await tryLink(link);
83
+ console.log(result === 'ok' ? 'FUNKTIONIERT' : result);
84
+ if (result === 'ok') {
85
+ console.log(`\n*** Gefunden! Trag in den Plugin-Einstellungen unter „Eigene Eingänge“ ein:`);
86
+ console.log(` App-Link: ${link}`);
87
+ console.log(` Paketname: ${pkg}`);
88
+ console.log(`Funktioniert er, melde ihn gern auf GitHub, damit er in den App-Katalog kommt.`);
89
+ process.exit(0);
90
+ }
91
+ await wait(1500);
92
+ }
93
+ console.log('\nKein Link gefunden. Eigene Vermutungen kannst du am Ende des Befehls anhängen, z.B. "plex://library".');
94
+ console.log('Oder per ADB die Links der App auslesen (siehe README).');
95
+ process.exit(0);
96
+ })();
package/bin/pair.js ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /*
5
+ * Koppelt Homebridge mit der Quickline TV-Box.
6
+ * Aufruf: node bin/pair.js <IP-der-Box> [Speicherordner]
7
+ * Standard-Speicherordner: ~/.homebridge/quickline-tv
8
+ */
9
+
10
+ const os = require('os');
11
+ const path = require('path');
12
+ const readline = require('readline');
13
+ const { loadLib, saveCert, certPath } = require('../lib/connection');
14
+
15
+ async function main() {
16
+ const host = process.argv[2];
17
+ const storageDir = process.argv[3] || path.join(os.homedir(), '.homebridge', 'quickline-tv');
18
+ if (!host) {
19
+ console.log('Aufruf: node bin/pair.js <IP-der-Box> [Speicherordner]');
20
+ process.exit(1);
21
+ }
22
+
23
+ const { AndroidRemote } = await loadLib();
24
+ const remote = new AndroidRemote(host, {
25
+ pairing_port: 6467,
26
+ remote_port: 6466,
27
+ service_name: 'Homebridge Quickline',
28
+ cert: {},
29
+ });
30
+
31
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
32
+
33
+ remote.on('secret', () => {
34
+ rl.question('Code, der jetzt auf dem Fernseher angezeigt wird: ', (code) => {
35
+ remote.sendCode(code.trim().toUpperCase());
36
+ });
37
+ });
38
+
39
+ remote.on('ready', () => {
40
+ saveCert(storageDir, host, remote.getCertificate());
41
+ console.log(`\nGekoppelt! Zertifikat gespeichert in ${certPath(storageDir, host)}`);
42
+ console.log('Homebridge verbindet sich innert ca. 10 Sekunden automatisch.');
43
+ rl.close();
44
+ setTimeout(() => process.exit(0), 500);
45
+ });
46
+
47
+ remote.on('error', (err) => console.error('Fehler:', err && err.message ? err.message : err));
48
+
49
+ console.log(`Verbinde mit ${host} … (Box und Fernseher müssen eingeschaltet sein)`);
50
+ await remote.start();
51
+ }
52
+
53
+ main().catch((err) => {
54
+ console.error('Kopplung fehlgeschlagen:', err.message);
55
+ process.exit(1);
56
+ });
package/bin/send.js ADDED
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /*
5
+ * Test-Werkzeug: schickt Tasten oder App-Links an die gekoppelte Box und zeigt, welche App danach läuft.
6
+ *
7
+ * node bin/send.js <IP> <Speicherordner> HOME
8
+ * node bin/send.js <IP> <Speicherordner> 111 BACK
9
+ * node bin/send.js <IP> <Speicherordner> link https://www.youtube.com wait 6
10
+ * node bin/send.js <IP> <Speicherordner> scan [von] [bis] – sucht die Taste, die Quickline öffnet
11
+ */
12
+
13
+ const { RemoteClient } = require('../lib/remote');
14
+ const { loadCert } = require('../lib/connection');
15
+ const { resolveKey } = require('../lib/keys');
16
+
17
+ const [host, storageDir, ...args] = process.argv.slice(2);
18
+ if (!host || !storageDir || args.length === 0) {
19
+ console.log('Aufruf: node bin/send.js <IP> <Speicherordner> <Taste|Keycode|link URL> [...]');
20
+ process.exit(1);
21
+ }
22
+
23
+ const cert = loadCert(storageDir, host);
24
+ if (!cert) {
25
+ console.log(`Kein Zertifikat in ${storageDir} gefunden – zuerst koppeln (bin/pair.js).`);
26
+ process.exit(1);
27
+ }
28
+
29
+ const log = { debug: () => {}, info: console.log, warn: console.log, error: console.log };
30
+ const client = new RemoteClient(host, 6466, cert, log);
31
+ const wait = (ms) => new Promise((r) => setTimeout(r, ms));
32
+
33
+ let currentApp = '';
34
+ client.on('app', (app) => { currentApp = app; if (!scanning) console.log(` → aktuelle App: ${app}`); });
35
+ let scanning = false;
36
+
37
+ const YOUTUBE = 'com.google.android.youtube.tv';
38
+ const QUICKLINE = 'ch.quickline.tv.uhd';
39
+ // Nicht getestet: Ein/Aus, Schlafmodus, Lautstärke, Anrufe, Kamera, Sprachassistent, TV-Eingänge, Helligkeit
40
+ const SKIP = new Set([5, 6, 24, 25, 26, 27, 84, 91, 164, 177, 178, 219, 220, 221, 223, 224, 225, 231, 276]);
41
+ for (let k = 230; k <= 258; k += 1) SKIP.add(k);
42
+
43
+ async function scan(from, to) {
44
+ scanning = true;
45
+ console.log(`Suchlauf über die Tastencodes ${from}–${to}. Das dauert einige Minuten …`);
46
+ for (let code = from; code <= to; code += 1) {
47
+ if (SKIP.has(code)) continue;
48
+ if (currentApp !== YOUTUBE) {
49
+ client.sendAppLink('https://www.youtube.com');
50
+ await wait(3500);
51
+ }
52
+ if (code % 20 === 0) console.log(` … bei Code ${code}`);
53
+ lastCode = code;
54
+ const before = currentApp;
55
+ try {
56
+ client.sendKey(code);
57
+ } catch (_) {
58
+ continue; // Code kennt das Protokoll nicht
59
+ }
60
+ await wait(1500);
61
+ if (currentApp !== before) {
62
+ console.log(` Code ${code}: App gewechselt zu ${currentApp}`);
63
+ if (currentApp === QUICKLINE) {
64
+ console.log(`\n*** GEFUNDEN: Tastencode ${code} öffnet Quickline ***`);
65
+ client.close();
66
+ process.exit(0);
67
+ }
68
+ }
69
+ }
70
+ console.log('Suchlauf beendet, kein Code hat Quickline geöffnet.');
71
+ client.close();
72
+ process.exit(0);
73
+ }
74
+ client.on('power', (on) => console.log(` → Box ist ${on ? 'an' : 'aus'}`));
75
+ let lastCode = 0;
76
+ client.on('close', () => {
77
+ console.log('Verbindung geschlossen.');
78
+ if (scanning) console.log(`Weitermachen mit: ... scan ${lastCode + 1}`);
79
+ process.exit(0);
80
+ });
81
+
82
+ client.on('ready', async () => {
83
+ await wait(800);
84
+ if (args[0] === 'scan') {
85
+ clearTimeout(noAnswer);
86
+ await scan(Number(args[1]) || 1, Number(args[2]) || 304);
87
+ return;
88
+ }
89
+ for (let i = 0; i < args.length; i += 1) {
90
+ if (args[i] === 'wait') {
91
+ const sec = Number(args[i + 1]) || 5;
92
+ i += 1;
93
+ await wait(sec * 1000);
94
+ continue;
95
+ }
96
+ if (args[i] === 'link') {
97
+ const url = args[i + 1];
98
+ i += 1;
99
+ console.log(`Sende Link: ${url}`);
100
+ client.sendAppLink(url);
101
+ } else {
102
+ const code = resolveKey(args[i]);
103
+ if (code === undefined) {
104
+ console.log(`Unbekannte Taste: ${args[i]}`);
105
+ continue;
106
+ }
107
+ console.log(`Sende Taste: ${args[i]} (${code})`);
108
+ client.sendKey(code);
109
+ }
110
+ await wait(2500);
111
+ }
112
+ client.close();
113
+ process.exit(0);
114
+ });
115
+
116
+ console.log(`Verbinde mit ${host} …`);
117
+ client.connect();
118
+ const noAnswer = setTimeout(() => { console.log('Keine Antwort von der Box.'); process.exit(1); }, 20000);