From f759e2698831653083e3cad1d26e9378cb657da8 Mon Sep 17 00:00:00 2001 From: Marcus Date: Fri, 8 Jan 2021 21:36:05 +0100 Subject: [PATCH 01/16] remove backward compatible #define option; ITurned it into an undocumented option to suppress it --- tasmota/xdrv_49_pid.ino | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tasmota/xdrv_49_pid.ino b/tasmota/xdrv_49_pid.ino index 37b8774a3..eda2b633f 100644 --- a/tasmota/xdrv_49_pid.ino +++ b/tasmota/xdrv_49_pid.ino @@ -119,11 +119,6 @@ #define PID_REPORT_MORE_SETTINGS // If defined, the SENSOR output will provide more extensive json // output in the PID section -// #define PID_BACKWARD_COMPATIBLE // Preserve the backward compatible reporting of PID power via - // `%topic%/PID {"power":"0.000"}` This is now available in - // `%topic$/SENSOR {..., "PID":{"PidPower":0.00}}` - // Don't use unless you know that you need it - * Help with using the PID algorithm and with loop tuning can be found at * http://blog.clanlaw.org.uk/2018/01/09/PID-tuning-with-node-red-contrib-pid.html * This is directed towards using the algorithm in the node-red node node-red-contrib-pid but the algorithm here is based on @@ -362,14 +357,14 @@ void PIDShowValues(void) { static void run_pid() { double power = pid.tick(pid_current_time_secs); -#ifdef PID_BACKWARD_COMPATIBLE +#ifdef PID_DONT_USE_PID_TOPIC // This part is left inside to regularly publish the PID Power via // `%topic%/PID {"power":"0.000"}` char str_buf[FLOATSZ]; dtostrfd(power, 3, str_buf); snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"%s\":\"%s\"}"), "power", str_buf); MqttPublishPrefixTopic_P(TELE, "PID", false); -#endif // PID_BACKWARD_COMPATIBLE +#endif // PID_DONT_USE_PID_TOPIC #if defined PID_SHUTTER // send output as a position from 0-100 to defined shutter From aedfe35b017567e28d06fd724699450235d67790 Mon Sep 17 00:00:00 2001 From: Marcus Date: Fri, 8 Jan 2021 21:36:28 +0100 Subject: [PATCH 02/16] re-add code to modify timeprop values via mqtt --- tasmota/xdrv_48_timeprop.ino | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tasmota/xdrv_48_timeprop.ino b/tasmota/xdrv_48_timeprop.ino index 6e8537dbb..a457c8d94 100644 --- a/tasmota/xdrv_48_timeprop.ino +++ b/tasmota/xdrv_48_timeprop.ino @@ -82,6 +82,11 @@ # include "Timeprop.h" +#define D_CMND_TIMEPROP "timeprop_" +#define D_CMND_TIMEPROP_SETPOWER "setpower_" // add index no on end (0:8) and data is power 0:1 + +enum TimepropCommands { CMND_TIMEPROP_SETPOWER }; +const char kTimepropCommands[] PROGMEM = D_CMND_TIMEPROP_SETPOWER; static Timeprop timeprops[TIMEPROP_NUM_OUTPUTS]; static int relayNos[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_RELAYS}; @@ -143,7 +148,50 @@ void Timeprop_Xdrv_Power() { /* } XdrvMailbox; */ // To get here post with topic cmnd/timeprop_setpower_n where n is index into timeprops 0:7 +bool Timeprop_Command() +{ + char command [CMDSZ]; + bool serviced = true; + uint8_t ua_prefix_len = strlen(D_CMND_TIMEPROP); // to detect prefix of command + /* + snprintf_P(log_data, sizeof(log_data), "Command called: " + "index: %d data_len: %d payload: %d topic: %s data: %s\n", + XdrvMailbox.index, + XdrvMailbox.data_len, + XdrvMailbox.payload, + (XdrvMailbox.payload >= 0 ? XdrvMailbox.topic : ""), + (XdrvMailbox.data_len >= 0 ? XdrvMailbox.data : "")); + AddLog(LOG_LEVEL_INFO); + */ + if (0 == strncasecmp_P(XdrvMailbox.topic, PSTR(D_CMND_TIMEPROP), ua_prefix_len)) { + // command starts with timeprop_ + int command_code = GetCommandCode(command, sizeof(command), XdrvMailbox.topic + ua_prefix_len, kTimepropCommands); + if (CMND_TIMEPROP_SETPOWER == command_code) { + /* + snprintf_P(log_data, sizeof(log_data), "Timeprop command timeprop_setpower: " + "index: %d data_len: %d payload: %d topic: %s data: %s", + XdrvMailbox.index, + XdrvMailbox.data_len, + XdrvMailbox.payload, + (XdrvMailbox.payload >= 0 ? XdrvMailbox.topic : ""), + (XdrvMailbox.data_len >= 0 ? XdrvMailbox.data : "")); + AddLog(LOG_LEVEL_INFO); + */ + if (XdrvMailbox.index >=0 && XdrvMailbox.index < TIMEPROP_NUM_OUTPUTS) { + timeprops[XdrvMailbox.index].setPower( atof(XdrvMailbox.data), timeprop_current_time_secs ); + } + snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"" D_CMND_TIMEPROP D_CMND_TIMEPROP_SETPOWER "%d\":\"%s\"}"), + XdrvMailbox.index, XdrvMailbox.data); + } + else { + serviced = false; + } + } else { + serviced = false; + } + return serviced; +} /*********************************************************************************************\ * Interface @@ -162,6 +210,9 @@ bool Xdrv48(byte function) case FUNC_EVERY_SECOND: Timeprop_Every_Second(); break; + case FUNC_COMMAND: + result = Timeprop_Command(); + break; case FUNC_SET_POWER: Timeprop_Xdrv_Power(); break; From d966f1f74f3469567d91997e9b45f5f7f148149c Mon Sep 17 00:00:00 2001 From: Marcus Date: Fri, 8 Jan 2021 21:57:56 +0100 Subject: [PATCH 03/16] add ifndef to ensure "tasmota-minimal" still builds --- tasmota/xdrv_48_timeprop.ino | 3 +++ tasmota/xdrv_49_pid.ino | 2 ++ 2 files changed, 5 insertions(+) diff --git a/tasmota/xdrv_48_timeprop.ino b/tasmota/xdrv_48_timeprop.ino index a457c8d94..f11d5e46b 100644 --- a/tasmota/xdrv_48_timeprop.ino +++ b/tasmota/xdrv_48_timeprop.ino @@ -79,6 +79,7 @@ #ifdef USE_TIMEPROP +#ifndef FIRMWARE_MINIMAL # include "Timeprop.h" @@ -153,6 +154,7 @@ bool Timeprop_Command() char command [CMDSZ]; bool serviced = true; uint8_t ua_prefix_len = strlen(D_CMND_TIMEPROP); // to detect prefix of command + AddLog_P(LOG_LEVEL_ERROR, PSTR("TRP: Timeprop_Command called")); /* snprintf_P(log_data, sizeof(log_data), "Command called: " "index: %d data_len: %d payload: %d topic: %s data: %s\n", @@ -220,4 +222,5 @@ bool Xdrv48(byte function) return result; } +#endif // FIRMWARE_MINIMAL #endif // USE_TIMEPROP diff --git a/tasmota/xdrv_49_pid.ino b/tasmota/xdrv_49_pid.ino index eda2b633f..fdc02ea50 100644 --- a/tasmota/xdrv_49_pid.ino +++ b/tasmota/xdrv_49_pid.ino @@ -129,6 +129,7 @@ #ifdef USE_PID +#ifndef FIRMWARE_MINIMAL #include "PID.h" @@ -410,4 +411,5 @@ bool Xdrv49(byte function) } return result; } +#endif // FIRMWARE_MINIMAL #endif // USE_PID From 2e76946e2daab4c9f968d6931f0641bc79eef8db Mon Sep 17 00:00:00 2001 From: Marcus Date: Sat, 9 Jan 2021 18:05:54 +0100 Subject: [PATCH 04/16] add missing Response to SetPv --- tasmota/xdrv_49_pid.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasmota/xdrv_49_pid.ino b/tasmota/xdrv_49_pid.ino index fdc02ea50..529ca3913 100644 --- a/tasmota/xdrv_49_pid.ino +++ b/tasmota/xdrv_49_pid.ino @@ -237,6 +237,7 @@ void CmndSetPv(void) { // this runs it at the next second run_pid_now = true; } + ResponseCmndNumber(atof(XdrvMailbox.data)); } void CmndSetSp(void) { @@ -358,7 +359,7 @@ void PIDShowValues(void) { static void run_pid() { double power = pid.tick(pid_current_time_secs); -#ifdef PID_DONT_USE_PID_TOPIC +#ifndef PID_DONT_USE_PID_TOPIC // This part is left inside to regularly publish the PID Power via // `%topic%/PID {"power":"0.000"}` char str_buf[FLOATSZ]; From 1fd5c44e6c16d1cadcd2315ca882e748592d10b8 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sat, 9 Jan 2021 18:23:07 +0100 Subject: [PATCH 05/16] add missing response; fix exclusion of PID power --- tasmota/xdrv_49_pid.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasmota/xdrv_49_pid.ino b/tasmota/xdrv_49_pid.ino index fdc02ea50..529ca3913 100644 --- a/tasmota/xdrv_49_pid.ino +++ b/tasmota/xdrv_49_pid.ino @@ -237,6 +237,7 @@ void CmndSetPv(void) { // this runs it at the next second run_pid_now = true; } + ResponseCmndNumber(atof(XdrvMailbox.data)); } void CmndSetSp(void) { @@ -358,7 +359,7 @@ void PIDShowValues(void) { static void run_pid() { double power = pid.tick(pid_current_time_secs); -#ifdef PID_DONT_USE_PID_TOPIC +#ifndef PID_DONT_USE_PID_TOPIC // This part is left inside to regularly publish the PID Power via // `%topic%/PID {"power":"0.000"}` char str_buf[FLOATSZ]; From 5a165962664b4ebf2294465d6433288e99f4b384 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sun, 10 Jan 2021 15:47:26 +0100 Subject: [PATCH 06/16] update code size metrics --- tasmota/my_user_config.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 5040f6c09..0eb76da95 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -811,10 +811,10 @@ // -- Prometheus exporter --------------------------- //#define USE_PROMETHEUS // Add support for https://prometheus.io/ metrics exporting over HTTP /metrics endpoint -// -- PID and Timeprop ------------------------------ -// #define use TIMEPROP // Add support for the timeprop feature (+0k8 code) +// -- PID and Timeprop ------------------------------ // Both together will add +12k1 code +// #define use TIMEPROP // Add support for the timeprop feature (+9k1 code) // For details on the configuration please see the header of tasmota/xdrv_48_timeprop.ino -// #define USE_PID // Add suport for the PID feature (+11k1 code) +// #define USE_PID // Add suport for the PID feature (+11k2 code) // For details on the configuration please see the header of tasmota/xdrv_49_pid.ino // -- End of general directives ------------------- From be68e1cdb1dd99aec84469744816a9e5b2a58844 Mon Sep 17 00:00:00 2001 From: Marcus Date: Fri, 8 Jan 2021 21:36:05 +0100 Subject: [PATCH 07/16] remove backward compatible #define option; Turned it into an undocumented option to suppress it --- tasmota/xdrv_49_pid.ino | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tasmota/xdrv_49_pid.ino b/tasmota/xdrv_49_pid.ino index 7da87ac7d..9d851b285 100644 --- a/tasmota/xdrv_49_pid.ino +++ b/tasmota/xdrv_49_pid.ino @@ -117,11 +117,6 @@ #define PID_REPORT_MORE_SETTINGS // If defined, the SENSOR output will provide more extensive json // output in the PID section -// #define PID_BACKWARD_COMPATIBLE // Preserve the backward compatible reporting of PID power via - // `%topic%/PID {"power":"0.000"}` This is now available in - // `%topic$/SENSOR {..., "PID":{"PidPower":0.00}}` - // Don't use unless you know that you need it - * Help with using the PID algorithm and with loop tuning can be found at * http://blog.clanlaw.org.uk/2018/01/09/PID-tuning-with-node-red-contrib-pid.html * This is directed towards using the algorithm in the node-red node node-red-contrib-pid but the algorithm here is based on @@ -391,14 +386,14 @@ void PIDShowValues(void) { void PIDRun(void) { double power = Pid.pid.tick(Pid.current_time_secs); -#ifdef PID_BACKWARD_COMPATIBLE +#ifdef PID_DONT_USE_PID_TOPIC // This part is left inside to regularly publish the PID Power via // `%topic%/PID {"power":"0.000"}` char str_buf[FLOATSZ]; dtostrfd(power, 3, str_buf); snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"%s\":\"%s\"}"), "power", str_buf); MqttPublishPrefixTopic_P(TELE, "PID", false); -#endif // PID_BACKWARD_COMPATIBLE +#endif // PID_DONT_USE_PID_TOPIC #if defined PID_SHUTTER // send output as a position from 0-100 to defined shutter From 405f25db08b055014e0d941edb032f5043f42473 Mon Sep 17 00:00:00 2001 From: Marcus Date: Fri, 8 Jan 2021 21:36:28 +0100 Subject: [PATCH 08/16] re-add code to modify timeprop values via mqtt --- tasmota/xdrv_48_timeprop.ino | 59 +++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/tasmota/xdrv_48_timeprop.ino b/tasmota/xdrv_48_timeprop.ino index bddf2653f..10fd3e843 100644 --- a/tasmota/xdrv_48_timeprop.ino +++ b/tasmota/xdrv_48_timeprop.ino @@ -81,6 +81,16 @@ * Publish values between 0 and 1 to the topic(s) described above \*********************************************************************************************/ +#define D_CMND_TIMEPROP "timeprop_" +#define D_CMND_TIMEPROP_SETPOWER "setpower_" // add index no on end (0:8) and data is power 0:1 + +enum TimepropCommands { CMND_TIMEPROP_SETPOWER }; +const char kTimepropCommands[] PROGMEM = D_CMND_TIMEPROP_SETPOWER; + +static Timeprop timeprops[TIMEPROP_NUM_OUTPUTS]; +static int relayNos[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_RELAYS}; +static long currentRelayStates = 0; // current actual relay states. Bit 0 first relay + #ifndef TIMEPROP_NUM_OUTPUTS #define TIMEPROP_NUM_OUTPUTS 1 // how many outputs to control (with separate alogorithm for each) #endif @@ -162,7 +172,51 @@ void TimepropXdrvPower(void) { /* char *data; */ /* } XdrvMailbox; */ -// To get here post with topic cmnd/timeprop_setpower_n where n is index into Tprop.timeprops 0:7 +// To get here post with topic cmnd/timeprop_setpower_n where n is index into timeprops 0:7 +bool TimepropCommand() +{ + char command [CMDSZ]; + bool serviced = true; + uint8_t ua_prefix_len = strlen(D_CMND_TIMEPROP); // to detect prefix of command + /* + snprintf_P(log_data, sizeof(log_data), "Command called: " + "index: %d data_len: %d payload: %d topic: %s data: %s\n", + XdrvMailbox.index, + XdrvMailbox.data_len, + XdrvMailbox.payload, + (XdrvMailbox.payload >= 0 ? XdrvMailbox.topic : ""), + (XdrvMailbox.data_len >= 0 ? XdrvMailbox.data : "")); + + AddLog(LOG_LEVEL_INFO); + */ + if (0 == strncasecmp_P(XdrvMailbox.topic, PSTR(D_CMND_TIMEPROP), ua_prefix_len)) { + // command starts with timeprop_ + int command_code = GetCommandCode(command, sizeof(command), XdrvMailbox.topic + ua_prefix_len, kTimepropCommands); + if (CMND_TIMEPROP_SETPOWER == command_code) { + /* + snprintf_P(log_data, sizeof(log_data), "Timeprop command timeprop_setpower: " + "index: %d data_len: %d payload: %d topic: %s data: %s", + XdrvMailbox.index, + XdrvMailbox.data_len, + XdrvMailbox.payload, + (XdrvMailbox.payload >= 0 ? XdrvMailbox.topic : ""), + (XdrvMailbox.data_len >= 0 ? XdrvMailbox.data : "")); + AddLog(LOG_LEVEL_INFO); + */ + if (XdrvMailbox.index >=0 && XdrvMailbox.index < TIMEPROP_NUM_OUTPUTS) { + timeprops[XdrvMailbox.index].setPower( atof(XdrvMailbox.data), timeprop_current_time_secs ); + } + snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"" D_CMND_TIMEPROP D_CMND_TIMEPROP_SETPOWER "%d\":\"%s\"}"), + XdrvMailbox.index, XdrvMailbox.data); + } + else { + serviced = false; + } + } else { + serviced = false; + } + return serviced; +} /*********************************************************************************************\ * Interface @@ -180,6 +234,9 @@ bool Xdrv48(byte function) { case FUNC_EVERY_SECOND: TimepropEverySecond(); break; + case FUNC_COMMAND: + result = TimepropCommand(); + break; case FUNC_SET_POWER: TimepropXdrvPower(); break; From 02d8715d3d2534fa19b3f8e44b51c683af18ba23 Mon Sep 17 00:00:00 2001 From: Marcus Date: Fri, 8 Jan 2021 21:57:56 +0100 Subject: [PATCH 09/16] add ifndef to ensure "tasmota-minimal" still builds --- tasmota/xdrv_48_timeprop.ino | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tasmota/xdrv_48_timeprop.ino b/tasmota/xdrv_48_timeprop.ino index 10fd3e843..7bb772f08 100644 --- a/tasmota/xdrv_48_timeprop.ino +++ b/tasmota/xdrv_48_timeprop.ino @@ -79,7 +79,10 @@ #define TIMEPROP_RELAYS 1, 2 // which relay to control 1:8 * Publish values between 0 and 1 to the topic(s) described above -\*********************************************************************************************/ + * +**/ + + #define D_CMND_TIMEPROP "timeprop_" #define D_CMND_TIMEPROP_SETPOWER "setpower_" // add index no on end (0:8) and data is power 0:1 @@ -91,6 +94,7 @@ static Timeprop timeprops[TIMEPROP_NUM_OUTPUTS]; static int relayNos[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_RELAYS}; static long currentRelayStates = 0; // current actual relay states. Bit 0 first relay + #ifndef TIMEPROP_NUM_OUTPUTS #define TIMEPROP_NUM_OUTPUTS 1 // how many outputs to control (with separate alogorithm for each) #endif @@ -178,6 +182,7 @@ bool TimepropCommand() char command [CMDSZ]; bool serviced = true; uint8_t ua_prefix_len = strlen(D_CMND_TIMEPROP); // to detect prefix of command + AddLog_P(LOG_LEVEL_ERROR, PSTR("TRP: Timeprop_Command called")); /* snprintf_P(log_data, sizeof(log_data), "Command called: " "index: %d data_len: %d payload: %d topic: %s data: %s\n", From d54ee124412670a526106506b3723635d0c0dde8 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sat, 9 Jan 2021 18:05:54 +0100 Subject: [PATCH 10/16] add missing Response to SetPv --- tasmota/xdrv_49_pid.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/tasmota/xdrv_49_pid.ino b/tasmota/xdrv_49_pid.ino index 9d851b285..e44a7e6f1 100644 --- a/tasmota/xdrv_49_pid.ino +++ b/tasmota/xdrv_49_pid.ino @@ -266,6 +266,7 @@ void CmndSetPv(void) { // this runs it at the next second Pid.run_pid_now = true; } + ResponseCmndNumber(atof(XdrvMailbox.data)); } void CmndSetSp(void) { From dee3864f871f09bdf7aaa49fd806c90bcf433338 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sun, 10 Jan 2021 15:47:26 +0100 Subject: [PATCH 11/16] update code size metrics --- tasmota/my_user_config.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index cad1a2e83..12f47d073 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -828,10 +828,10 @@ #define THERMOSTAT_TEMP_BAND_NO_PEAK_DET 1 // Default temperature band in thenths of degrees celsius within no peak will be detected #define THERMOSTAT_TIME_STD_DEV_PEAK_DET_OK 10 // Default standard deviation in minutes of the oscillation periods within the peak detection is successful -// -- PID and Timeprop ------------------------------ -//#define USE_TIMEPROP // Add support for the timeprop feature (+0k8 code) +// -- PID and Timeprop ------------------------------ // Both together will add +12k1 code +// #define use TIMEPROP // Add support for the timeprop feature (+9k1 code) // For details on the configuration please see the header of tasmota/xdrv_48_timeprop.ino -//#define USE_PID // Add suport for the PID feature (+11k1 code) +// #define USE_PID // Add suport for the PID feature (+11k2 code) // For details on the configuration please see the header of tasmota/xdrv_49_pid.ino // -- End of general directives --------------------- From 97f3a7d438d103d7ee38ef68c324dd3802940362 Mon Sep 17 00:00:00 2001 From: Marcus Date: Mon, 11 Jan 2021 18:42:00 +0100 Subject: [PATCH 12/16] readd TimePropCommand --- tasmota/xdrv_48_timeprop.ino | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tasmota/xdrv_48_timeprop.ino b/tasmota/xdrv_48_timeprop.ino index 93a75efe9..684d6e4b3 100644 --- a/tasmota/xdrv_48_timeprop.ino +++ b/tasmota/xdrv_48_timeprop.ino @@ -87,6 +87,8 @@ #define D_CMND_TIMEPROP "timeprop_" #define D_CMND_TIMEPROP_SETPOWER "setpower_" // add index no on end (0:8) and data is power 0:1 +#include "Timeprop.h" + enum TimepropCommands { CMND_TIMEPROP_SETPOWER }; const char kTimepropCommands[] PROGMEM = D_CMND_TIMEPROP_SETPOWER; @@ -117,8 +119,6 @@ static long currentRelayStates = 0; // current actual relay states. Bit 0 first #define TIMEPROP_RELAYS 1 // which relay to control 1:8 #endif -#include "Timeprop.h" - struct { Timeprop timeprops[TIMEPROP_NUM_OUTPUTS]; int relay_nos[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_RELAYS}; @@ -209,7 +209,7 @@ bool TimepropCommand() AddLog(LOG_LEVEL_INFO); */ if (XdrvMailbox.index >=0 && XdrvMailbox.index < TIMEPROP_NUM_OUTPUTS) { - timeprops[XdrvMailbox.index].setPower( atof(XdrvMailbox.data), timeprop_current_time_secs ); + timeprops[XdrvMailbox.index].setPower( atof(XdrvMailbox.data), Tprop.current_time_secs ); } snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"" D_CMND_TIMEPROP D_CMND_TIMEPROP_SETPOWER "%d\":\"%s\"}"), XdrvMailbox.index, XdrvMailbox.data); @@ -239,12 +239,9 @@ bool Xdrv48(byte function) { case FUNC_EVERY_SECOND: TimepropEverySecond(); break; - case FUNC_COMMAND: - result = TimepropCommand(); - break; - case FUNC_COMMAND: - result = TimepropCommand(); - break; + case FUNC_COMMAND: + result = TimepropCommand(); + break; case FUNC_SET_POWER: TimepropXdrvPower(); break; @@ -252,5 +249,4 @@ bool Xdrv48(byte function) { return result; } -#endif // FIRMWARE_MINIMAL #endif // USE_TIMEPROP From 611456327d320cb7775b1f219ebc34e960b712f2 Mon Sep 17 00:00:00 2001 From: Marcus Date: Mon, 11 Jan 2021 18:59:20 +0100 Subject: [PATCH 13/16] make sure code compiles with tasmota-minimal --- tasmota/xdrv_48_timeprop.ino | 2 ++ tasmota/xdrv_49_pid.ino | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tasmota/xdrv_48_timeprop.ino b/tasmota/xdrv_48_timeprop.ino index 684d6e4b3..a885f242d 100644 --- a/tasmota/xdrv_48_timeprop.ino +++ b/tasmota/xdrv_48_timeprop.ino @@ -18,6 +18,7 @@ */ #ifdef USE_TIMEPROP +#ifndef FIRMWARE_MINIMAL /*********************************************************************************************\ * Code to drive one or more relays in a time proportioned manner give a * required power value. @@ -249,4 +250,5 @@ bool Xdrv48(byte function) { return result; } +#endif // FIRMWARE_MINIMAL #endif // USE_TIMEPROP diff --git a/tasmota/xdrv_49_pid.ino b/tasmota/xdrv_49_pid.ino index e44a7e6f1..c3341b008 100644 --- a/tasmota/xdrv_49_pid.ino +++ b/tasmota/xdrv_49_pid.ino @@ -18,6 +18,7 @@ */ #ifdef USE_PID +#ifndef FIRMWARE_MINIMAL /*********************************************************************************************\ * Uses the library https://github.com/colinl/process-control.git from Github * In user_config_override.h include code as follows: @@ -439,4 +440,5 @@ bool Xdrv49(byte function) { } return result; } +#endif //FIRMWARE_MINIMAL #endif // USE_PID From 06cc6406dade7946cc71da3c4a5afc2f74b6586f Mon Sep 17 00:00:00 2001 From: Marcus Date: Mon, 11 Jan 2021 19:01:19 +0100 Subject: [PATCH 14/16] remove log entry --- tasmota/xdrv_48_timeprop.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/tasmota/xdrv_48_timeprop.ino b/tasmota/xdrv_48_timeprop.ino index a885f242d..5589868de 100644 --- a/tasmota/xdrv_48_timeprop.ino +++ b/tasmota/xdrv_48_timeprop.ino @@ -183,7 +183,6 @@ bool TimepropCommand() char command [CMDSZ]; bool serviced = true; uint8_t ua_prefix_len = strlen(D_CMND_TIMEPROP); // to detect prefix of command - AddLog_P(LOG_LEVEL_ERROR, PSTR("TRP: Timeprop_Command called")); /* snprintf_P(log_data, sizeof(log_data), "Command called: " "index: %d data_len: %d payload: %d topic: %s data: %s\n", From e56a08f4de7a8258a4736a5de94fb6505611c368 Mon Sep 17 00:00:00 2001 From: Marcus Date: Tue, 12 Jan 2021 09:00:17 +0100 Subject: [PATCH 15/16] Change Response to Float, where floats are stored --- tasmota/xdrv_49_pid.ino | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tasmota/xdrv_49_pid.ino b/tasmota/xdrv_49_pid.ino index c3341b008..2773137a5 100644 --- a/tasmota/xdrv_49_pid.ino +++ b/tasmota/xdrv_49_pid.ino @@ -267,27 +267,27 @@ void CmndSetPv(void) { // this runs it at the next second Pid.run_pid_now = true; } - ResponseCmndNumber(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data)); } void CmndSetSp(void) { Pid.pid.setSp(atof(XdrvMailbox.data)); - ResponseCmndNumber(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data)); } void CmndSetPb(void) { Pid.pid.setPb(atof(XdrvMailbox.data)); - ResponseCmndNumber(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data)); } void CmndSetTi(void) { Pid.pid.setTi(atof(XdrvMailbox.data)); - ResponseCmndNumber(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data)); } void CmndSetTd(void) { Pid.pid.setTd(atof(XdrvMailbox.data)); - ResponseCmndNumber(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data)); } void CmndSetInitialInt(void) { @@ -297,7 +297,7 @@ void CmndSetInitialInt(void) { void CmndSetDSmooth(void) { Pid.pid.setDSmooth(atof(XdrvMailbox.data)); - ResponseCmndNumber(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data)); } void CmndSetAuto(void) { @@ -307,7 +307,7 @@ void CmndSetAuto(void) { void CmndSetManualPower(void) { Pid.pid.setManualPower(atof(XdrvMailbox.data)); - ResponseCmndNumber(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data)); } void CmndSetMaxInterval(void) { From e63b3d9ac9bcafda5764eba3725bb575dd8e895b Mon Sep 17 00:00:00 2001 From: Marcus Date: Tue, 12 Jan 2021 09:14:19 +0100 Subject: [PATCH 16/16] add number of digits to ResponseCmndFloat --- tasmota/xdrv_49_pid.ino | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tasmota/xdrv_49_pid.ino b/tasmota/xdrv_49_pid.ino index 2773137a5..15097106b 100644 --- a/tasmota/xdrv_49_pid.ino +++ b/tasmota/xdrv_49_pid.ino @@ -267,27 +267,27 @@ void CmndSetPv(void) { // this runs it at the next second Pid.run_pid_now = true; } - ResponseCmndFloat(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data), 1); } void CmndSetSp(void) { Pid.pid.setSp(atof(XdrvMailbox.data)); - ResponseCmndFloat(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data), 1); } void CmndSetPb(void) { Pid.pid.setPb(atof(XdrvMailbox.data)); - ResponseCmndFloat(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data), 1); } void CmndSetTi(void) { Pid.pid.setTi(atof(XdrvMailbox.data)); - ResponseCmndFloat(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data), 1); } void CmndSetTd(void) { Pid.pid.setTd(atof(XdrvMailbox.data)); - ResponseCmndFloat(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data), 1); } void CmndSetInitialInt(void) { @@ -297,7 +297,7 @@ void CmndSetInitialInt(void) { void CmndSetDSmooth(void) { Pid.pid.setDSmooth(atof(XdrvMailbox.data)); - ResponseCmndFloat(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data), 1); } void CmndSetAuto(void) { @@ -307,7 +307,7 @@ void CmndSetAuto(void) { void CmndSetManualPower(void) { Pid.pid.setManualPower(atof(XdrvMailbox.data)); - ResponseCmndFloat(atof(XdrvMailbox.data)); + ResponseCmndFloat(atof(XdrvMailbox.data), 1); } void CmndSetMaxInterval(void) {