From 914c2929f8afc70e28ba25be7d78337b29cc3652 Mon Sep 17 00:00:00 2001 From: Theo Arends Date: Fri, 30 Mar 2018 10:28:55 +0200 Subject: [PATCH 1/4] Revert Button Topic change --- sonoff/settings.ino | 4 ++-- sonoff/user_config.h | 4 +--- sonoff/xdrv_00_mqtt.ino | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sonoff/settings.ino b/sonoff/settings.ino index e1b0a7dcd..db75406b4 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -494,7 +494,7 @@ void SettingsDefaultSet2() strlcpy(Settings.mqtt_user, MQTT_USER, sizeof(Settings.mqtt_user)); strlcpy(Settings.mqtt_pwd, MQTT_PASS, sizeof(Settings.mqtt_pwd)); strlcpy(Settings.mqtt_topic, MQTT_TOPIC, sizeof(Settings.mqtt_topic)); - strlcpy(Settings.button_topic, MQTT_BUTTON_TOPIC, sizeof(Settings.button_topic)); + strlcpy(Settings.button_topic, "0", sizeof(Settings.button_topic)); strlcpy(Settings.mqtt_grptopic, MQTT_GRPTOPIC, sizeof(Settings.mqtt_grptopic)); Settings.tele_period = TELE_PERIOD; @@ -544,7 +544,7 @@ void SettingsDefaultSet2() SettingsDefaultSet_3_9_3(); - strlcpy(Settings.switch_topic, MQTT_SWITCH_TOPIC, sizeof(Settings.switch_topic)); + strlcpy(Settings.switch_topic, "0", sizeof(Settings.switch_topic)); strlcpy(Settings.web_password, WEB_PASSWORD, sizeof(Settings.web_password)); diff --git a/sonoff/user_config.h b/sonoff/user_config.h index 178f414f6..68cafc6be 100644 --- a/sonoff/user_config.h +++ b/sonoff/user_config.h @@ -126,8 +126,6 @@ // %topic% token options (also ButtonTopic and SwitchTopic) #define MQTT_TOPIC PROJECT // [Topic] (unique) MQTT device topic #define MQTT_GRPTOPIC "sonoffs" // [GroupTopic] MQTT Group topic -#define MQTT_BUTTON_TOPIC "0" // [ButtonTopic] MQTT button topic -#define MQTT_SWITCH_TOPIC "0" // [SwitchTopic] MQTT switch topic #define MQTT_CLIENT_ID "DVES_%06X" // [MqttClient] Also fall back topic using Chip Id = last 6 characters of MAC address // -- MQTT - Telemetry ---------------------------- @@ -140,7 +138,7 @@ #define DOMOTICZ_UPDATE_TIMER 0 // [DomoticzUpdateTimer] Send relay status (0 = disable, 1 - 3600 seconds) (Optional) // -- MQTT - Home Assistant Discovery ------------- -#define USE_HOME_ASSISTANT // Enable Home Assistant Discovery Support (+1k4 code) +#define USE_HOME_ASSISTANT // Enable Home Assistant Discovery Support (+2k code) #define HOME_ASSISTANT_DISCOVERY_PREFIX "homeassistant" // Home Assistant discovery prefix #define HOME_ASSISTANT_DISCOVERY_ENABLE 0 // [SetOption19] Home Assistant Discovery (0 = Disable, 1 = Enable) diff --git a/sonoff/xdrv_00_mqtt.ino b/sonoff/xdrv_00_mqtt.ino index c1f2867da..6a87f1f25 100644 --- a/sonoff/xdrv_00_mqtt.ino +++ b/sonoff/xdrv_00_mqtt.ino @@ -637,7 +637,7 @@ bool MqttCommand() if ((data_len > 0) && (data_len < sizeof(Settings.button_topic))) { MakeValidMqtt(0, dataBuf); if (!strcmp(dataBuf, mqtt_client)) payload = 1; - strlcpy(Settings.button_topic, (!strcmp(dataBuf,"0")) ? "" : (1 == payload) ? MQTT_BUTTON_TOPIC : dataBuf, sizeof(Settings.button_topic)); + strlcpy(Settings.button_topic, (!strcmp(dataBuf,"0")) ? "" : (1 == payload) ? mqtt_topic : dataBuf, sizeof(Settings.button_topic)); } snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, Settings.button_topic); } @@ -645,7 +645,7 @@ bool MqttCommand() if ((data_len > 0) && (data_len < sizeof(Settings.switch_topic))) { MakeValidMqtt(0, dataBuf); if (!strcmp(dataBuf, mqtt_client)) payload = 1; - strlcpy(Settings.switch_topic, (!strcmp(dataBuf,"0")) ? "" : (1 == payload) ? MQTT_SWITCH_TOPIC : dataBuf, sizeof(Settings.switch_topic)); + strlcpy(Settings.switch_topic, (!strcmp(dataBuf,"0")) ? "" : (1 == payload) ? mqtt_topic : dataBuf, sizeof(Settings.switch_topic)); } snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, Settings.switch_topic); } From 5ee463ddfb35c01fd45f1f86d9500dc2e1257d64 Mon Sep 17 00:00:00 2001 From: Theo Arends Date: Fri, 30 Mar 2018 11:15:04 +0200 Subject: [PATCH 2/4] Change Timer parameter Device to Output Change Timer parameter Device to Output and add German translation (#2294) --- sonoff/_releasenotes.ino | 1 + sonoff/i18n.h | 2 +- sonoff/language/cs-CZ.h | 2 +- sonoff/language/de-DE.h | 18 +++++++++--------- sonoff/language/en-GB.h | 2 +- sonoff/language/es-AR.h | 2 +- sonoff/language/fr-FR.h | 2 +- sonoff/language/hu-HU.h | 2 +- sonoff/language/it-IT.h | 2 +- sonoff/language/nl-NL.h | 2 +- sonoff/language/pl-PL.h | 2 +- sonoff/language/pt-PT.h | 2 +- sonoff/language/ru-RU.h | 2 +- sonoff/language/zh-CN.h | 2 +- sonoff/language/zh-TW.h | 2 +- sonoff/xdrv_09_timers.ino | 6 +++--- 16 files changed, 26 insertions(+), 25 deletions(-) diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 07d30af84..e65516123 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -6,6 +6,7 @@ * Add Home Assistant MQTT Discovery for Buttons and change SetOption19 response (#2277) * Change webpage parameter communication * Change default Reset configuration time from 4 seconds to 40 seconds on Button hold (#2268) + * Change Timer parameter Device to more obvious Output * * 5.12.0h * Add optional Arduino OTA support to be enabled in user_config.h (#1998) diff --git a/sonoff/i18n.h b/sonoff/i18n.h index 2b9ac09ed..dcc7024a0 100644 --- a/sonoff/i18n.h +++ b/sonoff/i18n.h @@ -355,7 +355,7 @@ #define D_JSON_TIMER_TIME "Time" #define D_JSON_TIMER_DAYS "Days" #define D_JSON_TIMER_REPEAT "Repeat" - #define D_JSON_TIMER_DEVICE "Device" + #define D_JSON_TIMER_OUTPUT "Output" #define D_JSON_TIMER_POWER "Power" #define D_CMND_TIMERS "Timers" diff --git a/sonoff/language/cs-CZ.h b/sonoff/language/cs-CZ.h index 617524e20..c83da57de 100644 --- a/sonoff/language/cs-CZ.h +++ b/sonoff/language/cs-CZ.h @@ -365,7 +365,7 @@ #define D_TIMER_TIME "Time" #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" -#define D_TIMER_DEVICE "Device" +#define D_TIMER_OUTPUT "Device" #define D_TIMER_POWER "Power" // xdrv_03_energy.ino diff --git a/sonoff/language/de-DE.h b/sonoff/language/de-DE.h index f6f5c78a0..7e50360d0 100644 --- a/sonoff/language/de-DE.h +++ b/sonoff/language/de-DE.h @@ -356,17 +356,17 @@ #define D_DOMOTICZ_VOLTAGE "Voltage/PM2.5" #define D_DOMOTICZ_CURRENT "Current/PM10" #define D_DOMOTICZ_AIRQUALITY "AirQuality" -#define D_DOMOTICZ_UPDATE_TIMER "Update timer" + #define D_DOMOTICZ_UPDATE_TIMER "Update Zeitplan" // xdrv_09_timers.ino -#define D_CONFIGURE_TIMER "Configure Timer" -#define D_TIMER_PARAMETERS "Timer parameters" -#define D_TIMER_ARM "Arm" -#define D_TIMER_TIME "Time" -#define D_TIMER_DAYS "Days" -#define D_TIMER_REPEAT "Repeat" -#define D_TIMER_DEVICE "Device" -#define D_TIMER_POWER "Power" +#define D_CONFIGURE_TIMER "Zeitplan konfigurieren" +#define D_TIMER_PARAMETERS "Zeitplan Einstellungen" +#define D_TIMER_ARM "Aktiv" +#define D_TIMER_TIME "Uhrzeit" +#define D_TIMER_DAYS "Wochentage" +#define D_TIMER_REPEAT "Wiederholen" +#define D_TIMER_OUTPUT "Ausgang" +#define D_TIMER_POWER "Aktion" // xdrv_03_energy.ino #define D_ENERGY_TODAY "Energie heute" diff --git a/sonoff/language/en-GB.h b/sonoff/language/en-GB.h index c7db040db..c0ead99f8 100644 --- a/sonoff/language/en-GB.h +++ b/sonoff/language/en-GB.h @@ -365,7 +365,7 @@ #define D_TIMER_TIME "Time" #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" -#define D_TIMER_DEVICE "Device" +#define D_TIMER_OUTPUT "Output" #define D_TIMER_POWER "Power" // xdrv_03_energy.ino diff --git a/sonoff/language/es-AR.h b/sonoff/language/es-AR.h index bf35cc807..891a313ab 100644 --- a/sonoff/language/es-AR.h +++ b/sonoff/language/es-AR.h @@ -365,7 +365,7 @@ #define D_TIMER_TIME "Hora" #define D_TIMER_DAYS "Días" #define D_TIMER_REPEAT "Repetir" -#define D_TIMER_DEVICE "Salida" +#define D_TIMER_OUTPUT "Salida" #define D_TIMER_POWER "Estado" // xdrv_03_energy.ino diff --git a/sonoff/language/fr-FR.h b/sonoff/language/fr-FR.h index 64953f3b3..3fa12b4cd 100644 --- a/sonoff/language/fr-FR.h +++ b/sonoff/language/fr-FR.h @@ -365,7 +365,7 @@ #define D_TIMER_TIME "Time" #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" -#define D_TIMER_DEVICE "Device" +#define D_TIMER_OUTPUT "Device" #define D_TIMER_POWER "Power" // xsns_03_energy.ino diff --git a/sonoff/language/hu-HU.h b/sonoff/language/hu-HU.h index dd6ec3292..9edb25609 100644 --- a/sonoff/language/hu-HU.h +++ b/sonoff/language/hu-HU.h @@ -365,7 +365,7 @@ #define D_TIMER_TIME "Time" #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" -#define D_TIMER_DEVICE "Device" +#define D_TIMER_OUTPUT "Device" #define D_TIMER_POWER "Power" // xdrv_03_energy.ino diff --git a/sonoff/language/it-IT.h b/sonoff/language/it-IT.h index c9134c7dd..084327cc7 100644 --- a/sonoff/language/it-IT.h +++ b/sonoff/language/it-IT.h @@ -365,7 +365,7 @@ #define D_TIMER_TIME "Time" #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" -#define D_TIMER_DEVICE "Device" +#define D_TIMER_OUTPUT "Device" #define D_TIMER_POWER "Power" // xdrv_03_energy.ino diff --git a/sonoff/language/nl-NL.h b/sonoff/language/nl-NL.h index 3b91d3d84..2d1fbaf31 100644 --- a/sonoff/language/nl-NL.h +++ b/sonoff/language/nl-NL.h @@ -365,7 +365,7 @@ #define D_TIMER_TIME "Tijd" #define D_TIMER_DAYS "Dagen" #define D_TIMER_REPEAT "Herhaal" -#define D_TIMER_DEVICE "Uitgang" +#define D_TIMER_OUTPUT "Uitgang" #define D_TIMER_POWER "Actie" // xdrv_03_energy.ino diff --git a/sonoff/language/pl-PL.h b/sonoff/language/pl-PL.h index f1023e5e4..6c011fed5 100644 --- a/sonoff/language/pl-PL.h +++ b/sonoff/language/pl-PL.h @@ -365,7 +365,7 @@ #define D_TIMER_TIME "Time" #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" -#define D_TIMER_DEVICE "Device" +#define D_TIMER_OUTPUT "Device" #define D_TIMER_POWER "Power" // xdrv_03_energy.ino diff --git a/sonoff/language/pt-PT.h b/sonoff/language/pt-PT.h index 73a8b53ea..00acd9872 100644 --- a/sonoff/language/pt-PT.h +++ b/sonoff/language/pt-PT.h @@ -365,7 +365,7 @@ #define D_TIMER_TIME "Time" #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" -#define D_TIMER_DEVICE "Device" +#define D_TIMER_OUTPUT "Device" #define D_TIMER_POWER "Power" // xdrv_03_energy.ino diff --git a/sonoff/language/ru-RU.h b/sonoff/language/ru-RU.h index 5c5b964e6..496daf8b2 100644 --- a/sonoff/language/ru-RU.h +++ b/sonoff/language/ru-RU.h @@ -365,7 +365,7 @@ #define D_TIMER_TIME "Time" #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" -#define D_TIMER_DEVICE "Device" +#define D_TIMER_OUTPUT "Device" #define D_TIMER_POWER "Power" // xdrv_03_energy.ino diff --git a/sonoff/language/zh-CN.h b/sonoff/language/zh-CN.h index 86c352dbf..82f0ae4ce 100644 --- a/sonoff/language/zh-CN.h +++ b/sonoff/language/zh-CN.h @@ -365,7 +365,7 @@ #define D_TIMER_TIME "Time" #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" -#define D_TIMER_DEVICE "Device" +#define D_TIMER_OUTPUT "Device" #define D_TIMER_POWER "Power" // xdrv_03_energy.ino diff --git a/sonoff/language/zh-TW.h b/sonoff/language/zh-TW.h index f015232e3..b37639f6f 100644 --- a/sonoff/language/zh-TW.h +++ b/sonoff/language/zh-TW.h @@ -365,7 +365,7 @@ #define D_TIMER_TIME "Time" #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" -#define D_TIMER_DEVICE "Device" +#define D_TIMER_OUTPUT "Device" #define D_TIMER_POWER "Power" // xdrv_03_energy.ino diff --git a/sonoff/xdrv_09_timers.ino b/sonoff/xdrv_09_timers.ino index d84b14358..efa57b708 100644 --- a/sonoff/xdrv_09_timers.ino +++ b/sonoff/xdrv_09_timers.ino @@ -70,7 +70,7 @@ void PrepShowTimer(uint8_t index) uint8_t mask = 1 << i; snprintf(days, sizeof(days), "%s%d", days, ((Settings.timer[index].days & mask) > 0)); } - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"" D_CMND_TIMER "%d\":{\"" D_JSON_TIMER_ARM "\":%d,\"" D_JSON_TIMER_TIME "\":\"%02d:%02d\",\"" D_JSON_TIMER_DAYS "\":\"%s\",\"" D_JSON_TIMER_REPEAT "\":%d,\"" D_JSON_TIMER_DEVICE "\":%d,\"" D_JSON_TIMER_POWER "\":%d}"), + snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"" D_CMND_TIMER "%d\":{\"" D_JSON_TIMER_ARM "\":%d,\"" D_JSON_TIMER_TIME "\":\"%02d:%02d\",\"" D_JSON_TIMER_DAYS "\":\"%s\",\"" D_JSON_TIMER_REPEAT "\":%d,\"" D_JSON_TIMER_OUTPUT "\":%d,\"" D_JSON_TIMER_POWER "\":%d}"), mqtt_data, index +1, Settings.timer[index].arm, Settings.timer[index].time / 60, Settings.timer[index].time % 60, days, Settings.timer[index].repeat, Settings.timer[index].device +1, Settings.timer[index].power); } @@ -146,7 +146,7 @@ boolean TimerCommand() if (root[UpperCase_P(parm_uc, PSTR(D_JSON_TIMER_REPEAT))].success()) { Settings.timer[index].repeat = (root[parm_uc] != 0); } - if (root[UpperCase_P(parm_uc, PSTR(D_JSON_TIMER_DEVICE))].success()) { + if (root[UpperCase_P(parm_uc, PSTR(D_JSON_TIMER_OUTPUT))].success()) { uint8_t device = ((uint8_t)root[parm_uc] -1) & 0x0F; Settings.timer[index].device = (device < devices_present) ? device : devices_present -1; } @@ -257,7 +257,7 @@ const char HTTP_FORM_TIMER[] PROGMEM = const char HTTP_FORM_TIMER1[] PROGMEM = "


" "
" - "" D_TIMER_DEVICE "  " + "" D_TIMER_OUTPUT "  " "" D_TIMER_POWER " \"+a.substring(i*3,(i*3)+3)+\"\"}" + "eb('ds').innerHTML=s;" // Create weekdays + "eb('dP').click();" // Get the element with id='dP' and click on it "}"; const char HTTP_TIMER_STYLE[] PROGMEM = ".tl{float:left;border-radius:0;border:1px solid #fff;padding:1px;width:6.25%;}" @@ -255,7 +256,7 @@ const char HTTP_FORM_TIMER[] PROGMEM = "
 " D_TIMER_PARAMETERS " 
" "



" "
" "" D_TIMER_OUTPUT "  " "" D_TIMER_POWER "  " - "" D_TIMER_TIME "  :  " + "" D_TIMER_TIME "  " D_HOUR_MINUTE_SEPARATOR "  " "" D_TIMER_ARM " " "" D_TIMER_REPEAT "" "

" - "
"; + "
"; const char HTTP_FORM_TIMER2[] PROGMEM = "type='submit' onclick='st();this.form.submit();'"; @@ -295,25 +296,11 @@ void HandleTimerConfiguration() if (i > 0) page += F(","); page += String(Settings.timer[i].data); } - page += F("' hidden>
"); - for (byte i = 0; i < MAX_TIMERS; i++) { - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR(""), - i, (0 == i) ? " id='dP'" : "", i +1); - page += mqtt_data; - } page += FPSTR(HTTP_FORM_TIMER1); page.replace(F("}1"), String(devices_present)); - char day[4] = { 0 }; - for (byte i = 0; i < 7; i++) { - strncpy_P(day, PSTR(D_DAY3LIST) + (i *3), 3); - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s"), i, i, day); - page += mqtt_data; - } - page += F("
"); - page += FPSTR(HTTP_FORM_END); page.replace(F("type='submit'"), FPSTR(HTTP_FORM_TIMER2)); - page += F(""); // Get the element with id='defaultOpen' and click on it + page += F(""); // Init elements and select first tab/button page += FPSTR(HTTP_BTN_CONF); ShowPage(page); } @@ -324,11 +311,14 @@ void TimerSaveSettings() WebGetArg("t0", tmp, sizeof(tmp)); char *p = tmp; + snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_CMND_TIMERS " ")); for (byte i = 0; i < MAX_TIMERS; i++) { uint32_t data = strtol(p, &p, 10); p++; // Skip comma if ((data & 0x7FF) < 1440) Settings.timer[i].data = data; + snprintf_P(log_data, sizeof(log_data), PSTR("%s%s0x%08X"), log_data, (i > 0)?",":"", Settings.timer[i].data); } + AddLog(LOG_LEVEL_DEBUG); } #endif // USE_TIMERS_WEB #endif // USE_WEBSERVER