From bc8b1166dc1e6423c84d306799f96114f64d3edf Mon Sep 17 00:00:00 2001 From: Yannic Labonte Date: Mon, 21 Aug 2023 13:12:42 +0200 Subject: [PATCH] Add generic relay timers --- build/main.js | 40 +++++++ io-package.json | 111 +++--------------- package-lock.json | 287 +++++++++++++++++++--------------------------- package.json | 16 +-- src/main.ts | 44 ++++++- 5 files changed, 220 insertions(+), 278 deletions(-) diff --git a/build/main.js b/build/main.js index 7f01797..177f371 100644 --- a/build/main.js +++ b/build/main.js @@ -83,6 +83,7 @@ class ProconIp extends utils.Adapter { }); this._relayDataInterpreter = new procon_ip_1.RelayDataInterpreter(this.log); this._getStateService = new procon_ip_1.GetStateService(serviceConfig, this.log); + this._setStateService = new procon_ip_1.SetStateService(serviceConfig, this.log); this._usrcfgCgiService = new procon_ip_1.UsrcfgCgiService(serviceConfig, this.log, this._getStateService, this._relayDataInterpreter); this._commandService = new procon_ip_1.CommandService(serviceConfig, this.log); this.log.debug(`GetStateService url: ${this._getStateService.url}`); @@ -207,6 +208,11 @@ class ProconIp extends utils.Adapter { this.log.error(`Error on manual dosage (${id}): ${e}`); }); } + else if (id.endsWith(".timer")) { + this.setRelayTimer(id, state).catch((e) => { + this.log.error(`Error on relay timer (${id}): ${e}`); + }); + } } relayToggleAuto(objectId, state) { return __awaiter(this, void 0, void 0, function* () { @@ -290,6 +296,26 @@ class ProconIp extends utils.Adapter { } }); } + setRelayTimer(objectId, state) { + return __awaiter(this, void 0, void 0, function* () { + const obj = yield this.getObjectAsync(objectId); + if (!obj) { + throw new Error(`Cannot handle state change for non-existent object '${objectId}'`); + } + const getStateDataObject = this._stateData.getDataObject(obj.native.id); + const relayId = getStateDataObject.categoryId + + (getStateDataObject.category === procon_ip_1.GetStateCategory.EXTERNAL_RELAYS ? 9 : 1); + this._forceUpdate.push(getStateDataObject.id); + try { + const stateValNumber = state.val; + yield this._setStateService.setTimer(relayId, stateValNumber); + this.log.info(`Setting timer for ${obj.native.label} to ${state.val} seconds`); + } + catch (e) { + this.log.error(e); + } + }); + } // /** // * Some message was sent to this instance over message box. Used by email, pushover, text2speech, ... // * Using this method requires "common.message" property to be set to true in io-package.json @@ -540,6 +566,20 @@ class ProconIp extends utils.Adapter { native: obj, }); } + else { + const commonGenericRelayTimerState = { + name: obj.label, + type: "number", + role: "value.interval", + read: false, + write: true, + }; + this.setObjectNotExists(`${this.name}.${this.instance}.${obj.category}.${obj.categoryId}.timer`, { + type: "state", + common: commonGenericRelayTimerState, + native: obj, + }); + } // this.setObjectNotExistsAsync(`${this.name}.${this.instance}.${obj.category}.${obj.categoryId}.auto`, { // type: "state", // common: commonAuto, diff --git a/io-package.json b/io-package.json index 82346ad..a41f35e 100644 --- a/io-package.json +++ b/io-package.json @@ -1,8 +1,21 @@ { "common": { "name": "procon-ip", - "version": "1.3.3", + "version": "1.4.0", "news": { + "1.4.0": { + "en": "Add generic relay timers and update dependencies", + "de": "Einführung allgemeiner Relais-Timer und Aktualisierung von Abhängigkeiten", + "ru": "Добавьте таймеры генерических релей и обновляйте зависимости", + "pt": "Adicionar temporizadores de relé genéricos e dependências de atualização", + "nl": "Add generische relais timers en update afhankelijkheid", + "fr": "Ajouter les temps de relais génériques et mettre à jour les dépendances", + "it": "Aggiungi timer generici di relè e aggiorna le dipendenze", + "es": "Agregar cronogramas de relé genéricos y dependencias de actualización", + "pl": "Adddition timers and update Dependencyjność", + "uk": "Додавання генних таймерів реле та оновлення залежностей", + "zh-cn": "增加通用的延迟时间和最新频率" + }, "1.3.3": { "en": "Dependencies update", "de": "Aktualisierung der Abhängigkeiten", @@ -152,102 +165,6 @@ "es": "Lanzamiento estable para los repositorios oficiales. Para más detalles, consulte: https://github.com/ylabonte/ioBroker.procon-ip", "pl": "Stabilna wersja oficjalnych repozytoriów. Aby uzyskać szczegółowe informacje, patrz: https://github.com/ylabonte/ioBroker.procon-ip", "zh-cn": "官方仓库的稳定版本。有关详细信息,请参见:https://github.com/ylabonte/ioBroker.procon-ip" - }, - "0.4.1": { - "en": "Bugfix release: Fix write actions to the appropriate states of external relays. This will add auto-recognition on whether the external relays are activated or not and therefore decide on how to handle write actions to the corresponding relay state.", - "de": "Bugfix Release: Schreibaktionen auf die entsprechenden Zustände externer Relais korrigieren. Dadurch wird die automatische Erkennung hinzugefügt, ob die externen Relais aktiviert sind oder nicht, und daher wird entschieden, wie Schreibaktionen in den entsprechenden Relaisstatus ausgeführt werden sollen.", - "ru": "Исправление ошибок: исправление действий записи в соответствующих состояниях внешних реле. Это добавит автоматическое распознавание того, активированы ли внешние реле или нет, и, следовательно, решит, как обрабатывать действия записи в соответствующее состояние реле.", - "pt": "Versão do bugfix: Corrija as ações de gravação nos estados apropriados dos relés externos. Isso adicionará o reconhecimento automático se os relés externos estão ativados ou não e, portanto, decidirá como lidar com as ações de gravação no estado correspondente do relé.", - "nl": "Bugfix-release: schrijfacties corrigeren naar de juiste status van externe relais. Dit voegt automatische herkenning toe over het feit of de externe relais zijn geactiveerd of niet en beslist daarom hoe schrijfacties moeten worden afgehandeld in de overeenkomstige relaistoestand.", - "fr": "Version de correction de bug: correction des actions d'écriture sur les états appropriés des relais externes. Cela ajoutera une reconnaissance automatique de l'activation ou non des relais externes et décidera donc comment gérer les actions d'écriture dans l'état de relais correspondant.", - "it": "Rilascio bugfix: correggi le azioni di scrittura negli stati appropriati dei relè esterni. Ciò aggiungerà il riconoscimento automatico sull'attivazione o meno dei relè esterni e quindi la decisione su come gestire le azioni di scrittura nello stato di relè corrispondente.", - "es": "Versión de corrección de errores: arregla las acciones de escritura en los estados apropiados de los relés externos. Esto agregará el reconocimiento automático de si los relés externos están activados o no y, por lo tanto, decidirá cómo manejar las acciones de escritura en el estado del relé correspondiente.", - "pl": "Wydanie poprawki: Napraw działania zapisu w odpowiednich stanach przekaźników zewnętrznych. Spowoduje to dodanie automatycznego rozpoznawania, czy przekaźniki zewnętrzne są aktywowane, czy też nie, a zatem decyduje, w jaki sposób obsługiwać operacje zapisu do odpowiedniego stanu przekaźnika.", - "zh-cn": "错误修正版本:将写操作修正为外部继电器的相应状态。这将增加对外部继电器是否已激活的自动识别,并因此决定如何处理对相应继电器状态的写操作。" - }, - "0.4.0": { - "en": "This release adds encryption to the ProCon.ip credentials, that are stored in ioBroker. This will break your adapter configuration, which simply means you will have to re-enter your controller-url, username, password and click save. It also should improve the http request/connection error handling and remove the unused admin tab.", - "de": "Diese Version fügt den ProCon.ip-Anmeldeinformationen, die in ioBroker gespeichert sind, eine Verschlüsselung hinzu. Dadurch wird Ihre Adapterkonfiguration beschädigt, was einfach bedeutet, dass Sie Ihre Controller-URL, Ihren Benutzernamen und Ihr Kennwort erneut eingeben und auf Speichern klicken müssen. Es sollte auch die Behandlung von http-Anforderungs- / Verbindungsfehlern verbessern und die nicht verwendete Registerkarte \"Administrator\" entfernen.", - "ru": "Этот выпуск добавляет шифрование к учетным данным ProCon.ip, которые хранятся в ioBroker. Это нарушит конфигурацию вашего адаптера, а это просто означает, что вам придется повторно ввести URL-адрес контроллера, имя пользователя, пароль и нажать «Сохранить». Это также должно улучшить обработку запросов / ошибок http и удалить неиспользуемую вкладку администратора.", - "pt": "Esta versão adiciona criptografia às credenciais do ProCon.ip, armazenadas no ioBroker. Isso interromperá a configuração do adaptador, o que significa simplesmente que você precisará digitar novamente seu URL do controlador, nome de usuário, senha e clique em Salvar. Também deve melhorar a manipulação de erros de solicitação / conexão http e remover a guia de administração não utilizada.", - "nl": "Deze release voegt encryptie toe aan de inloggegevens van ProCon.ip, die zijn opgeslagen in ioBroker. Hierdoor wordt uw adapterconfiguratie verbroken, wat simpelweg betekent dat u uw controller-url, gebruikersnaam en wachtwoord opnieuw moet invoeren en op Opslaan moet klikken. Het zou ook de afhandeling van http-verzoeken / verbindingsfouten moeten verbeteren en het ongebruikte admin-tabblad moeten verwijderen.", - "fr": "Cette version ajoute un chiffrement aux informations d'identification ProCon.ip, qui sont stockées dans ioBroker. Cela cassera la configuration de votre adaptateur, ce qui signifie simplement que vous devrez ressaisir l'url de votre contrôleur, votre nom d'utilisateur, votre mot de passe et cliquer sur Enregistrer. Il devrait également améliorer la gestion des erreurs de demande / connexion http et supprimer l'onglet d'administration inutilisé.", - "it": "Questa versione aggiunge la crittografia alle credenziali ProCon.ip, che sono archiviate in ioBroker. Ciò interromperà la configurazione dell'adattatore, il che significa semplicemente che dovrai inserire nuovamente l'URL del controller, il nome utente, la password e fare clic su Salva. Dovrebbe inoltre migliorare la gestione degli errori di richiesta / connessione http e rimuovere la scheda di amministrazione non utilizzata.", - "es": "Esta versión agrega cifrado a las credenciales ProCon.ip, que se almacenan en ioBroker. Esto interrumpirá la configuración de su adaptador, lo que simplemente significa que tendrá que volver a ingresar su URL de controlador, nombre de usuario, contraseña y hacer clic en guardar. También debería mejorar el manejo de errores de solicitud / conexión http y eliminar la pestaña de administrador no utilizada.", - "pl": "Ta wersja dodaje szyfrowanie do poświadczeń ProCon.ip, które są przechowywane w ioBroker. Spowoduje to uszkodzenie konfiguracji adaptera, co oznacza po prostu, że musisz ponownie wprowadzić adres URL kontrolera, nazwę użytkownika, hasło i kliknąć przycisk Zapisz. Powinno to również poprawić obsługę żądania HTTP / błędu połączenia i usunąć nieużywaną kartę administratora.", - "zh-cn": "此版本将加密添加到ProCon.ip凭据中,该凭据存储在ioBroker中。这将破坏您的适配器配置,这仅意味着您将必须重新输入控制器URL,用户名,密码并单击“保存”。它还应改善http请求/连接错误处理并删除未使用的admin选项卡。" - }, - "0.3.1": { - "en": "Functional update with security aspects. See README.md for details.", - "de": "Funktionsaktualisierung mit Sicherheitsaspekten. Siehe README.md für Details.", - "ru": "Функциональное обновление с аспектами безопасности. Смотрите README.md для подробностей.", - "pt": "Atualização funcional com aspectos de segurança. Consulte README.md para obter detalhes.", - "nl": "Functionele update met beveiligingsaspecten. Zie README.md voor details.", - "fr": "Mise à jour fonctionnelle avec des aspects de sécurité. Voir README.md pour plus de détails.", - "it": "Aggiornamento funzionale con aspetti di sicurezza. Vedi README.md per i dettagli.", - "es": "Actualización funcional con aspectos de seguridad. Ver README.md para más detalles.", - "pl": "Aktualizacja funkcjonalna z aspektami bezpieczeństwa. Szczegółowe informacje można znaleźć w pliku README.md.", - "zh-cn": "具有安全方面的功能更新。有关详细信息,请参见README.md。" - }, - "0.2.0": { - "en": "Minor update", - "de": "Kleinere Aktualisierung", - "ru": "Незначительное обновление", - "pt": "Atualização menor", - "nl": "Kleine update", - "fr": "Mise à jour mineure", - "it": "Aggiornamento secondario", - "es": "Actualización menor", - "pl": "Drobna aktualizacja", - "zh-cn": "小更新" - }, - "0.1.1": { - "en": "Security update", - "de": "Sicherheitsupdate", - "ru": "Обновление безопасности", - "pt": "Atualização de segurança", - "nl": "Beveiligingsupdate", - "fr": "Mise à jour de sécurité", - "it": "Aggiornamento di sicurezza", - "es": "Actualización de seguridad", - "pl": "Aktualizacja bezpieczeństwa", - "zh-cn": "安全更新" - }, - "0.1.0": { - "en": "Functional update and minor fixes", - "de": "Funktionsupdate und kleinere Korrekturen", - "ru": "Функциональное обновление и мелкие исправления", - "pt": "Atualização funcional e pequenas correções", - "nl": "Functionele update en kleine aanpassingen", - "fr": "Mise à jour fonctionnelle et correctifs mineurs", - "it": "Aggiornamento funzionale e correzioni minori", - "es": "Actualización funcional y correcciones menores", - "pl": "Aktualizacja funkcjonalna i drobne poprawki", - "zh-cn": "功能更新和次要修复" - }, - "0.0.4": { - "en": "Security update", - "de": "Sicherheitsupdate", - "ru": "Обновление безопасности", - "pt": "Atualização de segurança", - "nl": "Beveiligingsupdate", - "fr": "Mise à jour de sécurité", - "it": "Aggiornamento di sicurezza", - "es": "Actualización de seguridad", - "pl": "Aktualizacja bezpieczeństwa", - "zh-cn": "安全更新" - }, - "0.0.3": { - "en": "Bugfix release", - "de": "Bugfix Release", - "ru": "Релиз исправления", - "pt": "Bugfix release", - "nl": "Bugfix-release", - "fr": "Version du correctif", - "it": "Rilascio bugfix", - "es": "Lanzamiento de corrección de errores", - "pl": "Wersja Bugfix", - "zh-cn": "错误修正版本" } }, "title": "ProCon.IP Pool Control", diff --git a/package-lock.json b/package-lock.json index c0e52a4..7f02b66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "iobroker.procon-ip", - "version": "1.3.3", + "version": "1.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "iobroker.procon-ip", - "version": "1.3.3", + "version": "1.4.0", "license": "MIT", "dependencies": { - "@iobroker/adapter-core": "^2.6.8", - "procon-ip": "^1.6.4" + "@iobroker/adapter-core": "^3.0.3", + "procon-ip": "^1.7.1" }, "devDependencies": { "@iobroker/testing": "^4.1.0", @@ -19,16 +19,16 @@ "@types/crypto-js": "^4.1.1", "@types/gulp": "^4.0.13", "@types/mocha": "^10.0.1", - "@types/node": "^20.4.1", + "@types/node": "^20.5.1", "@types/proxyquire": "^1.3.28", - "@types/sinon": "^10.0.15", + "@types/sinon": "^10.0.16", "@types/sinon-chai": "^3.2.9", - "@typescript-eslint/eslint-plugin": "^6.0.0", - "@typescript-eslint/parser": "^6.0.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", "chai": "^4.3.7", "chai-as-promised": "^7.1.1", "crypto-js": "^4.1.1", - "eslint": "^8.44.0", + "eslint": "^8.47.0", "gulp": "^4.0.2", "mocha": "^10.2.0", "nyc": "^15.1.0", @@ -503,18 +503,18 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.5.0.tgz", - "integrity": "sha512-vITaYzIcNmjn5tF5uxcZ/ft7/RXGrMUIS9HalWckEOF6ESiwXKoMzAQf2UW0aVd6rnOeExTJVd5hmWXucBKGXQ==", + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.6.2.tgz", + "integrity": "sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw==", "dev": true, "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, "node_modules/@eslint/eslintrc": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.0.tgz", - "integrity": "sha512-Lj7DECXqIVCqnqjjHMPna4vn6GJcMgul/wuS0je9OZ9gsL0zzDpKPVtcG1HaDVc+9y+qgXneTeUMbCqXJNpH1A==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", + "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", "dev": true, "dependencies": { "ajv": "^6.12.4", @@ -535,9 +535,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.44.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.44.0.tgz", - "integrity": "sha512-Ag+9YM4ocKQx9AarydN0KY2j0ErMHNIocPDrVo8zAE44xLTjEtz81OdR68/cydGtk6m6jDb5Za3r2useMzYmSw==", + "version": "8.47.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.47.0.tgz", + "integrity": "sha512-P6omY1zv5MItm93kLM8s2vr1HICJH8v0dvddDhysbIuZ+vcjOHg5Zbkf1mTkcmi2JA9oBG2anOkRnW8WJTS8Og==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -577,11 +577,11 @@ "dev": true }, "node_modules/@iobroker/adapter-core": { - "version": "2.6.8", - "resolved": "https://registry.npmjs.org/@iobroker/adapter-core/-/adapter-core-2.6.8.tgz", - "integrity": "sha512-xrqtH5RYZ6BvEcDyfuPkajd9el4R6p0VLRYKlnfMafAbxybIN+zfeHvjGI4l8OAHkyP2tcv6boX2Vu0KnMFOHw==", - "dependencies": { - "@types/iobroker": "^4.0.5" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@iobroker/adapter-core/-/adapter-core-3.0.3.tgz", + "integrity": "sha512-SZmL69BtUXitnTbidNjlljQKB6CbkBLK9+Tqo/NMsOqHb1RmhPCNKhO4F5o8jc0dW0J6d4VArXryUkL7Ru0WpA==", + "peerDependencies": { + "@iobroker/types": "^5.0.11" } }, "node_modules/@iobroker/testing": { @@ -636,6 +636,15 @@ "url": "https://opencollective.com/sinon" } }, + "node_modules/@iobroker/types": { + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/@iobroker/types/-/types-5.0.12.tgz", + "integrity": "sha512-zExHvDhSyjgSioJYB8BQa1LvmtiZjn0ThJfaKP+jH9tx7ddyK/irI5cqjR0Y6DUpx0x9BkaDI9utuPVbRWzYLQ==", + "peer": true, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", @@ -1067,14 +1076,6 @@ "chokidar": "^3.3.1" } }, - "node_modules/@types/iobroker": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/@types/iobroker/-/iobroker-4.0.5.tgz", - "integrity": "sha512-D1tJwuDQEQQQ/cZVFjFjFUhUuMxJbfrz5U2UooiZwhgs69D/t8IowMvBI6Lk4ZR8HnCSxYwWHVRKyQnEMNgJPA==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/json-schema": { "version": "7.0.12", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz", @@ -1094,9 +1095,10 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.4.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.1.tgz", - "integrity": "sha512-JIzsAvJeA/5iY6Y/OxZbv1lUcc8dNSE77lb2gnBH+/PJ3lFR1Ccvgwl5JWnHAkNHcRsT0TbpVOsiMKZ1F/yyJg==" + "version": "20.5.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.1.tgz", + "integrity": "sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg==", + "dev": true }, "node_modules/@types/proxyquire": { "version": "1.3.28", @@ -1111,9 +1113,9 @@ "dev": true }, "node_modules/@types/sinon": { - "version": "10.0.15", - "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.15.tgz", - "integrity": "sha512-3lrFNQG0Kr2LDzvjyjB6AMJk4ge+8iYhQfdnSwIwlG88FUOV43kPcQqDZkDa/h3WSZy6i8Fr0BSjfQtB1B3xuQ==", + "version": "10.0.16", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-10.0.16.tgz", + "integrity": "sha512-j2Du5SYpXZjJVJtXBokASpPRj+e2z+VUhCPHmM6WMfe3dpHu6iVKJMU6AiBcMp/XTAYnEj6Wc1trJUWwZ0QaAQ==", "dev": true, "dependencies": { "@types/sinonjs__fake-timers": "*" @@ -1174,23 +1176,21 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.0.0.tgz", - "integrity": "sha512-xuv6ghKGoiq856Bww/yVYnXGsKa588kY3M0XK7uUW/3fJNNULKRfZfSBkMTSpqGG/8ZCXCadfh8G/z/B4aqS/A==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.4.0.tgz", + "integrity": "sha512-62o2Hmc7Gs3p8SLfbXcipjWAa6qk2wZGChXG2JbBtYpwSRmti/9KHLqfbLs9uDigOexG+3PaQ9G2g3201FWLKg==", "dev": true, "dependencies": { - "@eslint-community/regexpp": "^4.5.0", - "@typescript-eslint/scope-manager": "6.0.0", - "@typescript-eslint/type-utils": "6.0.0", - "@typescript-eslint/utils": "6.0.0", - "@typescript-eslint/visitor-keys": "6.0.0", + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/type-utils": "6.4.0", + "@typescript-eslint/utils": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", "debug": "^4.3.4", - "grapheme-splitter": "^1.0.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", "natural-compare": "^1.4.0", - "natural-compare-lite": "^1.4.0", - "semver": "^7.5.0", + "semver": "^7.5.4", "ts-api-utils": "^1.0.1" }, "engines": { @@ -1211,15 +1211,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.0.0.tgz", - "integrity": "sha512-TNaufYSPrr1U8n+3xN+Yp9g31vQDJqhXzzPSHfQDLcaO4tU+mCfODPxCwf4H530zo7aUBE3QIdxCXamEnG04Tg==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.4.0.tgz", + "integrity": "sha512-I1Ah1irl033uxjxO9Xql7+biL3YD7w9IU8zF+xlzD/YxY6a4b7DYA08PXUUCbm2sEljwJF6ERFy2kTGAGcNilg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.0.0", - "@typescript-eslint/types": "6.0.0", - "@typescript-eslint/typescript-estree": "6.0.0", - "@typescript-eslint/visitor-keys": "6.0.0", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/typescript-estree": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", "debug": "^4.3.4" }, "engines": { @@ -1239,13 +1239,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.0.0.tgz", - "integrity": "sha512-o4q0KHlgCZTqjuaZ25nw5W57NeykZT9LiMEG4do/ovwvOcPnDO1BI5BQdCsUkjxFyrCL0cSzLjvIMfR9uo7cWg==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.4.0.tgz", + "integrity": "sha512-TUS7vaKkPWDVvl7GDNHFQMsMruD+zhkd3SdVW0d7b+7Zo+bd/hXJQ8nsiUZMi1jloWo6c9qt3B7Sqo+flC1nig==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.0.0", - "@typescript-eslint/visitor-keys": "6.0.0" + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1256,13 +1256,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.0.0.tgz", - "integrity": "sha512-ah6LJvLgkoZ/pyJ9GAdFkzeuMZ8goV6BH7eC9FPmojrnX9yNCIsfjB+zYcnex28YO3RFvBkV6rMV6WpIqkPvoQ==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.4.0.tgz", + "integrity": "sha512-TvqrUFFyGY0cX3WgDHcdl2/mMCWCDv/0thTtx/ODMY1QhEiyFtv/OlLaNIiYLwRpAxAtOLOY9SUf1H3Q3dlwAg==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.0.0", - "@typescript-eslint/utils": "6.0.0", + "@typescript-eslint/typescript-estree": "6.4.0", + "@typescript-eslint/utils": "6.4.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -1283,9 +1283,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.0.0.tgz", - "integrity": "sha512-Zk9KDggyZM6tj0AJWYYKgF0yQyrcnievdhG0g5FqyU3Y2DRxJn4yWY21sJC0QKBckbsdKKjYDV2yVrrEvuTgxg==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.4.0.tgz", + "integrity": "sha512-+FV9kVFrS7w78YtzkIsNSoYsnOtrYVnKWSTVXoL1761CsCRv5wpDOINgsXpxD67YCLZtVQekDDyaxfjVWUJmmg==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1296,17 +1296,17 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.0.0.tgz", - "integrity": "sha512-2zq4O7P6YCQADfmJ5OTDQTP3ktajnXIRrYAtHM9ofto/CJZV3QfJ89GEaM2BNGeSr1KgmBuLhEkz5FBkS2RQhQ==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.4.0.tgz", + "integrity": "sha512-iDPJArf/K2sxvjOR6skeUCNgHR/tCQXBsa+ee1/clRKr3olZjZ/dSkXPZjG6YkPtnW6p5D1egeEPMCW6Gn4yLA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.0.0", - "@typescript-eslint/visitor-keys": "6.0.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/visitor-keys": "6.4.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", - "semver": "^7.5.0", + "semver": "^7.5.4", "ts-api-utils": "^1.0.1" }, "engines": { @@ -1323,19 +1323,18 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.0.0.tgz", - "integrity": "sha512-SOr6l4NB6HE4H/ktz0JVVWNXqCJTOo/mHnvIte1ZhBQ0Cvd04x5uKZa3zT6tiodL06zf5xxdK8COiDvPnQ27JQ==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.4.0.tgz", + "integrity": "sha512-BvvwryBQpECPGo8PwF/y/q+yacg8Hn/2XS+DqL/oRsOPK+RPt29h5Ui5dqOKHDlbXrAeHUTnyG3wZA0KTDxRZw==", "dev": true, "dependencies": { - "@eslint-community/eslint-utils": "^4.3.0", - "@types/json-schema": "^7.0.11", - "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "6.0.0", - "@typescript-eslint/types": "6.0.0", - "@typescript-eslint/typescript-estree": "6.0.0", - "eslint-scope": "^5.1.1", - "semver": "^7.5.0" + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.4.0", + "@typescript-eslint/types": "6.4.0", + "@typescript-eslint/typescript-estree": "6.4.0", + "semver": "^7.5.4" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1349,12 +1348,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.0.0.tgz", - "integrity": "sha512-cvJ63l8c0yXdeT5POHpL0Q1cZoRcmRKFCtSjNGJxPkcP571EfZMcNbzWAc7oK3D1dRzm/V5EwtkANTZxqvuuUA==", + "version": "6.4.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.4.0.tgz", + "integrity": "sha512-yJSfyT+uJm+JRDWYRYdCm2i+pmvXJSMtPR9Cq5/XQs4QIgNoLcoRtDdzsLbLsFM/c6um6ohQkg/MLxWvoIndJA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.0.0", + "@typescript-eslint/types": "6.4.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -2750,27 +2749,27 @@ } }, "node_modules/eslint": { - "version": "8.44.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.44.0.tgz", - "integrity": "sha512-0wpHoUbDUHgNCyvFB5aXLiQVfK9B0at6gUvzy83k4kAsQ/u769TQDX6iKC+aO4upIHO9WSaA3QoXYQDHbNwf1A==", + "version": "8.47.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.47.0.tgz", + "integrity": "sha512-spUQWrdPt+pRVP1TTJLmfRNJJHHZryFmptzcafwSvHsceV81djHOdnEeDmkdotZyLNjDhrOasNK8nikkoG1O8Q==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.4.0", - "@eslint/eslintrc": "^2.1.0", - "@eslint/js": "8.44.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.2", + "@eslint/js": "^8.47.0", "@humanwhocodes/config-array": "^0.11.10", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.0", - "eslint-visitor-keys": "^3.4.1", - "espree": "^9.6.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -2780,7 +2779,6 @@ "globals": "^13.19.0", "graphemer": "^1.4.0", "ignore": "^5.2.0", - "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", @@ -2792,7 +2790,6 @@ "natural-compare": "^1.4.0", "optionator": "^0.9.3", "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" }, "bin": { @@ -2806,23 +2803,14 @@ } }, "node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, "dependencies": { "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" + "estraverse": "^5.2.0" }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/eslint-visitor-keys": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", - "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", - "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -2830,15 +2818,11 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/eslint-scope": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.0.tgz", - "integrity": "sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw==", + "node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -2846,15 +2830,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, "node_modules/eslint/node_modules/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", @@ -2868,9 +2843,9 @@ } }, "node_modules/espree": { - "version": "9.6.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.0.tgz", - "integrity": "sha512-1FH/IiruXZ84tpUlm0aCUEwMl2Ho5ilqVh0VvQXw+byAz/4SAciyHLlfmL5WYqsvD38oymdUwBss0LtK8m4s/A==", + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, "dependencies": { "acorn": "^8.9.0", @@ -2909,15 +2884,6 @@ "node": ">=0.10" } }, - "node_modules/esquery/node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, "node_modules/esrecurse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", @@ -2930,7 +2896,7 @@ "node": ">=4.0" } }, - "node_modules/esrecurse/node_modules/estraverse": { + "node_modules/estraverse": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", @@ -2939,15 +2905,6 @@ "node": ">=4.0" } }, - "node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -4166,9 +4123,9 @@ } }, "node_modules/globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "version": "13.21.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.21.0.tgz", + "integrity": "sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -4218,12 +4175,6 @@ "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, - "node_modules/grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", - "dev": true - }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -5880,12 +5831,6 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, - "node_modules/natural-compare-lite": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", - "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", - "dev": true - }, "node_modules/next-tick": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", @@ -6826,9 +6771,9 @@ } }, "node_modules/procon-ip": { - "version": "1.6.4", - "resolved": "https://registry.npmjs.org/procon-ip/-/procon-ip-1.6.4.tgz", - "integrity": "sha512-f+cFXdX6YP3UndW14G7MDqVAl81DPECTQH3k5BR53+JubQwB7HTLH0I9LZmq0QzF0FolpTcmo/yZXcUylHwdQw==", + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/procon-ip/-/procon-ip-1.7.1.tgz", + "integrity": "sha512-QPZR9cNsmYszLPB/kp9iixi7fomIGquxMqDEKrm91U7mGAi1dWHfSoGMDU09t2K6rgeHDLpGGp24vcHuiPgK9w==", "dependencies": { "axios": "^1.4.0" } diff --git a/package.json b/package.json index fc1f832..c1360e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iobroker.procon-ip", - "version": "1.3.3", + "version": "1.4.0", "description": "Adapter for basic support of the ProCon.IP pool control. Intended for integration with your voice assistant (eg. via the `cloud` adapter for Alexa or `yahka` for Apple HomeKit with Siri).", "author": { "name": "Yannic Labonte", @@ -29,8 +29,8 @@ "node": ">=16" }, "dependencies": { - "@iobroker/adapter-core": "^2.6.8", - "procon-ip": "^1.6.4" + "@iobroker/adapter-core": "^3.0.3", + "procon-ip": "^1.7.1" }, "devDependencies": { "@iobroker/testing": "^4.1.0", @@ -39,16 +39,16 @@ "@types/crypto-js": "^4.1.1", "@types/gulp": "^4.0.13", "@types/mocha": "^10.0.1", - "@types/node": "^20.4.1", + "@types/node": "^20.5.1", "@types/proxyquire": "^1.3.28", - "@types/sinon": "^10.0.15", + "@types/sinon": "^10.0.16", "@types/sinon-chai": "^3.2.9", - "@typescript-eslint/eslint-plugin": "^6.0.0", - "@typescript-eslint/parser": "^6.0.0", + "@typescript-eslint/eslint-plugin": "^6.4.0", + "@typescript-eslint/parser": "^6.4.0", "chai": "^4.3.7", "chai-as-promised": "^7.1.1", "crypto-js": "^4.1.1", - "eslint": "^8.44.0", + "eslint": "^8.47.0", "gulp": "^4.0.2", "mocha": "^10.2.0", "nyc": "^15.1.0", diff --git a/src/main.ts b/src/main.ts index 927ff5a..2f0b97e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,7 +14,8 @@ import { RelayDataInterpreter, GetStateCategory, GetStateData, GetStateDataSysInfo, - GetStateDataObject + GetStateDataObject, + SetStateService } from "procon-ip"; import {CryptoHelper} from "./lib/crypto-helper"; @@ -42,6 +43,7 @@ export class ProconIp extends utils.Adapter { private _relayDataInterpreter!: RelayDataInterpreter; private _getStateService!: GetStateService; + private _setStateService!: SetStateService; private _usrcfgCgiService!: UsrcfgCgiService; private _commandService!: CommandService; private _forceUpdate: number[]; @@ -115,6 +117,7 @@ export class ProconIp extends utils.Adapter { }); this._relayDataInterpreter = new RelayDataInterpreter(this.log); this._getStateService = new GetStateService(serviceConfig as IGetStateServiceConfig, this.log); + this._setStateService = new SetStateService(serviceConfig as IServiceConfig, this.log); this._usrcfgCgiService = new UsrcfgCgiService(serviceConfig as IServiceConfig, this.log, this._getStateService, this._relayDataInterpreter); this._commandService = new CommandService(serviceConfig as IServiceConfig, this.log); @@ -249,6 +252,10 @@ export class ProconIp extends utils.Adapter { this.setDosageTimer(id, state).catch((e) => { this.log.error(`Error on manual dosage (${id}): ${e}`); }); + } else if (id.endsWith(".timer")) { + this.setRelayTimer(id, state).catch((e) => { + this.log.error(`Error on relay timer (${id}): ${e}`); + }); } } @@ -328,6 +335,25 @@ export class ProconIp extends utils.Adapter { } } + public async setRelayTimer(objectId: string, state: ioBroker.State): Promise { + const obj = await this.getObjectAsync(objectId); + if (!obj) { + throw new Error(`Cannot handle state change for non-existent object '${objectId}'`); + } + + const getStateDataObject: GetStateDataObject = this._stateData.getDataObject(obj.native.id); + const relayId = getStateDataObject.categoryId + + (getStateDataObject.category === GetStateCategory.EXTERNAL_RELAYS ? 9 : 1); + this._forceUpdate.push(getStateDataObject.id); + try { + const stateValNumber = state.val as number; + await this._setStateService.setTimer(relayId, stateValNumber); + this.log.info(`Setting timer for ${obj.native.label} to ${state.val} seconds`); + } catch (e: any) { + this.log.error(e); + } + } + // /** // * Some message was sent to this instance over message box. Used by email, pushover, text2speech, ... // * Using this method requires "common.message" property to be set to true in io-package.json @@ -586,13 +612,27 @@ export class ProconIp extends utils.Adapter { role: "value.interval", read: false, write: true, - } + }; this.setObjectNotExists(`${this.name}.${this.instance}.${obj.category}.${obj.categoryId}.dosageTimer`, { type: "state", common: commonDosageTimerState, native: obj, }); + } else { + const commonGenericRelayTimerState: any = { + name: obj.label, + type: "number", + role: "value.interval", + read: false, + write: true, + }; + + this.setObjectNotExists(`${this.name}.${this.instance}.${obj.category}.${obj.categoryId}.timer`, { + type: "state", + common: commonGenericRelayTimerState, + native: obj, + }); } // this.setObjectNotExistsAsync(`${this.name}.${this.instance}.${obj.category}.${obj.categoryId}.auto`, {