From 2049730877e8c75b6ae2986d47d5fe62bdaeb1ac Mon Sep 17 00:00:00 2001 From: Theo Arends Date: Thu, 12 Apr 2018 14:01:43 +0200 Subject: [PATCH] Fix DS18x20 temperature updates (# 5.12.0k * Change Timer parameter name from Power to Action * Fix update temperature on DS18x20 drivers (#2328) --- sonoff/_releasenotes.ino | 2 ++ sonoff/i18n.h | 2 +- sonoff/language/cs-CZ.h | 3 +- sonoff/language/de-DE.h | 3 +- sonoff/language/en-GB.h | 3 +- sonoff/language/es-AR.h | 3 +- sonoff/language/fr-FR.h | 3 +- sonoff/language/hu-HU.h | 3 +- sonoff/language/it-IT.h | 3 +- sonoff/language/nl-NL.h | 3 +- sonoff/language/pl-PL.h | 3 +- sonoff/language/pt-PT.h | 3 +- sonoff/language/ru-RU.h | 3 +- sonoff/language/zh-CN.h | 3 +- sonoff/language/zh-TW.h | 3 +- sonoff/sonoff.h | 2 +- sonoff/support.ino | 6 ++-- sonoff/user_config.h | 6 ++-- sonoff/xdrv_09_timers.ino | 51 +++++++++++++++++-------------- sonoff/xdrv_interface.ino | 5 +++ sonoff/xsns_05_ds18b20.ino | 2 +- sonoff/xsns_05_ds18x20.ino | 7 +---- sonoff/xsns_05_ds18x20_legacy.ino | 7 ++--- sonoff/xsns_interface.ino | 13 ++++++++ 24 files changed, 86 insertions(+), 56 deletions(-) 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 0b2fed9f1..d8916d700 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_03_energy.ino #define D_ENERGY_TODAY "Spotřeba Dnes" diff --git a/sonoff/language/de-DE.h b/sonoff/language/de-DE.h index 7a2a169b2..0d804c0c1 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_03_energy.ino #define D_ENERGY_TODAY "Energie heute" diff --git a/sonoff/language/en-GB.h b/sonoff/language/en-GB.h index 26a2e9fe0..d5555b094 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_03_energy.ino #define D_ENERGY_TODAY "Energy Today" diff --git a/sonoff/language/es-AR.h b/sonoff/language/es-AR.h index 14793c0d6..fb3a1164b 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_03_energy.ino #define D_ENERGY_TODAY "Energía Hoy" diff --git a/sonoff/language/fr-FR.h b/sonoff/language/fr-FR.h index d0aff6c77..2d08fe03c 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" // xsns_03_energy.ino #define D_ENERGY_TODAY "Energie aujourd'hui" diff --git a/sonoff/language/hu-HU.h b/sonoff/language/hu-HU.h index 455e0ba1f..2e2080a84 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_03_energy.ino #define D_ENERGY_TODAY "Mai Energia" diff --git a/sonoff/language/it-IT.h b/sonoff/language/it-IT.h index cab2e7892..ad3185c49 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_03_energy.ino #define D_ENERGY_TODAY "Energia Oggi" diff --git a/sonoff/language/nl-NL.h b/sonoff/language/nl-NL.h index 802255b3a..bf030e88c 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_03_energy.ino #define D_ENERGY_TODAY "Verbruik vandaag" diff --git a/sonoff/language/pl-PL.h b/sonoff/language/pl-PL.h index 3ce638de6..e143424c7 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_03_energy.ino #define D_ENERGY_TODAY "Energia Dzisiaj" diff --git a/sonoff/language/pt-PT.h b/sonoff/language/pt-PT.h index cae2832db..765bb1e19 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_03_energy.ino #define D_ENERGY_TODAY "Consumo energético de hoje" diff --git a/sonoff/language/ru-RU.h b/sonoff/language/ru-RU.h index 0fa85d5a9..152d081c3 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_03_energy.ino #define D_ENERGY_TODAY "Энергия Сегодня" diff --git a/sonoff/language/zh-CN.h b/sonoff/language/zh-CN.h index 0f1a97347..dd965887c 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_03_energy.ino #define D_ENERGY_TODAY "今日用电量" diff --git a/sonoff/language/zh-TW.h b/sonoff/language/zh-TW.h index f0ae1d59e..a954d4669 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_03_energy.ino #define D_ENERGY_TODAY "今日用電量" diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 279c1652d..0cdc38cc8 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -164,7 +164,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 6fe6fe616..ffb41aff5 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 0975c8c64..080c33ec9 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>



" "
" "" D_TIMER_OUTPUT "  " - "" D_TIMER_POWER " " "" "" "" +#ifdef USE_RULES + "" +#else "" +#endif "" "

" "
" diff --git a/sonoff/xdrv_interface.ino b/sonoff/xdrv_interface.ino index 09f056ece..99a1600e8 100644 --- a/sonoff/xdrv_interface.ino +++ b/sonoff/xdrv_interface.ino @@ -182,12 +182,17 @@ boolean XdrvMqttData(char *topicBuf, uint16_t stopicBuf, char *dataBuf, uint16_t * FUNC_LOOP * FUNC_MQTT_SUBSCRIBE * FUNC_MQTT_INIT + * FUNC_MQTT_DISCONNECTED + * FUNC_MQTT_CONNECTED * return FUNC_MQTT_DATA * return FUNC_COMMAND * FUNC_SET_POWER * FUNC_SHOW_SENSOR * FUNC_EVERY_SECOND * FUNC_EVERY_50_MSECOND + * FUNC_NTP_INIT + * FUNC_NTP_SET + * FUNC_CLOCK_TIMER \*********************************************************************************************/ boolean XdrvCall(byte Function) diff --git a/sonoff/xsns_05_ds18b20.ino b/sonoff/xsns_05_ds18b20.ino index 6faeeed18..753fafeca 100644 --- a/sonoff/xsns_05_ds18b20.ino +++ b/sonoff/xsns_05_ds18b20.ino @@ -205,6 +205,7 @@ void Ds18b20Show(boolean json) #endif // USE_WEBSERVER } } + Ds18x20Convert(); // Start conversion, takes up to one second } /*********************************************************************************************\ @@ -231,7 +232,6 @@ boolean Xsns05(byte function) #ifdef USE_WEBSERVER case FUNC_WEB_APPEND: Ds18b20Show(0); - Ds18x20Convert(); // Start conversion, takes up to one second break; #endif // USE_WEBSERVER } diff --git a/sonoff/xsns_05_ds18x20.ino b/sonoff/xsns_05_ds18x20.ino index 4f17e94cd..b99c71298 100644 --- a/sonoff/xsns_05_ds18x20.ino +++ b/sonoff/xsns_05_ds18x20.ino @@ -392,6 +392,7 @@ void Ds18x20Show(boolean json) } } } + Ds18x20Convert(); // Start conversion, takes up to one second } /*********************************************************************************************\ @@ -409,11 +410,6 @@ boolean Xsns05(byte function) case FUNC_INIT: Ds18x20Init(); break; -// case FUNC_EVERY_SECOND: -// if ((Settings.tele_period - tele_period) &3 == 3) { -// Ds18x20Convert(); // Start conversion every four seconds, takes up to one second -// } -// break; case FUNC_PREP_BEFORE_TELEPERIOD: Ds18x20Convert(); // Start conversion, takes up to one second break; @@ -423,7 +419,6 @@ boolean Xsns05(byte function) #ifdef USE_WEBSERVER case FUNC_WEB_APPEND: Ds18x20Show(0); - Ds18x20Convert(); // Start conversion, takes up to one second break; #endif // USE_WEBSERVER } diff --git a/sonoff/xsns_05_ds18x20_legacy.ino b/sonoff/xsns_05_ds18x20_legacy.ino index bd78ff424..885ce7540 100644 --- a/sonoff/xsns_05_ds18x20_legacy.ino +++ b/sonoff/xsns_05_ds18x20_legacy.ino @@ -204,12 +204,9 @@ void Ds18x20Show(boolean json) if (dsxflg) { snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data); } -#ifdef USE_WEBSERVER - } else { - Ds18x20Search(); // Check for changes in sensors number - Ds18x20Convert(); // Start Conversion, takes up to one second -#endif // USE_WEBSERVER } + Ds18x20Search(); // Check for changes in sensors number + Ds18x20Convert(); // Start Conversion, takes up to one second } /*********************************************************************************************\ diff --git a/sonoff/xsns_interface.ino b/sonoff/xsns_interface.ino index 20488dc92..19cd86bb3 100644 --- a/sonoff/xsns_interface.ino +++ b/sonoff/xsns_interface.ino @@ -186,6 +186,7 @@ boolean (* const xsns_func_ptr[])(byte) PROGMEM = { // Sensor Function Pointers }; const uint8_t xsns_present = sizeof(xsns_func_ptr) / sizeof(xsns_func_ptr[0]); // Number of External Sensors found +uint8_t xsns_index = 0; /*********************************************************************************************\ * Function call to all xsns @@ -200,6 +201,18 @@ const uint8_t xsns_present = sizeof(xsns_func_ptr) / sizeof(xsns_func_ptr[0]); * FUNC_EVERY_50_MSECOND \*********************************************************************************************/ +uint8_t XsnsPresent() +{ + return xsns_present; +} + +boolean XsnsNextCall(byte Function) +{ + xsns_index++; + if (xsns_index == xsns_present) xsns_index = 0; + return xsns_func_ptr[xsns_index](Function); +} + boolean XsnsCall(byte Function) { boolean result = false;