Skip to content

Commit

Permalink
Feature: show hint if device profile missing or not selected
Browse files Browse the repository at this point in the history
  • Loading branch information
schlimmchen committed Dec 3, 2024
1 parent d85b53a commit 1a0a988
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions include/PinMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class PinMappingClass {
bool init(const String& deviceMapping);
PinMapping_t& get();

bool isMappingSelected() const { return _mappingSelected; }

bool isValidNrf24Config() const;
bool isValidCmt2300Config() const;
bool isValidW5500Config() const;
Expand All @@ -92,6 +94,8 @@ class PinMappingClass {

private:
PinMapping_t _pinMapping;

bool _mappingSelected = false;
};

extern PinMappingClass PinMapping;
2 changes: 2 additions & 0 deletions src/PinMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ bool PinMappingClass::init(const String& deviceMapping)
for (uint8_t i = 0; i < doc.size(); i++) {
String devName = doc[i]["name"] | "";
if (devName == deviceMapping) {
_mappingSelected = true;

strlcpy(_pinMapping.name, devName.c_str(), sizeof(_pinMapping.name));
_pinMapping.nrf24_clk = doc[i]["nrf24"]["clk"] | HOYMILES_PIN_SCLK;
_pinMapping.nrf24_cs = doc[i]["nrf24"]["cs"] | HOYMILES_PIN_CS;
Expand Down
3 changes: 3 additions & 0 deletions src/WebApi_ws_live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ void WebApiWsLiveClass::generateCommonJsonResponse(JsonVariant& root)
hintObj["time_sync"] = !getLocalTime(&timeinfo, 5);
hintObj["radio_problem"] = (Hoymiles.getRadioNrf()->isInitialized() && (!Hoymiles.getRadioNrf()->isConnected() || !Hoymiles.getRadioNrf()->isPVariant())) || (Hoymiles.getRadioCmt()->isInitialized() && (!Hoymiles.getRadioCmt()->isConnected()));
hintObj["default_password"] = strcmp(Configuration.get().Security.Password, ACCESS_POINT_PASSWORD) == 0;

bool isGeneric = std::string(PIOENV).find("generic") != std::string::npos;
hintObj["pin_mapping_issue"] = isGeneric && !PinMapping.isMappingSelected();
}

void WebApiWsLiveClass::generateInverterCommonJsonResponse(JsonObject& root, std::shared_ptr<InverterAbstract> inv)
Expand Down
7 changes: 7 additions & 0 deletions webapp/src/components/HintView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
</div>
</div>
</BootstrapAlert>

<BootstrapAlert :show="hints.pin_mapping_issue" variant="warning">
<div class="d-flex">
<div class="align-content-center"><BIconExclamationCircle class="fs-4" /></div>
<div class="align-content-center ms-3" v-html="$t('hints.PinMappingIssue')"></div>
</div>
</BootstrapAlert>
</template>

<script lang="ts">
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,8 @@
"TimeSync": "Die Uhr wurde noch nicht synchronisiert. Ohne eine korrekt eingestellte Uhr werden keine Anfragen an den Wechselrichter gesendet. Dies ist kurz nach dem Start normal. Nach einer längeren Laufzeit (>1 Minute) bedeutet es jedoch, dass der NTP-Server nicht erreichbar ist.",
"TimeSyncLink": "Bitte überprüfen Sie Ihre Zeiteinstellungen.",
"DefaultPassword": "Sie verwenden das Standardpasswort für die Weboberfläche und den Notfall Access Point. Dies ist potenziell unsicher.",
"DefaultPasswordLink": "Bitte ändern Sie das Passwort."
"DefaultPasswordLink": "Bitte ändern Sie das Passwort.",
"PinMappingIssue": "Sie verwenden eine generische Firmware, haben jedoch noch keine Datei mit Verdrahtungsprofilen (<code>pin_mapping.json</code>) hochgeladen oder kein dort definiertes Profil ausgewählt. Details hierzu entnehmen Sie bitte der <a href=\"https://opendtu-onbattery.net/firmware/device_profiles/\" target=\"_blank\" class=\"alert-link\">Dokumentation</a>."
},
"deviceadmin": {
"DeviceManager": "Hardware-Einstellungen",
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,8 @@
"TimeSync": "The clock has not yet been synchronised. Without a correctly set clock, no requests are made to the inverter. This is normal shortly after the start. However, after a longer runtime (>1 minute), it indicates that the NTP server is not accessible.",
"TimeSyncLink": "Please check your time settings.",
"DefaultPassword": "You are using the default password for the web interface and the emergency access point. This is potentially insecure.",
"DefaultPasswordLink": "Please change the password."
"DefaultPasswordLink": "Please change the password.",
"PinMappingIssue": "You are using a generic firmware image, but have not yet uploaded a file with device profiles (<code>pin_mapping.json</code>) or have not selected a profile defined there. Please refer to the <a href=\"https://opendtu-onbattery.net/firmware/device_profiles/\" target=\"_blank\" class=\"alert-link\">documentation</a> for details."
},
"deviceadmin": {
"DeviceManager": "Device-Manager",
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,8 @@
"TimeSync": "L'horloge n'a pas encore été synchronisée. Sans une horloge correctement réglée, aucune demande n'est adressée à l'onduleur. Ceci est normal peu de temps après le démarrage. Cependant, après un temps de fonctionnement plus long (>1 minute), cela indique que le serveur NTP n'est pas accessible.",
"TimeSyncLink": "Veuillez vérifier vos paramètres horaires.",
"DefaultPassword": "Vous utilisez le mot de passe par défaut pour l'interface Web et le point d'accès d'urgence. Ceci est potentiellement non sécurisé.",
"DefaultPasswordLink": "Merci de changer le mot de passe."
"DefaultPasswordLink": "Merci de changer le mot de passe.",
"PinMappingIssue": "Vous utilisez une image générique du micrologiciel, mais vous n'avez pas encore téléchargé un fichier contenant les profils de l'appareil (<code>pin_mapping.json</code>) ou vous n'avez pas sélectionné un profil défini dans ce fichier. Veuillez vous référer à la <a href=\"https://opendtu-onbattery.net/firmware/device_profiles/\" target=\"_blank\" class=\"alert-link\">documentation</a> pour plus de détails."
},
"deviceadmin": {
"DeviceManager": "Gestionnaire de périphériques",
Expand Down
1 change: 1 addition & 0 deletions webapp/src/types/LiveDataStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface Hints {
time_sync: boolean;
default_password: boolean;
radio_problem: boolean;
pin_mapping_issue: boolean;
}

export interface Vedirect {
Expand Down

0 comments on commit 1a0a988

Please sign in to comment.