diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index 4404e6fa5..72db773c9 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,6 +1,8 @@ /* 5.12.0k * Prepare for simple rules by enlarging Settings area to now 2048 bytes + * Change Timer parameter name from Power to Action * Fix freeing more code space when emulation is disabled (#1592) + * Fix update temperature on DS18x20 drivers (#2328) * Fix compile error when not defined USE_TIMERS (#2400) * * 5.12.0j diff --git a/sonoff/i18n.h b/sonoff/i18n.h index 5dea3bbe9..be258ae7e 100644 --- a/sonoff/i18n.h +++ b/sonoff/i18n.h @@ -361,7 +361,7 @@ #define D_JSON_TIMER_DAYS "Days" #define D_JSON_TIMER_REPEAT "Repeat" #define D_JSON_TIMER_OUTPUT "Output" - #define D_JSON_TIMER_POWER "Power" + #define D_JSON_TIMER_ACTION "Action" #define D_JSON_TIMER_NO_DEVICE "No GPIO as output configured" #define D_CMND_TIMERS "Timers" #define D_CMND_LATITUDE "Latitude" diff --git a/sonoff/language/cs-CZ.h b/sonoff/language/cs-CZ.h index 6d8294fd3..d5011cf7b 100644 --- a/sonoff/language/cs-CZ.h +++ b/sonoff/language/cs-CZ.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "Příčina restartu" #define D_RESTORE "Obnovit" #define D_RETAINED "Zachováno" +#define D_RULE "Rule" #define D_SAVE "Ulož" #define D_SENSOR "Sensor" #define D_SSID "SSID" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Dny" #define D_TIMER_REPEAT "Opakovat" #define D_TIMER_OUTPUT "Výstup" -#define D_TIMER_POWER "Napájení" +#define D_TIMER_ACTION "Napájení" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configure KNX" diff --git a/sonoff/language/de-DE.h b/sonoff/language/de-DE.h index f3ae6079d..b186c7f45 100644 --- a/sonoff/language/de-DE.h +++ b/sonoff/language/de-DE.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "Grund für Neustart" #define D_RESTORE "Wiederherstellung" #define D_RETAINED "beibehalten" +#define D_RULE "Regel" #define D_SAVE "Speichern" #define D_SENSOR "Sensor" #define D_SSID "SSID" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Wochentage" #define D_TIMER_REPEAT "Wiederholen" #define D_TIMER_OUTPUT "Ausgang" -#define D_TIMER_POWER "Aktion" +#define D_TIMER_ACTION "Aktion" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configure KNX" diff --git a/sonoff/language/en-GB.h b/sonoff/language/en-GB.h index 69a35e0d5..947749ccd 100644 --- a/sonoff/language/en-GB.h +++ b/sonoff/language/en-GB.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "Restart Reason" #define D_RESTORE "restore" #define D_RETAINED "retained" +#define D_RULE "Rule" #define D_SAVE "Save" #define D_SENSOR "Sensor" #define D_SSID "SSId" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" #define D_TIMER_OUTPUT "Output" -#define D_TIMER_POWER "Power" +#define D_TIMER_ACTION "Action" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configure KNX" diff --git a/sonoff/language/es-AR.h b/sonoff/language/es-AR.h index 3acd15ecc..e7b35e885 100644 --- a/sonoff/language/es-AR.h +++ b/sonoff/language/es-AR.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "Causa Reinicio" #define D_RESTORE "Restauración" #define D_RETAINED "Grabado" +#define D_RULE "Rule" #define D_SAVE "Grabar" #define D_SENSOR "Sensor" #define D_SSID "SSId" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Días" #define D_TIMER_REPEAT "Repetir" #define D_TIMER_OUTPUT "Salida" -#define D_TIMER_POWER "Estado" +#define D_TIMER_ACTION "Estado" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configuración de KNX" diff --git a/sonoff/language/fr-FR.h b/sonoff/language/fr-FR.h index 9c18af2cd..173dd45ee 100644 --- a/sonoff/language/fr-FR.h +++ b/sonoff/language/fr-FR.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "Raison redémarrage" #define D_RESTORE "restorer" #define D_RETAINED "retenu" +#define D_RULE "Rule" #define D_SAVE "Enregister" #define D_SENSOR "Capteur" #define D_SSID "SSID" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" #define D_TIMER_OUTPUT "Output" -#define D_TIMER_POWER "Power" +#define D_TIMER_ACTION "Action" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configure KNX" diff --git a/sonoff/language/hu-HU.h b/sonoff/language/hu-HU.h index c03b635c4..506ba69cb 100644 --- a/sonoff/language/hu-HU.h +++ b/sonoff/language/hu-HU.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "Újraindítás oka:" #define D_RESTORE "Visszaállítás" #define D_RETAINED "mentve" +#define D_RULE "Rule" #define D_SAVE "Mentés" #define D_SENSOR "Szenzor" #define D_SSID "SSId" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" #define D_TIMER_OUTPUT "Output" -#define D_TIMER_POWER "Power" +#define D_TIMER_ACTION "Action" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configure KNX" diff --git a/sonoff/language/it-IT.h b/sonoff/language/it-IT.h index 4c08ee1fa..95d5f20e7 100644 --- a/sonoff/language/it-IT.h +++ b/sonoff/language/it-IT.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "Causa Riavvio" #define D_RESTORE "ripristino" #define D_RETAINED "salvato" +#define D_RULE "Rule" #define D_SAVE "Salva" #define D_SENSOR "Sensore" #define D_SSID "SSId" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" #define D_TIMER_OUTPUT "Output" -#define D_TIMER_POWER "Power" +#define D_TIMER_ACTION "Action" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configure KNX" diff --git a/sonoff/language/nl-NL.h b/sonoff/language/nl-NL.h index 50a984792..ff68fd773 100644 --- a/sonoff/language/nl-NL.h +++ b/sonoff/language/nl-NL.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "Reden herstart" #define D_RESTORE "herstellen" #define D_RETAINED "retained" +#define D_RULE "Regel" #define D_SAVE "Opslaan" #define D_SENSOR "Sensor" #define D_SSID "SSId" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Dagen" #define D_TIMER_REPEAT "Herhaal" #define D_TIMER_OUTPUT "Uitgang" -#define D_TIMER_POWER "Actie" +#define D_TIMER_ACTION "Actie" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configure KNX" diff --git a/sonoff/language/pl-PL.h b/sonoff/language/pl-PL.h index d8d30c7f2..b61767687 100644 --- a/sonoff/language/pl-PL.h +++ b/sonoff/language/pl-PL.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "Przyczyna restartu" #define D_RESTORE "Przywracanie" #define D_RETAINED "Zachowane" +#define D_RULE "Rule" #define D_SAVE "Zapisz" #define D_SENSOR "Czujnik" #define D_SSID "SSID" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" #define D_TIMER_OUTPUT "Output" -#define D_TIMER_POWER "Power" +#define D_TIMER_ACTION "Action" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configure KNX" diff --git a/sonoff/language/pt-PT.h b/sonoff/language/pt-PT.h index 725f6a82c..408ea5d8a 100644 --- a/sonoff/language/pt-PT.h +++ b/sonoff/language/pt-PT.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "Razão do reinicio" #define D_RESTORE "Restauro" #define D_RETAINED "Manter" +#define D_RULE "Rule" #define D_SAVE "Salvar" #define D_SENSOR "Sensor" #define D_SSID "SSId" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" #define D_TIMER_OUTPUT "Output" -#define D_TIMER_POWER "Power" +#define D_TIMER_ACTION "Action" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configure KNX" diff --git a/sonoff/language/ru-RU.h b/sonoff/language/ru-RU.h index 34c051105..9cfce3792 100644 --- a/sonoff/language/ru-RU.h +++ b/sonoff/language/ru-RU.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "Причина перезагрузки" #define D_RESTORE "восстановление" #define D_RETAINED "нераспред." +#define D_RULE "Rule" #define D_SAVE "Сохранить" #define D_SENSOR "Датчик" #define D_SSID "SSId" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" #define D_TIMER_OUTPUT "Output" -#define D_TIMER_POWER "Power" +#define D_TIMER_ACTION "Action" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configure KNX" diff --git a/sonoff/language/zh-CN.h b/sonoff/language/zh-CN.h index 9fc5c0845..c09e50747 100644 --- a/sonoff/language/zh-CN.h +++ b/sonoff/language/zh-CN.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "重启原因" #define D_RESTORE "恢复" #define D_RETAINED "已保留" +#define D_RULE "Rule" #define D_SAVE "保存" #define D_SENSOR "传感器" #define D_SSID "名称" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" #define D_TIMER_OUTPUT "Output" -#define D_TIMER_POWER "Power" +#define D_TIMER_ACTION "Action" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configure KNX" diff --git a/sonoff/language/zh-TW.h b/sonoff/language/zh-TW.h index edb04d96c..70398fb0d 100644 --- a/sonoff/language/zh-TW.h +++ b/sonoff/language/zh-TW.h @@ -128,6 +128,7 @@ #define D_RESTART_REASON "重啟原因" #define D_RESTORE "恢覆" #define D_RETAINED "已保留" +#define D_RULE "Rule" #define D_SAVE "存檔" #define D_SENSOR "感測器" #define D_SSID "名稱" @@ -370,7 +371,7 @@ #define D_TIMER_DAYS "Days" #define D_TIMER_REPEAT "Repeat" #define D_TIMER_OUTPUT "Output" -#define D_TIMER_POWER "Power" +#define D_TIMER_ACTION "Action" // xdrv_10_KNX.ino #define D_CONFIGURE_KNX "Configure KNX" diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 6f61b20ff..ed1a1c34b 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -166,7 +166,7 @@ enum LichtSubtypes {LST_NONE, LST_SINGLE, LST_COLDWARM, LST_RGB, LST_RGBW, LST_R enum LichtSchemes {LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_MAX}; enum XsnsFunctions {FUNC_INIT, FUNC_LOOP, FUNC_EVERY_50_MSECOND, FUNC_EVERY_SECOND, FUNC_PREP_BEFORE_TELEPERIOD, FUNC_JSON_APPEND, FUNC_WEB_APPEND, FUNC_SAVE_BEFORE_RESTART, - FUNC_COMMAND, FUNC_NTP_INIT, FUNC_NTP_SET, + FUNC_COMMAND, FUNC_NTP_INIT, FUNC_NTP_SET, FUNC_CLOCK_TIMER, FUNC_MQTT_SUBSCRIBE, FUNC_MQTT_INIT, FUNC_MQTT_DATA, FUNC_MQTT_DISCONNECTED, FUNC_MQTT_CONNECTED, FUNC_SET_POWER, FUNC_SHOW_SENSOR}; diff --git a/sonoff/support.ino b/sonoff/support.ino index 591a4c571..2a2ea7625 100644 --- a/sonoff/support.ino +++ b/sonoff/support.ino @@ -192,7 +192,7 @@ size_t strchrspn(const char *str1, int character) return ret; } -double AtoD(char *str) +double CharToDouble(char *str) { // simple ascii to double, because atof or strtod are too large char strbuf[24]; @@ -1377,8 +1377,8 @@ void RtcSecond() GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str()); AddLog(LOG_LEVEL_DEBUG); - if (local_time < 1451602800) { - XdrvCall(FUNC_NTP_SET); + if (local_time < 1451602800) { // 2016-01-01 + XdrvCall(FUNC_NTP_INIT); } else { XdrvCall(FUNC_NTP_SET); } diff --git a/sonoff/user_config.h b/sonoff/user_config.h index cc598fd8d..c580a629a 100644 --- a/sonoff/user_config.h +++ b/sonoff/user_config.h @@ -68,9 +68,9 @@ // -- Syslog -------------------------------------- #define SYS_LOG_HOST "" // [LogHost] (Linux) syslog host #define SYS_LOG_PORT 514 // [LogPort] default syslog UDP port -#define SYS_LOG_LEVEL LOG_LEVEL_NONE // [SysLog] LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE -#define SERIAL_LOG_LEVEL LOG_LEVEL_INFO // [SerialLog] LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE -#define WEB_LOG_LEVEL LOG_LEVEL_INFO // [WebLog] LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE +#define SYS_LOG_LEVEL LOG_LEVEL_NONE // [SysLog] (LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE) +#define SERIAL_LOG_LEVEL LOG_LEVEL_INFO // [SerialLog] (LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE) +#define WEB_LOG_LEVEL LOG_LEVEL_INFO // [WebLog] (LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE) // -- Ota ----------------------------------------- #define OTA_URL "http://sonoff.maddox.co.uk/tasmota/sonoff.ino.bin" // [OtaUrl] diff --git a/sonoff/xdrv_09_timers.ino b/sonoff/xdrv_09_timers.ino index e5f5d2fac..35d45ec18 100644 --- a/sonoff/xdrv_09_timers.ino +++ b/sonoff/xdrv_09_timers.ino @@ -22,15 +22,15 @@ * Timers * * Arm a timer using one or all of the following JSON values: - * {"Arm":1,"Mode":0,"Time":"09:23","Days":"--TW--S","Repeat":1,"Device":1,"Power":1} + * {"Arm":1,"Mode":0,"Time":"09:23","Days":"--TW--S","Repeat":1,"Output":1,"Action":1} * - * Arm 0 = Off, 1 = On - * Mode 0 = Schedule, 1 = Sunrise, 2 = Sunset - * Time hours:minutes - * Days 7 day character mask starting with Sunday (SMTWTFS). 0 or - = Off, any other value = On - * Repeat 0 = Execute once, 1 = Execute again - * Device 1..16 - * Power 0 = Off, 1 = On, 2 = Toggle, 3 = Blink + * Arm 0 = Off, 1 = On + * Mode 0 = Schedule, 1 = Sunrise, 2 = Sunset + * Time hours:minutes + * Days 7 day character mask starting with Sunday (SMTWTFS). 0 or - = Off, any other value = On + * Repeat 0 = Execute once, 1 = Execute again + * Output 1..16 + * Action 0 = Off, 1 = On, 2 = Toggle, 3 = Blink or Rule if USE_RULES enabled * \*********************************************************************************************/ @@ -45,7 +45,6 @@ const char kTimerCommands[] PROGMEM = D_CMND_TIMER "|" D_CMND_TIMERS #endif ; -uint16_t timer_fired = 0; uint16_t timer_last_minute = 60; #ifdef USE_SUNRISE @@ -206,7 +205,7 @@ uint16_t GetSunMinutes(byte dawn) void TimerEverySecond() { if (RtcTime.valid) { - if (RtcTime.minute != timer_last_minute) { // Execute every minute + if (RtcTime.minute != timer_last_minute) { // Execute every minute only once timer_last_minute = RtcTime.minute; uint16_t time = (RtcTime.hour *60) + RtcTime.minute; uint8_t days = 1 << (RtcTime.day_of_week -1); @@ -221,13 +220,16 @@ void TimerEverySecond() #endif if (Settings.timer[i].arm) { if (time == set_time) { - if (!bitRead(timer_fired, i) && (Settings.timer[i].days & days)) { - bitSet(timer_fired, i); + if (Settings.timer[i].days & days) { Settings.timer[i].arm = Settings.timer[i].repeat; - ExecuteCommandPower(Settings.timer[i].device +1, Settings.timer[i].power); +#ifdef USE_RULES + if (3 == Settings.timer[i].power) { // Blink becomes Rule disregarding device and allowing use of Backlog commands + XdrvMailbox.index = i; + XdrvCall(FUNC_CLOCK_TIMER); + } else +#endif + ExecuteCommandPower(Settings.timer[i].device +1, Settings.timer[i].power); } - } else { - bitClear(timer_fired, i); } } } @@ -245,10 +247,10 @@ void PrepShowTimer(uint8_t index) snprintf(days, sizeof(days), "%s%d", days, ((Settings.timer[index].days & mask) > 0)); } #ifdef USE_SUNRISE - snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"" D_CMND_TIMER "%d\":{\"" D_JSON_TIMER_ARM "\":%d,\"" D_JSON_TIMER_MODE "\":%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}"), + snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s\"" D_CMND_TIMER "%d\":{\"" D_JSON_TIMER_ARM "\":%d,\"" D_JSON_TIMER_MODE "\":%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_ACTION "\":%d}"), mqtt_data, index +1, Settings.timer[index].arm, Settings.timer[index].mode, Settings.timer[index].time / 60, Settings.timer[index].time % 60, days, Settings.timer[index].repeat, Settings.timer[index].device +1, Settings.timer[index].power); #else - 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}"), + 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_ACTION "\":%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); #endif // USE_SUNRISE } @@ -259,7 +261,7 @@ void PrepShowTimer(uint8_t index) boolean TimerCommand() { - char command [CMDSZ]; + char command[CMDSZ]; char dataBufUc[XdrvMailbox.data_len]; boolean serviced = true; uint8_t index = XdrvMailbox.index; @@ -335,10 +337,9 @@ boolean TimerCommand() uint8_t device = ((uint8_t)root[parm_uc] -1) & 0x0F; Settings.timer[index].device = (device < devices_present) ? device : devices_present -1; } - if (root[UpperCase_P(parm_uc, PSTR(D_JSON_TIMER_POWER))].success()) { + if (root[UpperCase_P(parm_uc, PSTR(D_JSON_TIMER_ACTION))].success()) { Settings.timer[index].power = (uint8_t)root[parm_uc] & 0x03; } - if (Settings.timer[index].arm) bitClear(timer_fired, index); index++; } @@ -376,7 +377,7 @@ boolean TimerCommand() #ifdef USE_SUNRISE else if (CMND_LONGITUDE == command_code) { if (XdrvMailbox.data_len) { - Settings.longitude = (int)(AtoD(XdrvMailbox.data) *1000000); + Settings.longitude = (int)(CharToDouble(XdrvMailbox.data) *1000000); } char lbuff[32]; dtostrfd(((double)Settings.longitude) /1000000, 6, lbuff); @@ -384,7 +385,7 @@ boolean TimerCommand() } else if (CMND_LATITUDE == command_code) { if (XdrvMailbox.data_len) { - Settings.latitude = (int)(AtoD(XdrvMailbox.data) *1000000); + Settings.latitude = (int)(CharToDouble(XdrvMailbox.data) *1000000); } char lbuff[32]; dtostrfd(((double)Settings.latitude) /1000000, 6, lbuff); @@ -486,11 +487,15 @@ const char HTTP_FORM_TIMER1[] PROGMEM = "' hidden>