Skip to content

Commit

Permalink
Merge branch 'emsesp:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy authored Dec 3, 2023
2 parents 80f4e63 + f9b8ac6 commit 9375fb4
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 38 deletions.
2 changes: 1 addition & 1 deletion interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@types/imagemin": "^8.0.5",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.10.2",
"@types/react": "^18.2.40",
"@types/react": "^18.2.41",
"@types/react-dom": "^18.2.17",
"@types/react-router-dom": "^5.3.3",
"alova": "^2.15.0",
Expand Down
30 changes: 17 additions & 13 deletions interface/src/framework/mqtt/MqttSettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,24 @@ const MqttSettingsForm: FC = () => {
<MenuItem value={2}>2</MenuItem>
</TextField>
</Grid>
{data.rootCA !== undefined && (
<Grid item xs={12} sm={6}>
<ValidatedPasswordField
name="rootCA"
label={LL.CERT()}
fullWidth
variant="outlined"
value={data.rootCA}
onChange={updateFormValue}
margin="normal"
/>
</Grid>
)}
</Grid>
{data.enableTLS !== undefined && (
<BlockFormControlLabel
control={<Checkbox name="enableTLS" checked={data.enableTLS} onChange={updateFormValue} />}
label={LL.ENABLE_TLS()}
/>
)}
{data.enableTLS === true && (
<ValidatedPasswordField
name="rootCA"
label={LL.CERT()}
fullWidth
variant="outlined"
value={data.rootCA}
onChange={updateFormValue}
margin="normal"
/>
)}

<BlockFormControlLabel
control={<Checkbox name="clean_session" checked={data.clean_session} onChange={updateFormValue} />}
Expand Down
3 changes: 2 additions & 1 deletion interface/src/i18n/de/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ const de: Translation = {
WRITEABLE: 'Schreibbar',
SHOWING: 'Anzeigen von',
SEARCH: 'Suche',
CERT: 'TLS Zertifikat (Freilassen um TLS zu deaktivieren)',
CERT: 'TLS Zertifikat (Freilassen für unsichere Verbindung)',
ENABLE_TLS: 'Aktiviere TLS',
ON: 'An',
OFF: 'Aus',
POLARITY: 'Polarität',
Expand Down
3 changes: 2 additions & 1 deletion interface/src/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ const en: Translation = {
WRITEABLE: 'Writeable',
SHOWING: 'Showing',
SEARCH: 'Search',
CERT: 'TLS root certificate (leave blank to disable TLS)',
CERT: 'TLS root certificate (leave blank for insecure)',
ENABLE_TLS: 'Enable TLS',
ON: 'On',
OFF: 'Off',
POLARITY: 'Polarity',
Expand Down
3 changes: 2 additions & 1 deletion interface/src/i18n/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ const fr: Translation = {
WRITEABLE: 'Writeable', // TODO translate
SHOWING: 'Showing', // TODO translate
SEARCH: 'Search', // TODO translate
CERT: 'TLS root certificate (leave blank to disable TLS)', // TODO translate
CERT: 'TLS root certificate (leave blank for insecure)', // TODO translate
ENABLE_TLS: 'Activer TLS',
ON: 'On', // TODO translate
OFF: 'Off', // TODO translate
POLARITY: 'Polarity', // TODO translate
Expand Down
3 changes: 2 additions & 1 deletion interface/src/i18n/it/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ const it: Translation = {
WRITEABLE: 'Scrivibile',
SHOWING: 'Visualizza',
SEARCH: 'Ricerca',
CERT: 'TLS root certificate (leave blank to disable TLS)', // TODO translate
CERT: 'TLS root certificate (leave blank for insecure)', // TODO translate
ENABLE_TLS: 'Abilita TLS',
ON: 'On', // TODO translate
OFF: 'Off', // TODO translate
POLARITY: 'Polarity', // TODO translate
Expand Down
3 changes: 2 additions & 1 deletion interface/src/i18n/nl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ const nl: Translation = {
WRITEABLE: 'Beschrijfbare',
SHOWING: 'Tonen',
SEARCH: 'Zoek',
CERT: 'TLS rootcertificaat (laat leeg om TLS uit te schakelen)',
CERT: 'TLS rootcertificaat (laat leeg om TLS-insecure)', // TODO translate
ENABLE_TLS: 'Activeer TLS',
ON: 'On', // TODO translate
OFF: 'Off', // TODO translate
POLARITY: 'Polarity', // TODO translate
Expand Down
3 changes: 2 additions & 1 deletion interface/src/i18n/no/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ const no: Translation = {
WRITEABLE: 'Writeable', // TODO translate
SHOWING: 'Showing', // TODO translate
SEARCH: 'Search', // TODO translate
CERT: 'TLS root certificate (leave blank to disable TLS)', // TODO translate
CERT: 'TLS root certificate (leave blank for insecure)', // TODO translate
ENABLE_TLS: 'Aktiviser TLS',
ON: 'On', // TODO translate
OFF: 'Off', // TODO translate
POLARITY: 'Polarity', // TODO translate
Expand Down
3 changes: 2 additions & 1 deletion interface/src/i18n/pl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ const pl: BaseTranslation = {
WRITEABLE: 'zapisywalna',
SHOWING: 'Wyświetlane',
SEARCH: 'Szukaj',
CERT: 'Certyfikat główny TLS (pozostaw puste zby wyłączyć TLS)',
CERT: 'Certyfikat główny TLS (pozostaw puste zby wyłączyć TLS-insecure)',
ENABLE_TLS: 'Włącz wsparcie dla TLS',
ON: 'włączony',
OFF: 'wyłączony',
POLARITY: 'Typ przekaźnika',
Expand Down
3 changes: 2 additions & 1 deletion interface/src/i18n/sv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ const sv: Translation = {
WRITEABLE: 'Writeable', // TODO translate
SHOWING: 'Showing', // TODO translate
SEARCH: 'Search', // TODO translate
CERT: 'TLS root certificate (leave blank to disable TLS)', // TODO translate
CERT: 'TLS root certificate (leave blank for insecure)', // TODO translate
ENABLE_TLS: 'Aktivera TLS',
ON: 'On', // TODO translate
OFF: 'Off', // TODO translate
POLARITY: 'Polarity', // TODO translate
Expand Down
3 changes: 2 additions & 1 deletion interface/src/i18n/tr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ const tr: Translation = {
WRITEABLE: 'Writeable', // TODO translate
SHOWING: 'Showing', // TODO translate
SEARCH: 'Search', // TODO translate
CERT: 'TLS root certificate (leave blank to disable TLS)', // TODO translate
CERT: 'TLS root certificate (leave blank for insecure)',
ENABLE_TLS: 'TLS deveye al',
ON: 'On', // TODO translate
OFF: 'Off', // TODO translate
POLARITY: 'Polarity', // TODO translate
Expand Down
1 change: 1 addition & 0 deletions interface/src/types/mqtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface MqttSettings {
port: number;
base: string;
rootCA?: string;
enableTLS?: boolean;
username: string;
password: string;
client_id: string;
Expand Down
10 changes: 5 additions & 5 deletions interface/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1606,14 +1606,14 @@ __metadata:
languageName: node
linkType: hard

"@types/react@npm:^18.2.40":
version: 18.2.40
resolution: "@types/react@npm:18.2.40"
"@types/react@npm:^18.2.41":
version: 18.2.41
resolution: "@types/react@npm:18.2.41"
dependencies:
"@types/prop-types": "npm:*"
"@types/scheduler": "npm:*"
csstype: "npm:^3.0.2"
checksum: 323c319461482ad17b4813fec8641a4167361f42164757b64dbe27db379ae8fd98f3811a301f4abce0c17ce53a83c549db3ba3008e54d2a422a0656bddd72440
checksum: 31a498a56ad3e825ae13799355fe49042c0cdbbe6f40003f39b6b9cf847ba1669393c22ba60e97b1072cf1c002b15432082cdd17e47c948430bdc1f0864829b9
languageName: node
linkType: hard

Expand Down Expand Up @@ -1794,7 +1794,7 @@ __metadata:
"@types/imagemin": "npm:^8.0.5"
"@types/lodash-es": "npm:^4.17.12"
"@types/node": "npm:^20.10.2"
"@types/react": "npm:^18.2.40"
"@types/react": "npm:^18.2.41"
"@types/react-dom": "npm:^18.2.17"
"@types/react-router-dom": "npm:^5.3.3"
"@typescript-eslint/eslint-plugin": "npm:^6.13.1"
Expand Down
20 changes: 11 additions & 9 deletions lib/framework/MqttSettingsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ void MqttSettingsService::startClient() {
static bool isSecure = false;
if (_mqttClient != nullptr) {
// do we need to change the client?
if ((isSecure && _state.rootCA.length() > 0) || (!isSecure && _state.rootCA.length() == 0)) {
if ((isSecure && _state.enableTLS) || (!isSecure && _state.enableTLS)) {
return;
}
delete _mqttClient;
}
#if CONFIG_IDF_TARGET_ESP32S3
if (_state.rootCA.length() > 0) {
if (_state.enableTLS) {
isSecure = true;
_mqttClient = static_cast<MqttClient *>(new espMqttClientSecure(espMqttClientTypes::UseInternalTask::NO));
if (_state.rootCA == "insecure") {
Expand Down Expand Up @@ -100,7 +100,7 @@ const char * MqttSettingsService::getClientId() {

void MqttSettingsService::setWill(const char * topic) {
#if CONFIG_IDF_TARGET_ESP32S3
if (_state.rootCA.length() > 0) {
if (_state.enableTLS) {
static_cast<espMqttClientSecure *>(_mqttClient)->setWill(topic, 1, true, "offline");
return;
}
Expand All @@ -110,7 +110,7 @@ void MqttSettingsService::setWill(const char * topic) {

void MqttSettingsService::onMessage(espMqttClientTypes::OnMessageCallback callback) {
#if CONFIG_IDF_TARGET_ESP32S3
if (_state.rootCA.length() > 0) {
if (_state.enableTLS) {
static_cast<espMqttClientSecure *>(_mqttClient)->onMessage(callback);
return;
}
Expand Down Expand Up @@ -181,7 +181,7 @@ bool MqttSettingsService::configureMqtt() {
if (_state.enabled && emsesp::EMSESP::system_.network_connected() && !_state.host.isEmpty()) {
_reconfigureMqtt = false;
#if CONFIG_IDF_TARGET_ESP32S3
if (_state.rootCA.length() > 0) {
if (_state.enableTLS) {
// emsesp::EMSESP::logger().info("Start secure MQTT with rootCA");
static_cast<espMqttClientSecure *>(_mqttClient)->setServer(retainCstr(_state.host.c_str(), &_retainedHost), _state.port);
if (_state.username.length() > 0) {
Expand Down Expand Up @@ -217,7 +217,8 @@ bool MqttSettingsService::configureMqtt() {

void MqttSettings::read(MqttSettings & settings, JsonObject & root) {
#if CONFIG_IDF_TARGET_ESP32S3
root["rootCA"] = settings.rootCA;
root["enableTLS"] = settings.enableTLS;
root["rootCA"] = settings.rootCA;
#endif
root["enabled"] = settings.enabled;
root["host"] = settings.host;
Expand Down Expand Up @@ -253,7 +254,8 @@ StateUpdateResult MqttSettings::update(JsonObject & root, MqttSettings & setting
bool changed = false;

#if CONFIG_IDF_TARGET_ESP32S3
newSettings.rootCA = root["rootCA"] | "";
newSettings.enableTLS = root["enableTLS"] | false;
newSettings.rootCA = root["rootCA"] | "";
#endif
newSettings.enabled = root["enabled"] | FACTORY_MQTT_ENABLED;
newSettings.host = root["host"] | FACTORY_MQTT_HOST;
Expand Down Expand Up @@ -377,10 +379,10 @@ StateUpdateResult MqttSettings::update(JsonObject & root, MqttSettings & setting
newSettings.rootCA.replace("-----BEGIN CERTIFICATE-----", "");
newSettings.rootCA.replace("-----END CERTIFICATE-----", "");
newSettings.rootCA.replace(" ", "");
if (newSettings.rootCA.length() == 0 && newSettings.port > 8800) {
if (newSettings.rootCA.length() == 0 && newSettings.enableTLS) {
newSettings.rootCA = "insecure";
}
if (newSettings.rootCA != settings.rootCA) {
if (newSettings.enableTLS != settings.enableTLS || newSettings.rootCA != settings.rootCA) {
changed = true;
}
#endif
Expand Down
1 change: 1 addition & 0 deletions lib/framework/MqttSettingsService.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class MqttSettings {
String host;
uint16_t port;
String rootCA;
bool enableTLS;

// username and password
String username;
Expand Down
4 changes: 4 additions & 0 deletions src/devices/boiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const
DeviceValueTAG::TAG_DEVICE_DATA, &boilHystOn_, DeviceValueType::INT, FL_(boilHystOn), DeviceValueUOM::DEGREES_R, MAKE_CF_CB(set_hyst_on), -20, 0);
register_device_value(
DeviceValueTAG::TAG_DEVICE_DATA, &boilHystOff_, DeviceValueType::INT, FL_(boilHystOff), DeviceValueUOM::DEGREES_R, MAKE_CF_CB(set_hyst_off), 0, 20);
register_device_value(
DeviceValueTAG::TAG_DEVICE_DATA, &boil2HystOn_, DeviceValueType::INT, FL_(boil2HystOn), DeviceValueUOM::DEGREES_R, MAKE_CF_CB(set_hyst2_on), -20, 0);
register_device_value(
DeviceValueTAG::TAG_DEVICE_DATA, &boil2HystOff_, DeviceValueType::INT, FL_(boil2HystOff), DeviceValueUOM::DEGREES_R, MAKE_CF_CB(set_hyst2_off), 0, 20);
}
register_device_value(DeviceValueTAG::TAG_DEVICE_DATA,
&heatingActivated_,
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.6.5-dev.2"
#define EMSESP_APP_VERSION "3.6.5-dev.3"

0 comments on commit 9375fb4

Please sign in to comment.