5.12.0b
 * Add Webserver upload preflight request support (#1927)
 * Add
Home Assistant clear other device (#1931)
This commit is contained in:
arendst 2018-02-16 17:35:51 +01:00
parent b8d016914e
commit 5c60979682
5 changed files with 45 additions and 1 deletions

View File

@ -20,6 +20,7 @@ src_dir = sonoff
;env_default = sonoff-IT
;env_default = sonoff-NL
;env_default = sonoff-PL
;env_default = sonoff-RU
;env_default = sonoff-CN
[env:sonoff]
@ -143,6 +144,18 @@ extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-RU]
platform = espressif8266
framework = arduino
board = esp01_1m
board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=ru-RU
lib_deps = PubSubClient, NeoPixelBus, IRremoteESP8266, ArduinoJSON
extra_scripts = pio/strip-floats.py
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-CN]
platform = espressif8266
framework = arduino

View File

@ -5,6 +5,8 @@
* Add optional usage of %d or %04d in ota url to be replaced with chipid (#1871)
* Add user configurable serial GPIOs to MagicHome and Arilux modules (#1887)
* Add Russian language file (#1909)
* Add Webserver upload preflight request support (#1927)
* Add Home Assistant clear other device (#1931)
*
* 5.12.0a
* Change platformio option sonoff-ds18x20 to sonoff-xxl enabling ds18x20 and all other sensors in one image

View File

@ -865,6 +865,22 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
0,
GPIO_PWM4, // GPIO15 RGBW LED White
0, 0
}
{ "Ledunia", // Ledunia (ESP8266) - http://ledunia.de/
GPIO_USER, // GPIO00 (D0)
GPIO_USER, // GPIO01 (D7) Serial RXD
GPIO_USER, // GPIO02 (D2)
GPIO_USER, // GPIO03 (D8) Serial TXD
GPIO_USER, // GPIO04 (D4) 4 x WS2812 Leds, (DOUT) Extents WS2812 string
GPIO_USER, // GPIO05 (D5) Blue Led
0, 0, 0, 0, 0, 0, // Flash connection
GPIO_USER, // GPIO12 (D12)
GPIO_USER, // GPIO13 (D13)
GPIO_USER, // GPIO14 (D14)
GPIO_USER, // GPIO15 (D15)
GPIO_USER, // GPIO16 (D16)
0 // ADC0 Analog input (A0)
},
*/

View File

@ -347,6 +347,7 @@ void StartWebserver(int type, IPAddress ipweb)
WebServer->on("/up", HandleUpgradeFirmware);
WebServer->on("/u1", HandleUpgradeFirmwareStart); // OTA
WebServer->on("/u2", HTTP_POST, HandleUploadDone, HandleUploadLoop);
WebServer->on("/u2", HTTP_OPTIONS, HandlePreflightRequest);
WebServer->on("/cm", HandleHttpCommand);
WebServer->on("/cs", HandleConsole);
WebServer->on("/ax", HandleAjaxConsoleRefresh);
@ -1417,6 +1418,14 @@ void HandleUploadLoop()
delay(0);
}
void HandlePreflightRequest()
{
WebServer->sendHeader(F("Access-Control-Allow-Origin"), F("*"));
WebServer->sendHeader(F("Access-Control-Allow-Methods"), F("GET, POST"));
WebServer->sendHeader(F("Access-Control-Allow-Headers"), F("authorization"));
WebServer->send(200, FPSTR(HDR_CTYPE_HTML), "");
}
void HandleHttpCommand()
{
if (HttpUser()) {

View File

@ -89,10 +89,14 @@ void HAssDiscovery()
for (int i = 1; i <= devices_present; i++) {
is_light = ((i == devices_present) && (light_type));
mqtt_data[0] = '\0';
snprintf_P(sidx, sizeof(sidx), PSTR("_%d"), i);
// Clear "other" topic first in case the device has been reconfigured
snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/%s/%s%s/config"), (is_light) ? "switch" : "light", mqtt_topic, (1 == devices_present) ? "" : sidx);
MqttPublish(stopic, true);
snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/%s/%s%s/config"), (is_light) ? "light" : "switch", mqtt_topic, (1 == devices_present) ? "" : sidx);
mqtt_data[0] = '\0';
if (Settings.flag.hass_discovery) {
char name[33];
char value_template[33];