Merge pull request #18 from arendst/development

Update
This commit is contained in:
Adrian 2018-03-31 18:44:55 -03:00 committed by GitHub
commit cfb2d31ca1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 90 additions and 76 deletions

View File

@ -4,8 +4,10 @@
* Add optional Timer configuration webpage to be enabled in user_config.h with define USE_TIMERS_WEB * Add optional Timer configuration webpage to be enabled in user_config.h with define USE_TIMERS_WEB
* Add Home Assistant MQTT Discovery for Buttons and change SetOption19 response (#2277) * Add Home Assistant MQTT Discovery for Buttons and change SetOption19 response (#2277)
* Add support for SGP30 gas and air quality sensor (#2307) * Add support for SGP30 gas and air quality sensor (#2307)
* Add multiple color entry support for command Led like Led2 120000.001200.000012 setting led2 as Red, Led3 as Green and Led4 as Blue (#2303)
* Change webpage parameter communication * Change webpage parameter communication
* Change Timer parameter Device to more obvious Output * Change Timer parameter Device to more obvious Output
* Change max number of commands in Backlog from 15 to 30 and ignore commands overflowing
* Change MQTT response topic for Energy changes from ENERGY to SENSOR (#2229, #2251) * Change MQTT response topic for Energy changes from ENERGY to SENSOR (#2229, #2251)
* Change default Reset configuration time from 4 seconds to 40 seconds on Button hold (#2268) * Change default Reset configuration time from 4 seconds to 40 seconds on Button hold (#2268)
* *

View File

@ -358,6 +358,7 @@
#define D_JSON_TIMER_REPEAT "Repeat" #define D_JSON_TIMER_REPEAT "Repeat"
#define D_JSON_TIMER_OUTPUT "Output" #define D_JSON_TIMER_OUTPUT "Output"
#define D_JSON_TIMER_POWER "Power" #define D_JSON_TIMER_POWER "Power"
#define D_JSON_TIMER_NO_DEVICE "No GPIO as output configured"
#define D_CMND_TIMERS "Timers" #define D_CMND_TIMERS "Timers"
/********************************************************************************************/ /********************************************************************************************/

View File

@ -97,7 +97,7 @@ typedef unsigned long power_t; // Power (Relay) type
#define WEB_LOG_SIZE 4000 // Max number of characters in weblog #define WEB_LOG_SIZE 4000 // Max number of characters in weblog
#endif #endif
#define MAX_BACKLOG 16 // Max number of commands in backlog (chk backlog_index and backlog_pointer code) #define MAX_BACKLOG 30 // Max number of commands in backlog
#define MIN_BACKLOG_DELAY 2 // Minimal backlog delay in 0.1 seconds #define MIN_BACKLOG_DELAY 2 // Minimal backlog delay in 0.1 seconds
#define SOFT_BAUDRATE 9600 // Default software serial baudrate #define SOFT_BAUDRATE 9600 // Default software serial baudrate

View File

@ -463,16 +463,13 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
int command_code = GetCommandCode(command, sizeof(command), type, kTasmotaCommands); int command_code = GetCommandCode(command, sizeof(command), type, kTasmotaCommands);
if (CMND_BACKLOG == command_code) { if (CMND_BACKLOG == command_code) {
if (data_len) { if (data_len) {
uint8_t bl_pointer = (!backlog_pointer) ? MAX_BACKLOG -1 : backlog_pointer;
bl_pointer--;
char *blcommand = strtok(dataBuf, ";"); char *blcommand = strtok(dataBuf, ";");
while (blcommand != NULL) { while ((blcommand != NULL) && (backlog_index != bl_pointer)) {
backlog[backlog_index] = String(blcommand); backlog[backlog_index] = String(blcommand);
backlog_index++; backlog_index++;
/* if (backlog_index >= MAX_BACKLOG) backlog_index = 0;
if (backlog_index >= MAX_BACKLOG) {
backlog_index = 0;
}
*/
backlog_index &= 0xF;
blcommand = strtok(NULL, ";"); blcommand = strtok(NULL, ";");
} }
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_APPENDED); snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_APPENDED);
@ -1762,12 +1759,7 @@ void StateLoop()
ExecuteCommand((char*)backlog[backlog_pointer].c_str()); ExecuteCommand((char*)backlog[backlog_pointer].c_str());
backlog_mutex = 0; backlog_mutex = 0;
backlog_pointer++; backlog_pointer++;
/* if (backlog_pointer >= MAX_BACKLOG) backlog_pointer = 0;
if (backlog_pointer >= MAX_BACKLOG) {
backlog_pointer = 0;
}
*/
backlog_pointer &= 0xF;
} }
} }

View File

@ -45,7 +45,7 @@ void WifiWpsStatusCallback(wps_cb_status status);
#define USE_HTU // Add I2C code for HTU21/SI7013/SI7020/SI7021 sensor (+1k5 code) #define USE_HTU // Add I2C code for HTU21/SI7013/SI7020/SI7021 sensor (+1k5 code)
#define USE_BMP // Add I2C code for BMP085/BMP180/BMP280/BME280 sensor (+4k code) #define USE_BMP // Add I2C code for BMP085/BMP180/BMP280/BME280 sensor (+4k code)
#define USE_BME680 // Add additional support for BME680 sensor using Adafruit Sensor and BME680 libraries (+6k code) #define USE_BME680 // Add additional support for BME680 sensor using Adafruit Sensor and BME680 libraries (+6k code)
#define USE_SGP30 // Add I2C code for SGP30 sensor (+4k code) #define USE_SGP30 // Add I2C code for SGP30 sensor (+1k1 code)
#define USE_BH1750 // Add I2C code for BH1750 sensor (+0k5 code) #define USE_BH1750 // Add I2C code for BH1750 sensor (+0k5 code)
#define USE_VEML6070 // Add I2C code for VEML6070 sensor (+0k5 code) #define USE_VEML6070 // Add I2C code for VEML6070 sensor (+0k5 code)
#define USE_TSL2561 // Add I2C code for TSL2561 sensor using library Adafruit TSL2561 Arduino (+1k2 code) #define USE_TSL2561 // Add I2C code for TSL2561 sensor using library Adafruit TSL2561 Arduino (+1k2 code)

View File

@ -185,15 +185,17 @@ const char HTTP_BTN_MENU1[] PROGMEM =
"<br/><form action='cs' method='get'><button>" D_CONSOLE "</button></form>"; "<br/><form action='cs' method='get'><button>" D_CONSOLE "</button></form>";
const char HTTP_BTN_RSTRT[] PROGMEM = const char HTTP_BTN_RSTRT[] PROGMEM =
"<br/><form action='rb' method='get' onsubmit='return confirm(\"" D_CONFIRM_RESTART "\");'><button>" D_RESTART "</button></form>"; "<br/><form action='rb' method='get' onsubmit='return confirm(\"" D_CONFIRM_RESTART "\");'><button>" D_RESTART "</button></form>";
const char HTTP_BTN_MENU2[] PROGMEM = const char HTTP_BTN_MENU_MODULE[] PROGMEM =
"<br/><form action='md' method='get'><button>" D_CONFIGURE_MODULE "</button></form>" "<br/><form action='md' method='get'><button>" D_CONFIGURE_MODULE "</button></form>";
#ifdef USE_TIMERS #ifdef USE_TIMERS
#ifdef USE_TIMERS_WEB #ifdef USE_TIMERS_WEB
"<br/><form action='tm' method='get'><button>" D_CONFIGURE_TIMER "</button></form>" const char HTTP_BTN_MENU_TIMER[] PROGMEM =
"<br/><form action='tm' method='get'><button>" D_CONFIGURE_TIMER "</button></form>";
#endif // USE_TIMERS_WEB #endif // USE_TIMERS_WEB
#endif // USE_TIMERS #endif // USE_TIMERS
const char HTTP_BTN_MENU_WIFI[] PROGMEM =
"<br/><form action='w0' method='get'><button>" D_CONFIGURE_WIFI "</button></form>"; "<br/><form action='w0' method='get'><button>" D_CONFIGURE_WIFI "</button></form>";
const char HTTP_BTN_MENU3[] PROGMEM = const char HTTP_BTN_MENU_MQTT[] PROGMEM =
"<br/><form action='mq' method='get'><button>" D_CONFIGURE_MQTT "</button></form>" "<br/><form action='mq' method='get'><button>" D_CONFIGURE_MQTT "</button></form>"
#ifdef USE_DOMOTICZ #ifdef USE_DOMOTICZ
"<br/><form action='dm' method='get'><button>" D_CONFIGURE_DOMOTICZ "</button></form>" "<br/><form action='dm' method='get'><button>" D_CONFIGURE_DOMOTICZ "</button></form>"
@ -639,10 +641,14 @@ void HandleConfiguration()
String page = FPSTR(HTTP_HEAD); String page = FPSTR(HTTP_HEAD);
page.replace(F("{v}"), FPSTR(S_CONFIGURATION)); page.replace(F("{v}"), FPSTR(S_CONFIGURATION));
page += FPSTR(HTTP_HEAD_STYLE); page += FPSTR(HTTP_HEAD_STYLE);
page += FPSTR(HTTP_BTN_MENU2); page += FPSTR(HTTP_BTN_MENU_MODULE);
if (Settings.flag.mqtt_enabled) { #ifdef USE_TIMERS
page += FPSTR(HTTP_BTN_MENU3); #ifdef USE_TIMERS_WEB
} if (devices_present) page += FPSTR(HTTP_BTN_MENU_TIMER);
#endif // USE_TIMERS_WEB
#endif // USE_TIMERS
page += FPSTR(HTTP_BTN_MENU_WIFI);
if (Settings.flag.mqtt_enabled) page += FPSTR(HTTP_BTN_MENU_MQTT);
page += FPSTR(HTTP_BTN_MENU4); page += FPSTR(HTTP_BTN_MENU4);
page += FPSTR(HTTP_BTN_MAIN); page += FPSTR(HTTP_BTN_MAIN);
ShowPage(page); ShowPage(page);

View File

@ -1114,8 +1114,16 @@ boolean LightCommand()
#ifdef USE_WS2812 // *********************************************************************** #ifdef USE_WS2812 // ***********************************************************************
else if ((CMND_LED == command_code) && (LT_WS2812 == light_type) && (XdrvMailbox.index > 0) && (XdrvMailbox.index <= Settings.light_pixels)) { else if ((CMND_LED == command_code) && (LT_WS2812 == light_type) && (XdrvMailbox.index > 0) && (XdrvMailbox.index <= Settings.light_pixels)) {
if (XdrvMailbox.data_len > 0) { if (XdrvMailbox.data_len > 0) {
if (LightColorEntry(XdrvMailbox.data, XdrvMailbox.data_len)) { char *p;
Ws2812SetColor(XdrvMailbox.index, light_entry_color[0], light_entry_color[1], light_entry_color[2], light_entry_color[3]); uint16_t idx = XdrvMailbox.index;
for (char *color = strtok_r(XdrvMailbox.data, ".", &p); color; color = strtok_r(NULL, ".", &p)) {
if (LightColorEntry(color, strlen(color))) {
Ws2812SetColor(idx, light_entry_color[0], light_entry_color[1], light_entry_color[2], light_entry_color[3]);
idx++;
if (idx >= Settings.light_pixels) break;
} else {
break;
}
} }
} }
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, command, XdrvMailbox.index, Ws2812GetColor(XdrvMailbox.index, scolor)); snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, command, XdrvMailbox.index, Ws2812GetColor(XdrvMailbox.index, scolor));

View File

@ -97,6 +97,7 @@ boolean TimerCommand()
Settings.timer[index -1].data = Settings.timer[XdrvMailbox.payload -1].data; // Copy timer Settings.timer[index -1].data = Settings.timer[XdrvMailbox.payload -1].data; // Copy timer
} }
} else { } else {
if (devices_present) {
StaticJsonBuffer<128> jsonBuffer; StaticJsonBuffer<128> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(dataBufUc); JsonObject& root = jsonBuffer.parseObject(dataBufUc);
if (!root.success()) { if (!root.success()) {
@ -157,6 +158,10 @@ boolean TimerCommand()
index++; index++;
} }
} else {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_TIMER "%d\":\"" D_JSON_TIMER_NO_DEVICE "\"}"), index); // No outputs defined so nothing to control
error = 1;
}
} }
} }
if (!error) { if (!error) {