Merge pull request #70 from arendst/development

Update from Tasmota
This commit is contained in:
Adrian Scillato 2018-04-25 20:16:22 -03:00 committed by GitHub
commit f4980720e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 286 additions and 255 deletions

View File

@ -31,282 +31,274 @@ src_dir = sonoff
;env_default = sonoff-RU ;env_default = sonoff-RU
;env_default = sonoff-TW ;env_default = sonoff-TW
[env:sonoff] [common] ; ************************************************************
; *** Esp8266 core for Arduino version
;platform = espressif8266@1.5.0 ; v2.3.0 ;platform = espressif8266@1.5.0 ; v2.3.0
;platform = espressif8266@1.6.0 ; v2.4.0 ;platform = espressif8266@1.6.0 ; v2.4.0
;platform = espressif8266@1.7.0 ; v2.4.1
;platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
platform = espressif8266 platform = espressif8266
framework = arduino framework = arduino
board = esp01_1m board = esp01_1m
board_flash_mode = dout board_flash_mode = dout
build_flags = -Wl,-Tesp8266.flash.1m0.ld
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DUSE_CONFIG_OVERRIDE ; *** Fix espressif8266@1.7.0 induced undesired all warnings
build_unflags = -Wall
build_flags =
-Wl,-Tesp8266.flash.1m0.ld
-DVTABLES_IN_FLASH
-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
; -DUSE_CONFIG_OVERRIDE
; *** Fix Esp/Arduino core 2.4.x induced Tasmota unused floating point includes
extra_scripts = pio/strip-floats.py extra_scripts = pio/strip-floats.py
; *** Serial Monitor options ; *** Serial Monitor options
monitor_baud = 115200 monitor_baud = 115200
; *** Upload Serial reset method for Wemos and NodeMCU ; *** Upload Serial reset method for Wemos and NodeMCU
;upload_port = COM5
;upload_speed = 115200 ;upload_speed = 115200
;upload_resetmethod = nodemcu upload_speed = 512000
upload_resetmethod = nodemcu
;upload_port = COM5
; *** Upload file to OTA server using SCP ; *** Upload file to OTA server using SCP
;upload_port = user@host:/path ;upload_port = user@host:/path
;extra_scripts = pio/sftp-uploader.py ;extra_scripts = pio/strip-floats.py, pio/sftp-uploader.py
; *** Upload file to OTA server using HTTP ; *** Upload file to OTA server using HTTP
;upload_port = domus1:80/api/upload-arduino.php upload_port = domus1:80/api/upload-arduino.php
;extra_scripts = pio/strip-floats.py, pio/http-uploader.py extra_scripts = pio/strip-floats.py, pio/http-uploader.py
; *********************************************************************
[env:sonoff]
platform = ${common.platform}
framework = ${common.framework}
board = ${common.board}
board_flash_mode = ${common.board_flash_mode}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags}
monitor_baud = ${common.monitor_baud}
upload_speed = ${common.upload_speed}
upload_resetmethod = ${common.upload_resetmethod}
upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
[env:sonoff-minimal] [env:sonoff-minimal]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DBE_MINIMAL
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DBE_MINIMAL monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DBE_MINIMAL -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
upload_port = ${common.upload_port}
extra_scripts = pio/strip-floats.py extra_scripts = ${common.extra_scripts}
; Serial Monitor options
monitor_baud = 115200
[env:sonoff-classic] [env:sonoff-classic]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DUSE_CLASSIC
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DUSE_CLASSIC monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DUSE_CLASSIC -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; Serial Monitor options
monitor_baud = 115200
[env:sonoff-knx] [env:sonoff-knx]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DUSE_KNX_NO_EMULATION
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DUSE_KNX_NO_EMULATION monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DUSE_KNX_NO_EMULATION -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; Serial Monitor options
monitor_baud = 115200
[env:sonoff-allsensors] [env:sonoff-allsensors]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DUSE_ALL_SENSORS
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DUSE_ALL_SENSORS monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DUSE_ALL_SENSORS -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; Serial Monitor options
monitor_baud = 115200
[env:sonoff-BG] [env:sonoff-BG]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=bg-BG
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=bg-BG monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=bg-BG -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-CN] [env:sonoff-CN]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=zh-CN
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=zh-CN monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=zh-CN -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-CZ] [env:sonoff-CZ]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=cs-CZ
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=cs-CZ monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=cs-CZ -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-DE] [env:sonoff-DE]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=de-DE
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=de-DE monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=de-DE -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-ES] [env:sonoff-ES]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=es-AR
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=es-AR monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=es-AR -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-FR] [env:sonoff-FR]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=fr-FR
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=fr-FR monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=fr-FR -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-GR] [env:sonoff-GR]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=el-GR
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=el-GR monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=el-GR -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-HU] [env:sonoff-HU]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=hu-HU
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=hu-HU monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=hu-HU -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-IT] [env:sonoff-IT]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=it-IT
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=it-IT monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=it-IT -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-NL] [env:sonoff-NL]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=nl-NL
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=nl-NL monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=nl-NL -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-PL] [env:sonoff-PL]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=pl-PL
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=pl-PL monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=pl-PL -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-PT] [env:sonoff-PT]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=pt-PT
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=pt-PT monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=pt-PT -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-RU] [env:sonoff-RU]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=ru-RU
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=ru-RU monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=ru-RU -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200
[env:sonoff-TW] [env:sonoff-TW]
;platform = espressif8266@1.5.0 ; v2.3.0 platform = ${common.platform}
;platform = espressif8266@1.6.0 ; v2.4.0 framework = ${common.framework}
platform = espressif8266 board = ${common.board}
framework = arduino board_flash_mode = ${common.board_flash_mode}
board = esp01_1m build_unflags = ${common.build_unflags}
board_flash_mode = dout build_flags = ${common.build_flags} -DMY_LANGUAGE=zh-TW
build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=zh-TW monitor_baud = ${common.monitor_baud}
;build_flags = -Wl,-Tesp8266.flash.1m0.ld -DMY_LANGUAGE=zh-TW -DUSE_CONFIG_OVERRIDE upload_speed = ${common.upload_speed}
extra_scripts = pio/strip-floats.py upload_port = ${common.upload_port}
extra_scripts = ${common.extra_scripts}
; *** Serial Monitor options
monitor_baud = 115200

View File

@ -3,6 +3,7 @@
* Remove sonoff-xxl * Remove sonoff-xxl
* Add sonoff-classic, sonoff-allsensors and sonoff-knx * Add sonoff-classic, sonoff-allsensors and sonoff-knx
* Add some coloring to important web buttons * Add some coloring to important web buttons
* Add define MQTT_TELE_RETAIN compile option default set to 0 (#1071)
* Add user selectable defines for Sunrise/set Dawn option (#2378) * Add user selectable defines for Sunrise/set Dawn option (#2378)
* Add random window to timers (#2447) * Add random window to timers (#2447)
* Add optional KNX IP Protocol Support (#2402) * Add optional KNX IP Protocol Support (#2402)

View File

@ -98,7 +98,7 @@ typedef union {
uint32_t days : 7; // bits 16 - 22 = week day mask uint32_t days : 7; // bits 16 - 22 = week day mask
uint32_t device : 4; // bits 23 - 26 = 16 devices uint32_t device : 4; // bits 23 - 26 = 16 devices
uint32_t power : 2; // bits 27 - 28 = 4 power states - Off, On, Toggle, Blink or Rule uint32_t power : 2; // bits 27 - 28 = 4 power states - Off, On, Toggle, Blink or Rule
uint32_t mode : 2; // bits 29 - 30 = timer modes - Scheduler, Sunrise, Sunset uint32_t mode : 2; // bits 29 - 30 = timer modes - 0 = Scheduler, 1 = Sunrise, 2 = Sunset
uint32_t arm : 1; // bit 31 uint32_t arm : 1; // bit 31
}; };
} Timer; } Timer;

View File

@ -1459,10 +1459,10 @@ void PerformEverySecond()
mqtt_data[0] = '\0'; mqtt_data[0] = '\0';
MqttShowState(); MqttShowState();
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_STATE)); MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_STATE), MQTT_TELE_RETAIN);
mqtt_data[0] = '\0'; mqtt_data[0] = '\0';
if (MqttShowSensor()) MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain); if (MqttShowSensor()) { MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain); }
} }
} }

View File

@ -191,6 +191,9 @@
// Alternative MQTT driver does not block network when MQTT server is unavailable. No TLS support // Alternative MQTT driver does not block network when MQTT server is unavailable. No TLS support
//#define MQTT_LIBRARY_TYPE MQTT_ESPMQTTARDUINO // Use (patched) esp-mqtt-arduino library (+4k8 code, +4k mem) - non-TLS only //#define MQTT_LIBRARY_TYPE MQTT_ESPMQTTARDUINO // Use (patched) esp-mqtt-arduino library (+4k8 code, +4k mem) - non-TLS only
// -- MQTT ----------------------------------------
#define MQTT_TELE_RETAIN 0 // Tele messages may send retain flag (0 = off, 1 = on)
// -- MQTT - Domoticz ----------------------------- // -- MQTT - Domoticz -----------------------------
#define USE_DOMOTICZ // Enable Domoticz (+6k code, +0.3k mem) #define USE_DOMOTICZ // Enable Domoticz (+6k code, +0.3k mem)
#define DOMOTICZ_IN_TOPIC "domoticz/in" // Domoticz Input Topic #define DOMOTICZ_IN_TOPIC "domoticz/in" // Domoticz Input Topic

View File

@ -628,7 +628,11 @@ void HandleConfiguration()
page += FPSTR(HTTP_HEAD_STYLE); page += FPSTR(HTTP_HEAD_STYLE);
page += FPSTR(HTTP_BTN_MENU_MODULE); page += FPSTR(HTTP_BTN_MENU_MODULE);
#if defined(USE_TIMERS) && defined(USE_TIMERS_WEB) #if defined(USE_TIMERS) && defined(USE_TIMERS_WEB)
#ifdef USE_RULES
page += FPSTR(HTTP_BTN_MENU_TIMER);
#else
if (devices_present) { page += FPSTR(HTTP_BTN_MENU_TIMER); } if (devices_present) { page += FPSTR(HTTP_BTN_MENU_TIMER); }
#endif // USE_RULES
#endif // USE_TIMERS and USE_TIMERS_WEB #endif // USE_TIMERS and USE_TIMERS_WEB
page += FPSTR(HTTP_BTN_MENU_WIFI); page += FPSTR(HTTP_BTN_MENU_WIFI);
if (Settings.flag.mqtt_enabled) { page += FPSTR(HTTP_BTN_MENU_MQTT); } if (Settings.flag.mqtt_enabled) { page += FPSTR(HTTP_BTN_MENU_MQTT); }

View File

@ -399,6 +399,11 @@ boolean MqttCheckTls()
} }
AddLog_P(LOG_LEVEL_INFO, S_LOG_MQTT, PSTR(D_FINGERPRINT)); AddLog_P(LOG_LEVEL_INFO, S_LOG_MQTT, PSTR(D_FINGERPRINT));
//#ifdef ARDUINO_ESP8266_RELEASE_2_4_1
EspClient = WiFiClientSecure(); // Wifi Secure Client reconnect issue 4497 (https://github.com/esp8266/Arduino/issues/4497)
//#endif
if (!EspClient.connect(Settings.mqtt_host, Settings.mqtt_port)) { if (!EspClient.connect(Settings.mqtt_host, Settings.mqtt_port)) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_TLS_CONNECT_FAILED_TO " %s:%d. " D_RETRY_IN " %d " D_UNIT_SECOND), snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_TLS_CONNECT_FAILED_TO " %s:%d. " D_RETRY_IN " %d " D_UNIT_SECOND),
Settings.mqtt_host, Settings.mqtt_port, mqtt_retry_counter); Settings.mqtt_host, Settings.mqtt_port, mqtt_retry_counter);
@ -479,6 +484,14 @@ void MqttReconnect()
mqtt_initial_connection_state = 1; mqtt_initial_connection_state = 1;
} }
//#ifdef ARDUINO_ESP8266_RELEASE_2_4_1
#ifdef USE_MQTT_TLS
EspClient = WiFiClientSecure(); // Wifi Secure Client reconnect issue 4497 (https://github.com/esp8266/Arduino/issues/4497)
#else
EspClient = WiFiClient(); // Wifi Client reconnect issue 4497 (https://github.com/esp8266/Arduino/issues/4497)
#endif
//#endif
#if (MQTT_LIBRARY_TYPE == MQTT_PUBSUBCLIENT) #if (MQTT_LIBRARY_TYPE == MQTT_PUBSUBCLIENT)
MqttClient.setCallback(MqttDataHandler); MqttClient.setCallback(MqttDataHandler);
MqttClient.setServer(Settings.mqtt_host, Settings.mqtt_port); MqttClient.setServer(Settings.mqtt_host, Settings.mqtt_port);

View File

@ -22,7 +22,7 @@
* Timers * Timers
* *
* Arm a timer using one or all of the following JSON values: * Arm a timer using one or all of the following JSON values:
* {"Arm":1,"Mode":0,"Time":"09:23","Days":"--TW--S","Repeat":1,"Output":1,"Action":1} * {"Arm":1,"Mode":0,"Time":"09:23","Window":0,"Days":"--TW--S","Repeat":1,"Output":1,"Action":1}
* *
* Arm 0 = Off, 1 = On * Arm 0 = Off, 1 = On
* Mode 0 = Schedule, 1 = Sunrise, 2 = Sunset * Mode 0 = Schedule, 1 = Sunrise, 2 = Sunset
@ -268,7 +268,7 @@ void TimerEverySecond()
uint8_t days = 1 << (RtcTime.day_of_week -1); uint8_t days = 1 << (RtcTime.day_of_week -1);
for (byte i = 0; i < MAX_TIMERS; i++) { for (byte i = 0; i < MAX_TIMERS; i++) {
if (Settings.timer[i].device >= devices_present) Settings.timer[i].data = 0; // Reset timer due to change in devices present // if (Settings.timer[i].device >= devices_present) Settings.timer[i].data = 0; // Reset timer due to change in devices present
Timer xtimer = Settings.timer[i]; Timer xtimer = Settings.timer[i];
uint16_t set_time = xtimer.time; uint16_t set_time = xtimer.time;
#ifdef USE_SUNRISE #ifdef USE_SUNRISE
@ -290,7 +290,7 @@ void TimerEverySecond()
RulesProcess(); RulesProcess();
} else } else
#endif // USE_RULES #endif // USE_RULES
ExecuteCommandPower(xtimer.device +1, xtimer.power); if (devices_present) { ExecuteCommandPower(xtimer.device +1, xtimer.power); }
} }
} }
} }
@ -302,6 +302,7 @@ void TimerEverySecond()
void PrepShowTimer(uint8_t index) void PrepShowTimer(uint8_t index)
{ {
char days[8] = { 0 }; char days[8] = { 0 };
char soutput[80];
Timer xtimer = Settings.timer[index -1]; Timer xtimer = Settings.timer[index -1];
@ -309,16 +310,21 @@ void PrepShowTimer(uint8_t index)
uint8_t mask = 1 << i; uint8_t mask = 1 << i;
snprintf(days, sizeof(days), "%s%d", days, ((xtimer.days & mask) > 0)); snprintf(days, sizeof(days), "%s%d", days, ((xtimer.days & mask) > 0));
} }
soutput[0] = '\0';
if (devices_present) {
snprintf_P(soutput, sizeof(soutput), PSTR(",\"" D_JSON_TIMER_OUTPUT "\":%d"), xtimer.device +1);
}
#ifdef USE_SUNRISE #ifdef USE_SUNRISE
int16_t hour = xtimer.time / 60; int16_t hour = xtimer.time / 60;
if ((1 == xtimer.mode) || (2 == xtimer.mode)) { // Sunrise or Sunset if ((1 == xtimer.mode) || (2 == xtimer.mode)) { // Sunrise or Sunset
if (hour > 11) { hour = (hour -12) * -1; } if (hour > 11) { hour = (hour -12) * -1; }
} }
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_WINDOW "\":%d,\"" D_JSON_TIMER_DAYS "\":\"%s\",\"" D_JSON_TIMER_REPEAT "\":%d,\"" D_JSON_TIMER_OUTPUT "\":%d,\"" D_JSON_TIMER_ACTION "\":%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_WINDOW "\":%d,\"" D_JSON_TIMER_DAYS "\":\"%s\",\"" D_JSON_TIMER_REPEAT "\":%d%s,\"" D_JSON_TIMER_ACTION "\":%d}"),
mqtt_data, index, xtimer.arm, xtimer.mode, hour, xtimer.time % 60, xtimer.window, days, xtimer.repeat, xtimer.device +1, xtimer.power); mqtt_data, index, xtimer.arm, xtimer.mode, hour, xtimer.time % 60, xtimer.window, days, xtimer.repeat, soutput, xtimer.power);
#else #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_WINDOW "\":%d,\"" D_JSON_TIMER_DAYS "\":\"%s\",\"" D_JSON_TIMER_REPEAT "\":%d,\"" D_JSON_TIMER_OUTPUT "\":%d,\"" D_JSON_TIMER_ACTION "\":%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_WINDOW "\":%d,\"" D_JSON_TIMER_DAYS "\":\"%s\",\"" D_JSON_TIMER_REPEAT "\":%d%s,\"" D_JSON_TIMER_ACTION "\":%d}"),
mqtt_data, index, xtimer.arm, xtimer.time / 60, xtimer.time % 60, xtimer.window, days, xtimer.repeat, xtimer.device +1, xtimer.power); mqtt_data, index, xtimer.arm, xtimer.time / 60, xtimer.time % 60, xtimer.window, days, xtimer.repeat, soutput, xtimer.power);
#endif // USE_SUNRISE #endif // USE_SUNRISE
} }
@ -345,7 +351,9 @@ 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 {
#ifndef USE_RULES
if (devices_present) { if (devices_present) {
#endif
StaticJsonBuffer<200> jsonBuffer; StaticJsonBuffer<200> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(dataBufUc); JsonObject& root = jsonBuffer.parseObject(dataBufUc);
if (!root.success()) { if (!root.success()) {
@ -408,18 +416,21 @@ boolean TimerCommand()
} }
if (root[UpperCase_P(parm_uc, PSTR(D_JSON_TIMER_OUTPUT))].success()) { if (root[UpperCase_P(parm_uc, PSTR(D_JSON_TIMER_OUTPUT))].success()) {
uint8_t device = ((uint8_t)root[parm_uc] -1) & 0x0F; uint8_t device = ((uint8_t)root[parm_uc] -1) & 0x0F;
Settings.timer[index].device = (device < devices_present) ? device : devices_present -1; Settings.timer[index].device = (device < devices_present) ? device : 0;
} }
if (root[UpperCase_P(parm_uc, PSTR(D_JSON_TIMER_ACTION))].success()) { if (root[UpperCase_P(parm_uc, PSTR(D_JSON_TIMER_ACTION))].success()) {
Settings.timer[index].power = (uint8_t)root[parm_uc] & 0x03; uint8_t action = ((uint8_t)root[parm_uc] -1) & 0x03;
Settings.timer[index].power = (devices_present) ? action : 3; // If no devices than only allow rules
} }
index++; index++;
} }
#ifndef USE_RULES
} else { } 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 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; error = 1;
} }
#endif
} }
} }
if (!error) { if (!error) {
@ -527,8 +538,12 @@ const char HTTP_TIMER_SCRIPT[] PROGMEM =
"m=qs('input[name=\"rd\"]:checked').value;" // Check mode "m=qs('input[name=\"rd\"]:checked').value;" // Check mode
"s|=(qs('input[name=\"rd\"]:checked').value<<29);" // Get mode "s|=(qs('input[name=\"rd\"]:checked').value<<29);" // Get mode
#endif #endif
"s|=(eb('p1').value<<27);" // Get power "if(}1>0){"
"s|=(qs('#d1').selectedIndex<<23);" // Get device "i=qs('#d1').selectedIndex;if(i>=0){s|=(i<<23);}" // Get output
"s|=(qs('#p1').selectedIndex<<27);" // Get action
"}else{"
"s|=3<<27;" // Get action (rule)
"}"
"l=((qs('#ho').selectedIndex*60)+qs('#mi').selectedIndex)&0x7FF;" "l=((qs('#ho').selectedIndex*60)+qs('#mi').selectedIndex)&0x7FF;"
"if(m==0){s|=l;}" // Get time "if(m==0){s|=l;}" // Get time
#ifdef USE_SUNRISE #ifdef USE_SUNRISE
@ -559,8 +574,10 @@ const char HTTP_TIMER_SCRIPT[] PROGMEM =
#endif #endif
"q=(s>>11)&0xF;if(q<10){q='0'+q;}qs('#mw').value=q;" // Set window minutes "q=(s>>11)&0xF;if(q<10){q='0'+q;}qs('#mw').value=q;" // Set window minutes
"for(i=0;i<7;i++){p=(s>>(16+i))&1;eb('w'+i).checked=p;}" // Set weekdays "for(i=0;i<7;i++){p=(s>>(16+i))&1;eb('w'+i).checked=p;}" // Set weekdays
"p=(s>>23)&0xF;qs('#d1').value=p+1;" // Set device "if(}1>0){"
"p=(s>>27)&3;eb('p1').value=p;" // Set power "p=(s>>23)&0xF;qs('#d1').value=p+1;" // Set output
"p=(s>>27)&3;qs('#p1').selectedIndex=p;" // Set action
"}"
"p=(s>>15)&1;eb('r0').checked=p;" // Set repeat "p=(s>>15)&1;eb('r0').checked=p;" // Set repeat
"p=(s>>31)&1;eb('a0').checked=p;" // Set arm "p=(s>>31)&1;eb('a0').checked=p;" // Set arm
"}" "}"
@ -569,13 +586,24 @@ const char HTTP_TIMER_SCRIPT[] PROGMEM =
"pt=eb('t0').value.split(',').map(Number);" // Get parameters from hidden area to array "pt=eb('t0').value.split(',').map(Number);" // Get parameters from hidden area to array
"s='';for(i=0;i<" STR(MAX_TIMERS) ";i++){b='';if(0==i){b=\" id='dP'\";}s+=\"<button type='button' class='tl' onclick='ot(\"+i+\",this)'\"+b+\">\"+(i+1)+\"</button>\"}" "s='';for(i=0;i<" STR(MAX_TIMERS) ";i++){b='';if(0==i){b=\" id='dP'\";}s+=\"<button type='button' class='tl' onclick='ot(\"+i+\",this)'\"+b+\">\"+(i+1)+\"</button>\"}"
"eb('bt').innerHTML=s;" // Create tabs "eb('bt').innerHTML=s;" // Create tabs
"if(}1>0){" // Create Output and Action drop down boxes
"eb('oa').innerHTML=\"<b>" D_TIMER_OUTPUT "</b>&nbsp;<span><select style='width:60px;' id='d1' name='d1'></select></span>&emsp;<b>" D_TIMER_ACTION "</b>&nbsp;<select style='width:99px;' id='p1' name='p1'></select>\";"
"o=qs('#p1');ce('" D_OFF "',o);ce('" D_ON "',o);ce('" D_TOGGLE "',o);" // Create offset direction select options
#ifdef USE_RULES
"ce('" D_RULE "',o);"
#else
"ce('" D_BLINK "',o);"
#endif
"}else{"
"eb('oa').innerHTML=\"<b>" D_TIMER_ACTION "</b> " D_RULE "\";" // No outputs but rule is allowed
"}"
#ifdef USE_SUNRISE #ifdef USE_SUNRISE
"o=qs('#dr');ce('+',o);ce('-',o);" // Create offset direction select options "o=qs('#dr');ce('+',o);ce('-',o);" // Create offset direction select options
#endif #endif
"o=qs('#ho');for(i=0;i<=23;i++){ce((i<10)?('0'+i):i,o);}" // Create hours select options "o=qs('#ho');for(i=0;i<=23;i++){ce((i<10)?('0'+i):i,o);}" // Create hours select options
"o=qs('#mi');for(i=0;i<=59;i++){ce((i<10)?('0'+i):i,o);}" // Create minutes select options "o=qs('#mi');for(i=0;i<=59;i++){ce((i<10)?('0'+i):i,o);}" // Create minutes select options
"o=qs('#mw');for(i=0;i<=15;i++){ce((i<10)?('0'+i):i,o);}" // Create window minutes select options "o=qs('#mw');for(i=0;i<=15;i++){ce((i<10)?('0'+i):i,o);}" // Create window minutes select options
"o=qs('#d1');for(i=0;i<}1;i++){ce(i+1,o);}" // Create devices "o=qs('#d1');for(i=0;i<}1;i++){ce(i+1,o);}" // Create outputs
"var a='" D_DAY3LIST "';" "var a='" D_DAY3LIST "';"
"s='';for(i=0;i<7;i++){s+=\"<input style='width:5%;' id='w\"+i+\"' name='w\"+i+\"' type='checkbox'><b>\"+a.substring(i*3,(i*3)+3)+\"</b>\"}" "s='';for(i=0;i<7;i++){s+=\"<input style='width:5%;' id='w\"+i+\"' name='w\"+i+\"' type='checkbox'><b>\"+a.substring(i*3,(i*3)+3)+\"</b>\"}"
"eb('ds').innerHTML=s;" // Create weekdays "eb('ds').innerHTML=s;" // Create weekdays
@ -592,19 +620,7 @@ const char HTTP_FORM_TIMER[] PROGMEM =
"<input id='w' name='w' value='7,0' hidden><input id='t0' name='t0' value='"; "<input id='w' name='w' value='7,0' hidden><input id='t0' name='t0' value='";
const char HTTP_FORM_TIMER1[] PROGMEM = const char HTTP_FORM_TIMER1[] PROGMEM =
"' hidden><div id='bt' name='bt'></div><br/><br/><br/>" "' hidden><div id='bt' name='bt'></div><br/><br/><br/>"
"<div>" "<div id='oa' name='oa'></div><br/>"
"<b>" D_TIMER_OUTPUT "</b>&nbsp;<span><select style='width:60px;' id='d1' name='d1'></select></span>&emsp;"
"<b>" D_TIMER_ACTION "</b>&nbsp;<select style='width:99px;' id='p1' name='p1'>"
"<option value='0'>" D_OFF "</option>"
"<option value='1'>" D_ON "</option>"
"<option value='2'>" D_TOGGLE "</option>"
#ifdef USE_RULES
"<option value='3'>" D_RULE "</option>"
#else
"<option value='3'>" D_BLINK "</option>"
#endif
"</select>"
"</div><br/>"
"<div>" "<div>"
"<input style='width:5%;' id='a0' name='a0' type='checkbox'><b>" D_TIMER_ARM "</b>&emsp;" "<input style='width:5%;' id='a0' name='a0' type='checkbox'><b>" D_TIMER_ARM "</b>&emsp;"
"<input style='width:5%;' id='r0' name='r0' type='checkbox'><b>" D_TIMER_REPEAT "</b>" "<input style='width:5%;' id='r0' name='r0' type='checkbox'><b>" D_TIMER_REPEAT "</b>"

View File

@ -63,7 +63,9 @@
#define MAX_RULE_TIMERS 8 #define MAX_RULE_TIMERS 8
#ifndef ULONG_MAX
#define ULONG_MAX 0xffffffffUL #define ULONG_MAX 0xffffffffUL
#endif
#define D_CMND_RULE "Rule" #define D_CMND_RULE "Rule"
#define D_CMND_RULETIMER "RuleTimer" #define D_CMND_RULETIMER "RuleTimer"