From 11cb7ed4fa3e78e8af1c98d0f18d0a4a939fa80b Mon Sep 17 00:00:00 2001 From: Terdious Date: Wed, 11 Feb 2026 15:58:20 +0100 Subject: [PATCH 01/90] add cloud discovery metadata --- front/src/config.js | 4 +- front/src/config/i18n/de.json | 22 ++- front/src/config/i18n/en.json | 22 ++- front/src/config/i18n/fr.json | 20 +- .../integration/all/tuya/TuyaDeviceBox.jsx | 52 +++++- .../all/tuya/discover-page/DiscoverTab.jsx | 64 ++++++- .../all/tuya/setup-page/SetupTab.jsx | 173 ++++++++++++++++-- .../tuya/lib/device/tuya.convertDevice.js | 25 ++- server/services/tuya/lib/index.js | 1 + server/services/tuya/lib/tuya.connect.js | 11 +- .../tuya/lib/tuya.getConfiguration.js | 2 + .../tuya/lib/tuya.loadDeviceDetails.js | 24 ++- server/services/tuya/lib/tuya.loadDevices.js | 22 +-- .../tuya/lib/tuya.saveConfiguration.js | 3 +- .../services/tuya/lib/utils/tuya.constants.js | 9 + .../services/tuya/lib/tuya.connect.test.js | 10 +- .../tuya/lib/tuya.discoverDevices.test.js | 37 +++- .../tuya/lib/tuya.getConfiguration.test.js | 8 +- .../tuya/lib/tuya.loadDeviceDetails.test.js | 17 +- .../tuya/lib/tuya.loadDevices.test.js | 14 +- .../tuya/lib/tuya.saveConfiguration.test.js | 4 +- server/utils/constants.js | 1 + 22 files changed, 459 insertions(+), 86 deletions(-) diff --git a/front/src/config.js b/front/src/config.js index 2e8aa5b2af..f29374d2c3 100644 --- a/front/src/config.js +++ b/front/src/config.js @@ -1,7 +1,7 @@ const local = { gladysGatewayApiUrl: process.env.GLADYS_GATEWAY_API_URL || 'https://api.gladysgateway.com', - localApiUrl: process.env.LOCAL_API_URL || 'http://localhost:1443', - webSocketUrl: process.env.WEBSOCKET_URL || 'ws://localhost:1443', + localApiUrl: process.env.LOCAL_API_URL || 'http://10.1.0.62:1443', + webSocketUrl: process.env.WEBSOCKET_URL || 'ws://10.1.0.62:1443', gatewayMode: process.env.GATEWAY_MODE === 'true', demoMode: process.env.DEMO_MODE === 'true', demoRequestTime: process.env.DEMO_REQUEST_TIME || 0, diff --git a/front/src/config/i18n/de.json b/front/src/config/i18n/de.json index c2d955661b..1af20b6c5b 100644 --- a/front/src/config/i18n/de.json +++ b/front/src/config/i18n/de.json @@ -1175,14 +1175,18 @@ "updates": "Nach Updates suchen", "editButton": "Bearbeiten", "noDeviceFound": "Du hast noch keine Tuya-Geräte hinzugefügt.", - "featuresLabel": "Funktionen" + "featuresLabel": "Funktionen", + "idLabel": "Geräte-ID", + "localKeyLabel": "Lokaler Schlüssel" }, "discover": { "title": "In deinem Tuya-Cloud-Account erkannte Geräte", "description": "Tuya-Geräte werden automatisch erkannt. Deine Tuya-Geräte müssen zuerst zu deinem Tuya-Cloud-Account hinzugefügt werden.", "error": "Fehler beim Entdecken von Tuya-Geräten. Bitte überprüfe deine Login-Daten auf der Einrichtungsseite.", "noDeviceFound": "Kein Tuya-Gerät entdeckt.", - "scan": "Scannen" + "scan": "Scannen", + "addSelected": "Auswahl hinzufügen", + "addSelectedError": "Fehler beim Hinzufügen der ausgewählten Geräte." }, "setup": { "title": "Tuya-Konfiguration", @@ -1201,12 +1205,14 @@ "india": "Indien" }, "endpoint": "Endpunkt", - "accessKey": "Access Key", - "accessKeyPlaceholder": "Tuya Zugangsschlüssel eingeben", - "secretKey": "Secret Key", - "secretKeyPlaceholder": "Tuya Geheimschlüssel eingeben", - "appAccountId": "App Account UID", - "appAccountIdPlaceholder": "Tuya App UID eingeben", + "accessKey": "Client ID", + "accessKeyPlaceholder": "Tuya Client ID eingeben", + "secretKey": "Client Secret", + "secretKeyPlaceholder": "Tuya Client Secret eingeben", + "appAccountId": "App Account User ID", + "appAccountIdPlaceholder": "Tuya App User ID eingeben", + "appUsername": "App Username", + "appUsernamePlaceholder": "Tuya App Username eingeben", "saveLabel": "Konfiguration sichern", "error": "Beim Sichern der Konfiguration ist ein Fehler aufgetreten.", "connecting": "Konfiguration gesichert. Die Verbindung mit deinem Tuya-Cloud-Account wird jetzt hergestellt …", diff --git a/front/src/config/i18n/en.json b/front/src/config/i18n/en.json index ac15af5b8c..8972039793 100644 --- a/front/src/config/i18n/en.json +++ b/front/src/config/i18n/en.json @@ -1070,14 +1070,18 @@ "updates": "Check updates", "editButton": "Edit", "noDeviceFound": "No Tuya device found.", - "featuresLabel": "Features" + "featuresLabel": "Features", + "idLabel": "Device ID", + "localKeyLabel": "Local Key" }, "discover": { "title": "Devices detected on your Tuya cloud account", "description": "Tuya devices are automatically discovered. Your Tuya devices need to be added to your Tuya cloud account before.", "error": "Error discovering Tuya devices. Please verify your credentials on Setup.", "noDeviceFound": "No Tuya device discovered.", - "scan": "Scan" + "scan": "Scan", + "addSelected": "Add selected", + "addSelectedError": "Error adding selected devices." }, "setup": { "title": "Tuya configuration", @@ -1096,12 +1100,14 @@ "india": "India" }, "endpoint": "Endpoint", - "accessKey": "Access Key", - "accessKeyPlaceholder": "Enter Tuya access key", - "secretKey": "Secret Key", - "secretKeyPlaceholder": "Enter Tuya secret key", - "appAccountId": "App account UID", - "appAccountIdPlaceholder": "Enter Tuya application UID", + "accessKey": "Client ID", + "accessKeyPlaceholder": "Enter Tuya Client ID", + "secretKey": "Client Secret", + "secretKeyPlaceholder": "Enter Tuya Client Secret", + "appAccountId": "App account User ID", + "appAccountIdPlaceholder": "Enter Tuya app User ID", + "appUsername": "App Username", + "appUsernamePlaceholder": "Enter Tuya app Username", "saveLabel": "Save configuration", "error": "An error occurred while saving configuration.", "connecting": "Configuration saved. Now connecting to your Tuya cloud account...", diff --git a/front/src/config/i18n/fr.json b/front/src/config/i18n/fr.json index 9423b8534a..c9cb42e5a3 100644 --- a/front/src/config/i18n/fr.json +++ b/front/src/config/i18n/fr.json @@ -1305,14 +1305,18 @@ "updates": "Vérifier les mises à jour", "editButton": "Éditer", "noDeviceFound": "Aucun appareil Tuya trouvé.", - "featuresLabel": "Fonctionnalités" + "featuresLabel": "Fonctionnalités", + "idLabel": "Identifiant de l'appareil", + "localKeyLabel": "Clé locale" }, "discover": { "title": "Appareils détectés sur votre compte cloud Tuya", "description": "Les appareils Tuya sont automatiquement découverts. Vos appareils Tuya doivent être ajoutés à votre compte cloud Tuya avant.", "error": "Erreur de découverte des appareils Tuya. Veuillez vérifier vos informations d'identification lors de l'installation.", "noDeviceFound": "Aucun appareil Tuya n'a été découvert.", - "scan": "Scanner" + "scan": "Scanner", + "addSelected": "Ajouter la sélection", + "addSelectedError": "Erreur lors de l'ajout des appareils sélectionnés." }, "setup": { "title": "Configuration Tuya", @@ -1331,12 +1335,14 @@ "india": "India" }, "endpoint": "Endpoint", - "accessKey": "Access Key", - "accessKeyPlaceholder": "Entrez l'Access Key de Tuya", - "secretKey": "Secret Key", - "secretKeyPlaceholder": "Entrez la Secret Key de Tuya", - "appAccountId": "App account UID", + "accessKey": "Client ID", + "accessKeyPlaceholder": "Entrez le 'Client ID' de Tuya", + "secretKey": "Client Secret", + "secretKeyPlaceholder": "Entrez le 'Client Secret' de Tuya", + "appAccountId": "App account User ID", "appAccountIdPlaceholder": "Entrez l'UID de l'app de Tuya", + "appUsername": "App Username", + "appUsernamePlaceholder": "Entrez le Username de l'app de Tuya", "saveLabel": "Enregistrer la configuration", "error": "Une erreur s'est produite lors de la sauvegarde de la configuration.", "connecting": "Configuration sauvegardée. Connexion à votre compte cloud Tuya...", diff --git a/front/src/routes/integration/all/tuya/TuyaDeviceBox.jsx b/front/src/routes/integration/all/tuya/TuyaDeviceBox.jsx index 7e202253a0..39723f0124 100644 --- a/front/src/routes/integration/all/tuya/TuyaDeviceBox.jsx +++ b/front/src/routes/integration/all/tuya/TuyaDeviceBox.jsx @@ -99,23 +99,45 @@ class TuyaDeviceBox extends Component { saveButton, updateButton, alreadyCreatedButton, - housesWithRooms + housesWithRooms, + selectable, + selected, + onToggleSelected }, { device, loading, errorMessage, tooMuchStatesError, statesNumber } ) { const validModel = device.features && device.features.length > 0; const online = device.online; + const params = (device.params || []).reduce((acc, param) => { + acc[param.name] = param.value; + return acc; + }, {}); + const deviceId = params.DEVICE_ID || (device.external_id ? device.external_id.split(':')[1] : ''); + const localKey = params.LOCAL_KEY || device.local_key || ''; return (
-
+
}>  {device.name}
+ {selectable && ( +
+ onToggleSelected && onToggleSelected(device.external_id)} + /> +
+ )}
+
+ + +
+ +
+ + +
+