iobroker.autodarts 0.0.14 → 0.1.0

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/README.md CHANGED
@@ -19,6 +19,14 @@
19
19
  - Announce the current player via TTS.
20
20
  - Trigger other automations in ioBroker.
21
21
 
22
+ It also provides:
23
+
24
+ - `visit.score`: Total score of the last complete visit (3 darts).
25
+ - `throw.current`: Numeric score of the last thrown dart.
26
+ - `throw.isTriple`: Boolean flag that only turns true for triple hits above a configurable score threshold.
27
+ - `system.boardVersion`: Reported Board Manager version.
28
+ - `system.cam0/1/2`: JSON with camera settings (width, height, fps).
29
+
22
30
  ## What this adapter does NOT do
23
31
 
24
32
  - ❌ No data is sent to the internet or to third-party servers.
@@ -47,6 +55,11 @@ In the adapter settings, enter:
47
55
  <!--
48
56
  ### **WORK IN PROGRESS**
49
57
  -->
58
+ ### 0.1.0 (2025-12-23)
59
+ - Added datapoints for visit score, current dart score, triple-hit flag with configurable minimum score, and camera configuration (cam0–cam2).
60
+ - Cleaned up adapter logic and internal polling/timing.
61
+ - Updated translations.
62
+
50
63
  ### 0.0.14 (2025-12-22)
51
64
  - fix
52
65
 
@@ -3,5 +3,6 @@
3
3
  "host_port": "Autodarts (Boardmanager) Port",
4
4
  "intro_txt": "Autodarts-Adapterkonfiguration.<br>Bitte gebe IP und Port vom Boardmanager sowie den Abfrageintervall ein.",
5
5
  "outro_txt": "Team inventwo • <a href=\"https://github.com/inventwo\">https://github.com/inventwo</a>",
6
- "polling": "Abfrageintervall (ms)"
6
+ "polling": "Abfrageintervall (ms)",
7
+ "triple_flag": "Mindestpunktzahl für den Triple-Datenpunkt"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "outro_txt": "Team inventwo • <a href=\"https://github.com/inventwo\">https://github.com/inventwo</a>",
4
4
  "host_ip": "Autodarts (Boardmanager) Host / IP",
5
5
  "host_port": "Autodarts (Boardmanager) Port",
6
- "polling": "Polling interval (ms)"
6
+ "polling": "Polling interval (ms)",
7
+ "triple_flag": "Minimum score for Triple Flag"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "host_port": "Puerto Autodarts (Boardmanager)",
4
4
  "intro_txt": "Configuración del adaptador Autodarts.<br>Ingrese el host y el puerto de Boardmanager, así como el intervalo de sondeo.",
5
5
  "outro_txt": "Equipo inventwo • <a href=\"https://github.com/inventwo\">https://github.com/inventwo</a>",
6
- "polling": "Intervalo de sondeo (ms)"
6
+ "polling": "Intervalo de sondeo (ms)",
7
+ "triple_flag": "Puntuación mínima para Triple Bandera"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "host_port": "Port Autodarts (Boardmanager)",
4
4
  "intro_txt": "Configuration de l'adaptateur Autodarts.<br>Veuillez saisir l'hôte et le port de Boardmanager ainsi que l'intervalle d'interrogation.",
5
5
  "outro_txt": "Équipe inventwo • <a href=\"https://github.com/inventwo\">https://github.com/inventwo</a>",
6
- "polling": "Intervalle d'interrogation (ms)"
6
+ "polling": "Intervalle d'interrogation (ms)",
7
+ "triple_flag": "Score minimum pour le triple drapeau"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "host_port": "Porta Autodarts (Boardmanager).",
4
4
  "intro_txt": "Configurazione dell'adattatore Autodarts.<br>Inserisci host e porta da Boardmanager nonché l'intervallo di polling.",
5
5
  "outro_txt": "Team inventtwo • <a href=\"https://github.com/inventtwo\">https://github.com/inventtwo</a>",
6
- "polling": "Intervallo di polling (ms)"
6
+ "polling": "Intervallo di polling (ms)",
7
+ "triple_flag": "Punteggio minimo per Triple Flag"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "host_port": "Autodarts (Bestuursmanager) Port",
4
4
  "intro_txt": "Autodarts-adapterconfiguratie.<br>Voer de host en poort van Boardmanager in, evenals het polling-interval.",
5
5
  "outro_txt": "Team inventwo • <a href=\"https://github.com/inventwo\">https://github.com/inventwo</a>",
6
- "polling": "Polling-interval (ms)"
6
+ "polling": "Polling-interval (ms)",
7
+ "triple_flag": "Minimumscore voor Triple Flag"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "host_port": "Port Autodarts (Boardmanager).",
4
4
  "intro_txt": "Konfiguracja adaptera Autodarts.<br>Wprowadź host i port z Boardmanager oraz interwał odpytywania.",
5
5
  "outro_txt": "Zespół inventwo • <a href=\"https://github.com/inventwo\">https://github.com/inventwo</a>",
6
- "polling": "Interwał odpytywania (ms)"
6
+ "polling": "Interwał odpytywania (ms)",
7
+ "triple_flag": "Minimalny wynik dla Potrójnej Flagi"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "host_port": "Porto Autodarts (Boardmanager)",
4
4
  "intro_txt": "Configuração do adaptador Autodarts.<br>Insira o host e a porta do Boardmanager, bem como o intervalo de pesquisa.",
5
5
  "outro_txt": "Equipe inventtwo • <a href=\"https://github.com/inventwo\">https://github.com/inventwo</a>",
6
- "polling": "Intervalo de pesquisa (ms)"
6
+ "polling": "Intervalo de pesquisa (ms)",
7
+ "triple_flag": "Pontuação mínima para Tripla Bandeira"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "host_port": "Порт Autodarts (Boardmanager)",
4
4
  "intro_txt": "Конфигурация адаптера Autodarts.<br>Укажите хост и порт из Boardmanager, а также интервал опроса.",
5
5
  "outro_txt": "Команда inventwo • <a href=\"https://github.com/inventwo\">https://github.com/inventwo</a>",
6
- "polling": "Интервал опроса (мс)"
6
+ "polling": "Интервал опроса (мс)",
7
+ "triple_flag": "Минимальный балл для тройного флага"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "host_port": "Autodarts (Boardmanager) Порт",
4
4
  "intro_txt": "Конфігурація адаптера Autodarts.<br>Введіть хост і порт із Boardmanager, а також інтервал опитування.",
5
5
  "outro_txt": "Команда inventwo • <a href=\"https://github.com/inventwo\">https://github.com/inventwo</a>",
6
- "polling": "Інтервал опитування (мс)"
6
+ "polling": "Інтервал опитування (мс)",
7
+ "triple_flag": "Мінімальний бал для потрійного прапора"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "host_port": "Autodarts(Boardmanager)端口",
4
4
  "intro_txt": "Autodarts 适配器配置。<br>请输入 Boardmanager 中的主机和端口以及轮询间隔。",
5
5
  "outro_txt": "团队 inventwo • <a href=\"https://github.com/inventwo\">https://github.com/inventwo</a>",
6
- "polling": "轮询间隔(毫秒)"
6
+ "polling": "轮询间隔(毫秒)",
7
+ "triple_flag": "三旗最低分数"
7
8
  }
@@ -50,6 +50,17 @@
50
50
  "lg": 6,
51
51
  "xl": 4
52
52
  },
53
+ "tripleMinScore": {
54
+ "type": "number",
55
+ "label": "triple_flag",
56
+ "default": 1,
57
+ "newLine": true,
58
+ "sm": 12,
59
+ "xs": 12,
60
+ "md": 8,
61
+ "lg": 6,
62
+ "xl": 4
63
+ },
53
64
  "outro": {
54
65
  "type": "staticText",
55
66
  "text": "outro_txt",
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "autodarts",
4
- "version": "0.0.14",
4
+ "version": "0.1.0",
5
5
  "news": {
6
+ "0.1.0": {
7
+ "en": "Added datapoints for visit score, current dart score, triple-hit flag with configurable minimum score, and camera configuration (cam0–cam2).\nCleaned up adapter logic and internal polling/timing.\nUpdated translations.",
8
+ "de": "Weitere Datenpunkte für Besuchscore, aktuelle Dart-Score, Tripel-hit-Flag mit konfigurierbaren minimalen Punktzahl und Kamerakonfiguration (cam0–cam2).\nAufgereinigte Adapterlogik und interne Abfrage/timing.\nAktualisierte Übersetzungen.",
9
+ "ru": "Добавлены точки данных для оценки посещений, текущая оценка дарта, флаг тройного удара с настраиваемым минимальным баллом и конфигурация камеры (cam0-cam2).\nОчищена адаптерная логика и внутренний опрос/настройка.\nОбновленные переводы.",
10
+ "pt": "Adicionados pontos de dados para a pontuação de visita, pontuação de dardo atual, bandeira de triplo hit com pontuação mínima configurável, e configuração da câmera (cam0–cam2).\nLimpei a lógica do adaptador e as pesquisas internas.\nTradução atualizada.",
11
+ "nl": "Toegevoegd datapoints voor bezoek score, huidige dart score, triple-hit vlag met configureerbare minimum score, en camera configuratie (cam0.\nOpgeruimd adapter logica en interne peiling / timing.\nBijgewerkte vertalingen.",
12
+ "fr": "Ajout de points de données pour le score de visite, le score de fléchette actuel, le drapeau triple-hit avec le score minimum configurable et la configuration de la caméra (cam0–cam2).\nNettoyer la logique de l'adaptateur et effectuer des sondages internes/timing.\nTraductions actualisées.",
13
+ "it": "Aggiunti i datapoint per il punteggio di visita, il punteggio di freccette corrente, la bandiera a triplo punto con il punteggio minimo configurabile e la configurazione della fotocamera (cam0–cam2).\nPulito logica adattatore e polling/timing interno.\nTraduzione aggiornata.",
14
+ "es": "Puntos de datos añadidos para la puntuación de la visita, puntaje del dardo actual, bandera triple con puntaje mínimo configurable, y configuración de la cámara (cam0–cam2).\nLógica del adaptador limpiado y polinización interna / estimulación.\nTraducciones actualizadas.",
15
+ "pl": "Dodano punkty datapointowe dla wyniku odwiedzin, aktualny wynik dart, flagę trójuderzeniową z konfigurowalnym minimalnym wynikiem oraz konfigurację kamery (cam0- cam2).\nOczyszczona logika adaptera i wewnętrzny sondaż / czas.\nAktualizacja tłumaczeń.",
16
+ "uk": "Додано точки даних для облікового запису, поточний запис dart, потрійний прапор з налаштуванням мінімального балу та конфігурації камери (cam0–cam2).\nЗнімання логіки адаптера та внутрішнього опитування / термінів.\nОновлені переклади.",
17
+ "zh-cn": "添加了访问分数的数据点,当前飞镖分数,三重击旗可配置最小分数,以及相机配置(cam0–cam2).\n清理适配器逻辑和内部投票/计时.\n最新译名."
18
+ },
6
19
  "0.0.14": {
7
20
  "en": "fix",
8
21
  "de": "fixieren",
@@ -80,19 +93,6 @@
80
93
  "pl": "fix - Kontrola adaptera",
81
94
  "uk": "виправити - Перевірювач адаптера",
82
95
  "zh-cn": "修补 - 适配器检查器"
83
- },
84
- "0.0.6": {
85
- "en": "fix - Adapter Checker",
86
- "de": "fix - Adapter Checker",
87
- "ru": "обсуждение Adapter Checker",
88
- "pt": "correção - Adapter Checker",
89
- "nl": "fix - Adapterchecker",
90
- "fr": "correction - Vérificateur d'adaptateur",
91
- "it": "correzione - Adattatore Checker",
92
- "es": "fijado - Adaptador Checker",
93
- "pl": "fix - Kontrola adaptera",
94
- "uk": "виправити - Перевірювач адаптера",
95
- "zh-cn": "修补 - 适配器检查器"
96
96
  }
97
97
  },
98
98
  "titleLang": {
package/main.js CHANGED
@@ -17,7 +17,7 @@ class Autodarts extends utils.Adapter {
17
17
  this.lastThrowsCount = 0; // Anzahl Darts im aktuellen Visit
18
18
  this.lastSignature = ""; // Verhindert doppelte Verarbeitung gleicher Würfe
19
19
  this.offline = false;
20
- this.versionTimer = null; // Timer für Versionsabfrage
20
+ this.versionTimer = null; // Timer für Versions- und Config-Abfrage
21
21
  }
22
22
 
23
23
  async onReady() {
@@ -27,6 +27,9 @@ class Autodarts extends utils.Adapter {
27
27
  this.config.host ??= "127.0.0.1";
28
28
  this.config.port ??= 3180;
29
29
  this.config.interval ??= 1000;
30
+ // eslint-disable-next-line jsdoc/check-tag-names
31
+ /** @ts-expect-error tripleMinScore is defined in io-package.json but not in AdapterConfig */
32
+ this.config.tripleMinScore ??= 1; // Mindestpunktzahl für Triple-Flag
30
33
 
31
34
  // Visit-Struktur anlegen
32
35
  await this.setObjectNotExistsAsync("visit", {
@@ -59,6 +62,56 @@ class Autodarts extends utils.Adapter {
59
62
  native: {},
60
63
  });
61
64
 
65
+ // Throw-Channel und States
66
+ await this.setObjectNotExistsAsync("throw", {
67
+ type: "channel",
68
+ common: {
69
+ name: {
70
+ en: "Current throw",
71
+ de: "Aktueller Wurf",
72
+ },
73
+ },
74
+ native: {},
75
+ });
76
+
77
+ await this.setObjectNotExistsAsync("throw.current", {
78
+ type: "state",
79
+ common: {
80
+ name: {
81
+ en: "Current dart score",
82
+ de: "Punkte aktueller Pfeil",
83
+ },
84
+ type: "number",
85
+ role: "value",
86
+ read: true,
87
+ write: false,
88
+ desc: {
89
+ en: "Score of the last dart",
90
+ de: "Punktzahl des letzten Pfeils",
91
+ },
92
+ },
93
+ native: {},
94
+ });
95
+
96
+ await this.setObjectNotExistsAsync("throw.isTriple", {
97
+ type: "state",
98
+ common: {
99
+ name: {
100
+ en: "Triple hit",
101
+ de: "Triple getroffen",
102
+ },
103
+ type: "boolean",
104
+ role: "indicator",
105
+ read: true,
106
+ write: false,
107
+ desc: {
108
+ en: "true if the last dart hit a triple segment (and passes score threshold)",
109
+ de: "true, wenn der letzte Pfeil ein Triple-Segment getroffen hat (und die Punktschwelle erfüllt)",
110
+ },
111
+ },
112
+ native: {},
113
+ });
114
+
62
115
  // Online-Datenpunkt
63
116
  await this.setObjectNotExistsAsync("online", {
64
117
  type: "state",
@@ -110,6 +163,64 @@ class Autodarts extends utils.Adapter {
110
163
  native: {},
111
164
  });
112
165
 
166
+ // Kamera-Infos als JSON-States
167
+ await this.setObjectNotExistsAsync("system.cam0", {
168
+ type: "state",
169
+ common: {
170
+ name: {
171
+ en: "Camera 0 config",
172
+ de: "Kamera 0 Konfiguration",
173
+ },
174
+ type: "string",
175
+ role: "json",
176
+ read: true,
177
+ write: false,
178
+ desc: {
179
+ en: "JSON with camera 0 parameters (width, height, fps)",
180
+ de: "JSON mit Kamera-0-Parametern (width, height, fps)",
181
+ },
182
+ },
183
+ native: {},
184
+ });
185
+
186
+ await this.setObjectNotExistsAsync("system.cam1", {
187
+ type: "state",
188
+ common: {
189
+ name: {
190
+ en: "Camera 1 config",
191
+ de: "Kamera 1 Konfiguration",
192
+ },
193
+ type: "string",
194
+ role: "json",
195
+ read: true,
196
+ write: false,
197
+ desc: {
198
+ en: "JSON with camera 1 parameters (width, height, fps)",
199
+ de: "JSON mit Kamera-1-Parametern (width, height, fps)",
200
+ },
201
+ },
202
+ native: {},
203
+ });
204
+
205
+ await this.setObjectNotExistsAsync("system.cam2", {
206
+ type: "state",
207
+ common: {
208
+ name: {
209
+ en: "Camera 2 config",
210
+ de: "Kamera 2 Konfiguration",
211
+ },
212
+ type: "string",
213
+ role: "json",
214
+ read: true,
215
+ write: false,
216
+ desc: {
217
+ en: "JSON with camera 2 parameters (width, height, fps)",
218
+ de: "JSON mit Kamera-2-Parametern (width, height, fps)",
219
+ },
220
+ },
221
+ native: {},
222
+ });
223
+
113
224
  // Zustand zurücksetzen
114
225
  this.lastThrowsCount = 0;
115
226
  this.lastSignature = "";
@@ -118,9 +229,16 @@ class Autodarts extends utils.Adapter {
118
229
  this.pollTimer = setInterval(() => this.fetchState(), this.config.interval);
119
230
  this.fetchState();
120
231
 
121
- // Boardmanager-Version abfragen und alle 5 Minuten aktualisieren
232
+ // Boardmanager-Version und Kameras abfragen und alle 5 Minuten aktualisieren
122
233
  this.fetchVersion();
123
- this.versionTimer = setInterval(() => this.fetchVersion(), 5 * 60 * 1000);
234
+ this.fetchConfig();
235
+ this.versionTimer = setInterval(
236
+ () => {
237
+ this.fetchVersion();
238
+ this.fetchConfig();
239
+ },
240
+ 5 * 60 * 1000,
241
+ );
124
242
  }
125
243
 
126
244
  /**
@@ -180,6 +298,21 @@ class Autodarts extends utils.Adapter {
180
298
  }
181
299
  this.lastSignature = signature;
182
300
 
301
+ // letzten Dart in States schreiben
302
+ const lastDart = currentThrows[currentThrows.length - 1];
303
+ const score = this.calcScore(lastDart);
304
+
305
+ // Konfigurierter Mindestwert für Triple-Flag
306
+ // eslint-disable-next-line jsdoc/check-tag-names
307
+ /** @ts-expect-error tripleMinScore is defined in io-package.json but not in AdapterConfig */
308
+ const minScore = Number(this.config.tripleMinScore) || 0;
309
+
310
+ // Triple nur, wenn multiplier === 3 UND score >= minScore
311
+ const isTriple = !!lastDart?.segment && lastDart.segment.multiplier === 3 && score >= minScore;
312
+
313
+ this.setState("throw.current", { val: score, ack: true });
314
+ this.setState("throw.isTriple", { val: isTriple, ack: true });
315
+
183
316
  // Nur schreiben, wenn:
184
317
  // - genau 3 Darts geworfen wurden
185
318
  // - vorher weniger als 3 waren (Visit gerade abgeschlossen)
@@ -255,6 +388,55 @@ class Autodarts extends utils.Adapter {
255
388
  req.end();
256
389
  }
257
390
 
391
+ /**
392
+ * Board-Konfiguration abfragen (Kameras)
393
+ */
394
+ fetchConfig() {
395
+ const options = {
396
+ host: this.config.host,
397
+ port: this.config.port,
398
+ path: "/api/config",
399
+ method: "GET",
400
+ timeout: 1500,
401
+ };
402
+
403
+ const req = http.request(options, res => {
404
+ let data = "";
405
+ res.on("data", chunk => (data += chunk));
406
+ res.on("end", () => {
407
+ try {
408
+ const cfg = JSON.parse(data);
409
+
410
+ const cam = cfg.cam || {};
411
+ const camInfo = {
412
+ width: cam.width ?? 1280,
413
+ height: cam.height ?? 720,
414
+ fps: cam.fps ?? 20,
415
+ };
416
+
417
+ const json = JSON.stringify(camInfo);
418
+
419
+ this.setState("system.cam0", { val: json, ack: true });
420
+ this.setState("system.cam1", { val: json, ack: true });
421
+ this.setState("system.cam2", { val: json, ack: true });
422
+ } catch (e) {
423
+ this.log.warn(`Fehler beim Lesen der Config: ${e.message} | Daten: ${data.substring(0, 200)}...`);
424
+ }
425
+ });
426
+ });
427
+
428
+ req.on("error", () => {
429
+ this.log.warn("Config-API nicht erreichbar");
430
+ });
431
+
432
+ req.on("timeout", () => {
433
+ req.destroy();
434
+ this.log.warn("Config-API Timeout");
435
+ });
436
+
437
+ req.end();
438
+ }
439
+
258
440
  onUnload(callback) {
259
441
  try {
260
442
  if (this.pollTimer) {
@@ -264,8 +446,7 @@ class Autodarts extends utils.Adapter {
264
446
  clearInterval(this.versionTimer);
265
447
  }
266
448
  callback();
267
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
268
- } catch (e) {
449
+ } catch {
269
450
  callback();
270
451
  }
271
452
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.autodarts",
3
- "version": "0.0.14",
3
+ "version": "0.1.0",
4
4
  "description": "Autodarts Autoscoring",
5
5
  "author": "skvarel <skvarel@inventwo.com>",
6
6
  "contributors": [