mirror of https://github.com/arendst/Tasmota.git
commit
82f372350c
33
README.md
33
README.md
|
@ -15,7 +15,7 @@ If you like **Sonoff-Tasmota**, give it a star, or fork it and contribute!
|
||||||
### Development
|
### Development
|
||||||
[![Build Status](https://img.shields.io/travis/arendst/Sonoff-Tasmota.svg)](https://travis-ci.org/arendst/Sonoff-Tasmota)
|
[![Build Status](https://img.shields.io/travis/arendst/Sonoff-Tasmota.svg)](https://travis-ci.org/arendst/Sonoff-Tasmota)
|
||||||
|
|
||||||
Current version is **6.0.0c** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
Current version is **6.1.0a** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
||||||
|
|
||||||
### Disclaimer
|
### Disclaimer
|
||||||
:warning: **DANGER OF ELECTROCUTION** :warning:
|
:warning: **DANGER OF ELECTROCUTION** :warning:
|
||||||
|
@ -39,7 +39,7 @@ If you want to compile Sonoff-Tasmota yourself keep in mind the following:
|
||||||
- Once uploaded select module using the configuration webpage or the commands ```Modules``` and ```Module```.
|
- Once uploaded select module using the configuration webpage or the commands ```Modules``` and ```Module```.
|
||||||
- After reboot select config menu again or use commands ```GPIOs``` and ```GPIO``` to change GPIO with desired sensor.
|
- After reboot select config menu again or use commands ```GPIOs``` and ```GPIO``` to change GPIO with desired sensor.
|
||||||
|
|
||||||
### Migration Instructions
|
### Migration Information
|
||||||
See [wiki migration path](https://github.com/arendst/Sonoff-Tasmota/wiki/Upgrade#migration-path) for instructions how to migrate to a major version. Pay attention to the following version breaks due to dynamic settings updates:
|
See [wiki migration path](https://github.com/arendst/Sonoff-Tasmota/wiki/Upgrade#migration-path) for instructions how to migrate to a major version. Pay attention to the following version breaks due to dynamic settings updates:
|
||||||
|
|
||||||
1. Migrate to **Sonoff-Tasmota 3.9.x**
|
1. Migrate to **Sonoff-Tasmota 3.9.x**
|
||||||
|
@ -134,34 +134,34 @@ Different firmware images are released based on Features and Sensors selection g
|
||||||
| USE_ADS1115 | - | - | - | - | x |
|
| USE_ADS1115 | - | - | - | - | x |
|
||||||
| USE_ADS1115_I2CDEV | - | - | - | - | - |
|
| USE_ADS1115_I2CDEV | - | - | - | - | - |
|
||||||
| USE_INA219 | - | - | - | - | x |
|
| USE_INA219 | - | - | - | - | x |
|
||||||
| USE_APDS9960 | - | - | - | - | - |
|
|
||||||
| USE_MGS | - | - | - | - | x |
|
| USE_MGS | - | - | - | - | x |
|
||||||
| USE_SPI | - | - | - | - | - |
|
| USE_SPI | - | - | - | - | - |
|
||||||
| USE_MHZ19 | x | x | - | x | x |
|
| USE_MHZ19 | x | x | - | x | x |
|
||||||
| USE_SENSEAIR | x | x | - | x | x |
|
| USE_SENSEAIR | x | - | - | x | x |
|
||||||
| USE_PMS5003 | x | x | - | x | x |
|
| USE_PMS5003 | x | - | - | x | x |
|
||||||
| USE_NOVA_SDS | x | - | - | x | x |
|
| USE_NOVA_SDS | x | - | - | x | x |
|
||||||
| USE_PZEM004T | x | x | - | x | x |
|
| USE_PZEM004T | x | - | - | x | x |
|
||||||
| USE_SERIAL_BRIDGE | x | - | - | x | x |
|
| USE_SERIAL_BRIDGE | x | - | - | x | x |
|
||||||
| USE_SDM120 | x | - | - | - | x |
|
| USE_SDM120 | - | - | - | - | x |
|
||||||
| USE_SDM630 | x | - | - | - | x |
|
| USE_SDM630 | - | - | - | - | x |
|
||||||
| USE_IR_REMOTE | x | x | - | x | x |
|
| USE_IR_REMOTE | x | x | - | x | x |
|
||||||
| USE_IR_HVAC | - | - | - | - | x |
|
| USE_IR_HVAC | - | - | - | - | x |
|
||||||
| USE_IR_RECEIVE | x | - | - | x | x |
|
| USE_IR_RECEIVE | x | - | - | x | x |
|
||||||
| USE_WS2812 | x | x | - | x | x |
|
| USE_WS2812 | x | x | - | x | x |
|
||||||
| USE_WS2812_DMA | - | - | - | - | - |
|
| USE_WS2812_DMA | - | - | - | - | - |
|
||||||
| USE_ARILUX_RF | x | x | - | x | x |
|
| USE_ARILUX_RF | x | - | - | x | x |
|
||||||
| USE_SR04 | x | - | - | x | x |
|
| USE_SR04 | x | - | - | x | x |
|
||||||
| USE_TM1638 | - | - | - | - | - |
|
|
||||||
| USE_RF_FLASH | x | - | - | x | x |
|
| USE_RF_FLASH | x | - | - | x | x |
|
||||||
|
|
||||||
#### Typical File Size
|
#### Typical file size
|
||||||
|
|
||||||
| ESP/Arduino library version | sonoff | classic | minimal | knx | allsensors |
|
| ESP/Arduino library version | sonoff | classic | minimal | knx | allsensors |
|
||||||
|-----------------------------|--------|---------|---------|------|------------|
|
|-----------------------------|--------|---------|---------|------|------------|
|
||||||
| ESP/Arduino lib v2.3.0 | 529k | 490k | 429k | 538k | 554k |
|
| ESP/Arduino lib v2.3.0 | 538k | 490k | 399k | 548k | 562k |
|
||||||
| ESP/Arduino lib v2.4.0 | 534k | 498k | 436k | 542k | 558k |
|
| ESP/Arduino lib v2.4.0 | 543k | 498k | 406k | 553k | 565k |
|
||||||
| ESP/Arduino lib v2.4.1 | 536k | 501k | 439k | 545k | 560k |
|
| ESP/Arduino lib v2.4.1 | 544k | 500k | 408k | 555k | 567k |
|
||||||
|
|
||||||
|
See [Tasmota ESP/Arduino library version related issues](https://github.com/arendst/Sonoff-Tasmota/wiki/Theo's-Tasmota-Tips#20180523---relation-tasmota-and-esp8266arduino-core-version) for more information.
|
||||||
|
|
||||||
### Contribute
|
### Contribute
|
||||||
You can contribute to Sonoff-Tasmota by
|
You can contribute to Sonoff-Tasmota by
|
||||||
|
@ -176,13 +176,14 @@ You can contribute to Sonoff-Tasmota by
|
||||||
#### Libraries Used
|
#### Libraries Used
|
||||||
Libraries used with Sonoff-Tasmota are:
|
Libraries used with Sonoff-Tasmota are:
|
||||||
- [ESP8266 core for Arduino](https://github.com/esp8266/Arduino)
|
- [ESP8266 core for Arduino](https://github.com/esp8266/Arduino)
|
||||||
- [Adafruit BME680](https://github.com/adafruit/Adafruit_BME680)
|
|
||||||
- [Adafruit Sensor](https://github.com/adafruit/Adafruit_Sensor)
|
|
||||||
- [Adafruit SGP30](https://github.com/adafruit/Adafruit_SGP30)
|
- [Adafruit SGP30](https://github.com/adafruit/Adafruit_SGP30)
|
||||||
- [ArduinoJson](https://arduinojson.org/)
|
- [ArduinoJson](https://arduinojson.org/)
|
||||||
|
- [Bosch BME680](https://github.com/BoschSensortec/BME680_driver)
|
||||||
|
- [C2 Programmer](http://app.cear.ufpb.br/~lucas.hartmann/tag/efm8bb1/)
|
||||||
- [Esp8266MqttClient](https://github.com/tuanpmt/ESP8266MQTTClient)
|
- [Esp8266MqttClient](https://github.com/tuanpmt/ESP8266MQTTClient)
|
||||||
- [esp-knx-ip](https://github.com/envy/esp-knx-ip)
|
- [esp-knx-ip](https://github.com/envy/esp-knx-ip)
|
||||||
- [esp-mqtt-arduino](https://github.com/i-n-g-o/esp-mqtt-arduino)
|
- [esp-mqtt-arduino](https://github.com/i-n-g-o/esp-mqtt-arduino)
|
||||||
|
- [ESPAsyncUDP](https://github.com/me-no-dev/ESPAsyncUDP)
|
||||||
- [I2Cdevlib](https://github.com/jrowberg/i2cdevlib)
|
- [I2Cdevlib](https://github.com/jrowberg/i2cdevlib)
|
||||||
- [IRremoteEsp8266](https://github.com/markszabo/IRremoteESP8266)
|
- [IRremoteEsp8266](https://github.com/markszabo/IRremoteESP8266)
|
||||||
- [JobaTsl2561](https://github.com/joba-1/Joba_Tsl2561)
|
- [JobaTsl2561](https://github.com/joba-1/Joba_Tsl2561)
|
||||||
|
|
|
@ -39,7 +39,7 @@ platform = espressif8266@1.5.0
|
||||||
; *** Esp8266 core for Arduino version 2.4.0
|
; *** Esp8266 core for Arduino version 2.4.0
|
||||||
;platform = espressif8266@1.6.0
|
;platform = espressif8266@1.6.0
|
||||||
; *** Esp8266 core for Arduino version 2.4.1
|
; *** Esp8266 core for Arduino version 2.4.1
|
||||||
;platform = espressif8266@1.7.0
|
;platform = espressif8266@1.7.3
|
||||||
; *** Esp8266 core for Arduino version latest beta
|
; *** Esp8266 core for Arduino version latest beta
|
||||||
;platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
|
;platform = https://github.com/platformio/platform-espressif8266.git#feature/stage
|
||||||
; *** Esp8266 core for Arduino current version
|
; *** Esp8266 core for Arduino current version
|
||||||
|
@ -62,8 +62,7 @@ build_flags =
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
; *** Upload Serial reset method for Wemos and NodeMCU
|
; *** Upload Serial reset method for Wemos and NodeMCU
|
||||||
;upload_speed = 115200
|
upload_speed = 115200
|
||||||
upload_speed = 512000
|
|
||||||
upload_resetmethod = nodemcu
|
upload_resetmethod = nodemcu
|
||||||
upload_port = COM5
|
upload_port = COM5
|
||||||
; *** Fix Esp/Arduino core 2.4.x induced Tasmota unused floating point includes
|
; *** Fix Esp/Arduino core 2.4.x induced Tasmota unused floating point includes
|
||||||
|
|
|
@ -1,38 +1,37 @@
|
||||||
/* 6.0.0c
|
/* 6.1.0a
|
||||||
* Rewrite BME680 driver now using latest Bosch BME680 library (#2969)
|
|
||||||
* Add support for bitflags SetOption50 .. SetOption81 (#3118)
|
|
||||||
*
|
|
||||||
* 6.0.0b
|
|
||||||
* Add support for BlitzWolf BW-SHP2 (and Homecube, Gosund SP1) Energy Monitoring Smart Socket (#2223)
|
|
||||||
* Add support for Sonoff iFan02 as module 44 introducing command FanSpeed 0..3 (#2839)
|
|
||||||
* Add support for Sonoff S26 Smart Socket (#2808)
|
|
||||||
* Add command SetOption30 to enforce Hass discovery as light group (#1784)
|
|
||||||
* Add decimal values support for commands ADD, SUB, MULT and SCALE (#3083, #3089)
|
|
||||||
* Add experimental (untested) TM1638 switch support (#2226)
|
* Add experimental (untested) TM1638 switch support (#2226)
|
||||||
* Change number of switches from 4 to 8 (#2885, #3086)
|
|
||||||
*
|
|
||||||
* 6.0.0a
|
|
||||||
* Add support for APDS9960 proximity sensor (#3051)
|
* Add support for APDS9960 proximity sensor (#3051)
|
||||||
* Add increment and decrement value to command Counter (#2838)
|
|
||||||
* Add option 0 to command Timers disarming all timers (#2962)
|
|
||||||
* Add time in minutes to rule Time#Initialized, Time#set and Time#Minute (#2669)
|
|
||||||
* Add rule variables %time% for minutes since midnight, %uptime%, %sunrise% and %sunset% giving time in minutes (#2669)
|
|
||||||
* Add heap and stack debug information
|
* Add heap and stack debug information
|
||||||
* Add command SetOption28 to switch between hex or decimal Sonoff Bridge RF received data format (#3008)
|
|
||||||
* Add command SetOption29 to switch between hex or decimal IR received data format
|
|
||||||
* Add performance improvement when updating multiple individual WS2812 pixels (#3007)
|
|
||||||
* Add debug facilities using optional xdrv_99_debug.ino to enable in user_config.h
|
* Add debug facilities using optional xdrv_99_debug.ino to enable in user_config.h
|
||||||
* Add KNX support for DS18S20 Temperature sensor
|
*
|
||||||
* Add CRC to Settings making future upgrades more fail-safe
|
* 6.1.0 20180706
|
||||||
* Add support for uploading Sonoff Bridge firmware found in tools/fw_efm8bb1 folder build by Portisch using Web Gui File Upload (#2886)
|
|
||||||
* Add support for I2C temperature sensor LM75AD (#2909)
|
|
||||||
* Add command RfRaw to control Portisch firmware features
|
|
||||||
* Remove version 3, 4 and pre 5.2 settings auto-upgrade. See https://github.com/arendst/Sonoff-Tasmota/wiki/Upgrade#migration-path
|
* Remove version 3, 4 and pre 5.2 settings auto-upgrade. See https://github.com/arendst/Sonoff-Tasmota/wiki/Upgrade#migration-path
|
||||||
* Change default CFG_HOLDER from 0x20161209 to 4617 (=0x1209) - no impact on default upgrades
|
* Change default CFG_HOLDER from 0x20161209 to 4617 (=0x1209) - no impact on default upgrades
|
||||||
|
* Change number of supported switches from 4 to 8 (#2885, #3086)
|
||||||
|
* Change BME680 driver from Adafruit to Bosch BME680 library (#2969)
|
||||||
* Fix Pzem004T checksum error
|
* Fix Pzem004T checksum error
|
||||||
* Fix KNX bug when doing reply of sensors values
|
* Fix KNX bug when doing reply of sensors values
|
||||||
* Fix rules induced LWT message
|
* Fix rules induced LWT message
|
||||||
* Fix possible wifi connection problem (#1366)
|
* Fix possible wifi connection problem (#1366)
|
||||||
|
* Add Ukrainian language file
|
||||||
|
* Add KNX support for DS18S20 Temperature sensor
|
||||||
|
* Add CRC to Settings making future upgrades more fail-safe
|
||||||
|
* Add command SetOption30 to enforce Hass discovery as light group (#1784)
|
||||||
|
* Add support for BlitzWolf BW-SHP2 (and Homecube, Gosund SP1) Energy Monitoring Smart Socket (#2223)
|
||||||
|
* Add time in minutes to rule Time#Initialized, Time#set and Time#Minute (#2669)
|
||||||
|
* Add rule variables %time% for minutes since midnight, %uptime%, %sunrise% and %sunset% giving time in minutes (#2669)
|
||||||
|
* Add support for Sonoff S26 Smart Socket (#2808)
|
||||||
|
* Add increment and decrement value to command Counter (#2838)
|
||||||
|
* Add support for Sonoff iFan02 as module 44 introducing command FanSpeed 0..3 (#2839)
|
||||||
|
* Add support for uploading Sonoff Bridge firmware found in tools/fw_efm8bb1 folder build by Portisch using Web Gui File Upload (#2886)
|
||||||
|
* Add command RfRaw to control Portisch firmware features
|
||||||
|
* Add support for I2C temperature sensor LM75AD (#2909)
|
||||||
|
* Add option 0 to command Timers disarming all timers (#2962)
|
||||||
|
* Add performance improvement when updating multiple individual WS2812 pixels (#3007)
|
||||||
|
* Add command SetOption28 to switch between hex or decimal Sonoff Bridge RF received data format (#3008)
|
||||||
|
* Add command SetOption29 to switch between hex or decimal IR received data format
|
||||||
|
* Add decimal values support for commands ADD, SUB, MULT and SCALE (#3083, #3089)
|
||||||
|
* Add support for bitflags SetOption50 .. SetOption81 (#3118)
|
||||||
*
|
*
|
||||||
* 5.14.0b
|
* 5.14.0b
|
||||||
* Add Console Commands to send KNX Commands
|
* Add Console Commands to send KNX Commands
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
||||||
====================================================*/
|
====================================================*/
|
||||||
|
|
||||||
#define VERSION 0x06000003 // 6.0.0c
|
#define VERSION 0x06010001 // 6.1.0a
|
||||||
|
|
||||||
// Location specific includes
|
// Location specific includes
|
||||||
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)
|
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)
|
||||||
|
@ -75,6 +75,12 @@
|
||||||
// Structs
|
// Structs
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
#ifdef BE_MINIMAL
|
||||||
|
enum TasmotaCommands {
|
||||||
|
CMND_POWER, CMND_FANSPEED, CMND_STATUS, CMND_STATE, CMND_SLEEP, CMND_UPGRADE, CMND_UPLOAD, CMND_OTAURL, CMND_SERIALLOG, CMND_RESTART };
|
||||||
|
const char kTasmotaCommands[] PROGMEM =
|
||||||
|
D_CMND_POWER "|" D_CMND_FANSPEED "|" D_CMND_STATUS "|" D_CMND_STATE "|" D_CMND_SLEEP "|" D_CMND_UPGRADE "|" D_CMND_UPLOAD "|" D_CMND_OTAURL "|" D_CMND_SERIALLOG "|" D_CMND_RESTART;
|
||||||
|
#else
|
||||||
enum TasmotaCommands {
|
enum TasmotaCommands {
|
||||||
CMND_BACKLOG, CMND_DELAY, CMND_POWER, CMND_FANSPEED, CMND_STATUS, CMND_STATE, CMND_POWERONSTATE, CMND_PULSETIME,
|
CMND_BACKLOG, CMND_DELAY, CMND_POWER, CMND_FANSPEED, CMND_STATUS, CMND_STATE, CMND_POWERONSTATE, CMND_PULSETIME,
|
||||||
CMND_BLINKTIME, CMND_BLINKCOUNT, CMND_SENSOR, CMND_SAVEDATA, CMND_SETOPTION, CMND_TEMPERATURE_RESOLUTION, CMND_HUMIDITY_RESOLUTION,
|
CMND_BLINKTIME, CMND_BLINKCOUNT, CMND_SENSOR, CMND_SAVEDATA, CMND_SETOPTION, CMND_TEMPERATURE_RESOLUTION, CMND_HUMIDITY_RESOLUTION,
|
||||||
|
@ -95,6 +101,7 @@ const char kTasmotaCommands[] PROGMEM =
|
||||||
D_CMND_WIFICONFIG "|" D_CMND_FRIENDLYNAME "|" D_CMND_SWITCHMODE "|"
|
D_CMND_WIFICONFIG "|" D_CMND_FRIENDLYNAME "|" D_CMND_SWITCHMODE "|"
|
||||||
D_CMND_TELEPERIOD "|" D_CMND_RESTART "|" D_CMND_RESET "|" D_CMND_TIMEZONE "|" D_CMND_TIMESTD "|" D_CMND_TIMEDST "|" D_CMND_ALTITUDE "|" D_CMND_LEDPOWER "|" D_CMND_LEDSTATE "|"
|
D_CMND_TELEPERIOD "|" D_CMND_RESTART "|" D_CMND_RESET "|" D_CMND_TIMEZONE "|" D_CMND_TIMESTD "|" D_CMND_TIMEDST "|" D_CMND_ALTITUDE "|" D_CMND_LEDPOWER "|" D_CMND_LEDSTATE "|"
|
||||||
D_CMND_I2CSCAN "|" D_CMND_SERIALSEND "|" D_CMND_BAUDRATE "|" D_CMND_SERIALDELIMITER;
|
D_CMND_I2CSCAN "|" D_CMND_SERIALSEND "|" D_CMND_BAUDRATE "|" D_CMND_SERIALDELIMITER;
|
||||||
|
#endif
|
||||||
|
|
||||||
const uint8_t kIFan02Speed[4][3] = {{6,6,6}, {7,6,6}, {7,7,6}, {7,6,7}};
|
const uint8_t kIFan02Speed[4][3] = {{6,6,6}, {7,6,6}, {7,7,6}, {7,6,7}};
|
||||||
|
|
||||||
|
@ -480,6 +487,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||||
type = NULL; // Unknown command
|
type = NULL; // Unknown command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef BE_MINIMAL
|
||||||
else if (CMND_BACKLOG == command_code) {
|
else if (CMND_BACKLOG == command_code) {
|
||||||
if (data_len) {
|
if (data_len) {
|
||||||
uint8_t bl_pointer = (!backlog_pointer) ? MAX_BACKLOG -1 : backlog_pointer;
|
uint8_t bl_pointer = (!backlog_pointer) ? MAX_BACKLOG -1 : backlog_pointer;
|
||||||
|
@ -513,6 +521,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||||
if ((payload >= MIN_BACKLOG_DELAY) && (payload <= 3600)) backlog_delay = payload;
|
if ((payload >= MIN_BACKLOG_DELAY) && (payload <= 3600)) backlog_delay = payload;
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, command, backlog_delay);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, command, backlog_delay);
|
||||||
}
|
}
|
||||||
|
#endif // Not BE_MINIMAL
|
||||||
else if ((CMND_POWER == command_code) && (index > 0) && (index <= devices_present)) {
|
else if ((CMND_POWER == command_code) && (index > 0) && (index <= devices_present)) {
|
||||||
if ((payload < 0) || (payload > 4)) payload = 9;
|
if ((payload < 0) || (payload > 4)) payload = 9;
|
||||||
// Settings.flag.device_index_enable = user_append_index;
|
// Settings.flag.device_index_enable = user_append_index;
|
||||||
|
@ -540,6 +549,54 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||||
mqtt_data[0] = '\0';
|
mqtt_data[0] = '\0';
|
||||||
MqttShowState();
|
MqttShowState();
|
||||||
}
|
}
|
||||||
|
else if (CMND_SLEEP == command_code) {
|
||||||
|
if ((payload >= 0) && (payload < 251)) {
|
||||||
|
if ((!Settings.sleep && payload) || (Settings.sleep && !payload)) restart_flag = 2;
|
||||||
|
Settings.sleep = payload;
|
||||||
|
sleep = payload;
|
||||||
|
}
|
||||||
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE_UNIT_NVALUE_UNIT, command, sleep, (Settings.flag.value_units) ? " " D_UNIT_MILLISECOND : "", Settings.sleep, (Settings.flag.value_units) ? " " D_UNIT_MILLISECOND : "");
|
||||||
|
}
|
||||||
|
else if ((CMND_UPGRADE == command_code) || (CMND_UPLOAD == command_code)) {
|
||||||
|
// Check if the payload is numerically 1, and had no trailing chars.
|
||||||
|
// e.g. "1foo" or "1.2.3" could fool us.
|
||||||
|
// Check if the version we have been asked to upgrade to is higher than our current version.
|
||||||
|
// We also need at least 3 chars to make a valid version number string.
|
||||||
|
if (((1 == data_len) && (1 == payload)) || ((data_len >= 3) && NewerVersion(dataBuf))) {
|
||||||
|
ota_state_flag = 3;
|
||||||
|
// snprintf_P(mqtt_data, sizeof(mqtt_data), "{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}", command, my_version, Settings.ota_url);
|
||||||
|
snprintf_P(mqtt_data, sizeof(mqtt_data), "{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}", command, my_version, GetOtaUrl(stemp1, sizeof(stemp1)));
|
||||||
|
} else {
|
||||||
|
snprintf_P(mqtt_data, sizeof(mqtt_data), "{\"%s\":\"" D_JSON_ONE_OR_GT "\"}", command, my_version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (CMND_OTAURL == command_code) {
|
||||||
|
if ((data_len > 0) && (data_len < sizeof(Settings.ota_url)))
|
||||||
|
strlcpy(Settings.ota_url, (1 == payload) ? OTA_URL : dataBuf, sizeof(Settings.ota_url));
|
||||||
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, Settings.ota_url);
|
||||||
|
}
|
||||||
|
else if (CMND_SERIALLOG == command_code) {
|
||||||
|
if ((payload >= LOG_LEVEL_NONE) && (payload <= LOG_LEVEL_ALL)) {
|
||||||
|
Settings.flag.mqtt_serial = 0;
|
||||||
|
SetSeriallog(payload);
|
||||||
|
}
|
||||||
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE_ACTIVE_NVALUE, command, Settings.seriallog_level, seriallog_level);
|
||||||
|
}
|
||||||
|
else if (CMND_RESTART == command_code) {
|
||||||
|
switch (payload) {
|
||||||
|
case 1:
|
||||||
|
restart_flag = 2;
|
||||||
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_RESTARTING);
|
||||||
|
break;
|
||||||
|
case 99:
|
||||||
|
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
|
||||||
|
EspRestart();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_ONE_TO_RESTART);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifndef BE_MINIMAL
|
||||||
else if ((CMND_POWERONSTATE == command_code) && (Settings.module != MOTOR)) {
|
else if ((CMND_POWERONSTATE == command_code) && (Settings.module != MOTOR)) {
|
||||||
/* 0 = Keep relays off after power on
|
/* 0 = Keep relays off after power on
|
||||||
* 1 = Turn relays on after power on, if PulseTime set wait for PulseTime seconds, and turn relays off
|
* 1 = Turn relays on after power on, if PulseTime set wait for PulseTime seconds, and turn relays off
|
||||||
|
@ -854,32 +911,6 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||||
}
|
}
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, command, Settings.pulse_counter_debounce);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, command, Settings.pulse_counter_debounce);
|
||||||
}
|
}
|
||||||
else if (CMND_SLEEP == command_code) {
|
|
||||||
if ((payload >= 0) && (payload < 251)) {
|
|
||||||
if ((!Settings.sleep && payload) || (Settings.sleep && !payload)) restart_flag = 2;
|
|
||||||
Settings.sleep = payload;
|
|
||||||
sleep = payload;
|
|
||||||
}
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE_UNIT_NVALUE_UNIT, command, sleep, (Settings.flag.value_units) ? " " D_UNIT_MILLISECOND : "", Settings.sleep, (Settings.flag.value_units) ? " " D_UNIT_MILLISECOND : "");
|
|
||||||
}
|
|
||||||
else if ((CMND_UPGRADE == command_code) || (CMND_UPLOAD == command_code)) {
|
|
||||||
// Check if the payload is numerically 1, and had no trailing chars.
|
|
||||||
// e.g. "1foo" or "1.2.3" could fool us.
|
|
||||||
// Check if the version we have been asked to upgrade to is higher than our current version.
|
|
||||||
// We also need at least 3 chars to make a valid version number string.
|
|
||||||
if (((1 == data_len) && (1 == payload)) || ((data_len >= 3) && NewerVersion(dataBuf))) {
|
|
||||||
ota_state_flag = 3;
|
|
||||||
// snprintf_P(mqtt_data, sizeof(mqtt_data), "{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}", command, my_version, Settings.ota_url);
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), "{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}", command, my_version, GetOtaUrl(stemp1, sizeof(stemp1)));
|
|
||||||
} else {
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), "{\"%s\":\"" D_JSON_ONE_OR_GT "\"}", command, my_version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (CMND_OTAURL == command_code) {
|
|
||||||
if ((data_len > 0) && (data_len < sizeof(Settings.ota_url)))
|
|
||||||
strlcpy(Settings.ota_url, (1 == payload) ? OTA_URL : dataBuf, sizeof(Settings.ota_url));
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, Settings.ota_url);
|
|
||||||
}
|
|
||||||
else if (CMND_BAUDRATE == command_code) {
|
else if (CMND_BAUDRATE == command_code) {
|
||||||
if (payload32 > 0) {
|
if (payload32 > 0) {
|
||||||
payload32 /= 1200; // Make it a valid baudrate
|
payload32 /= 1200; // Make it a valid baudrate
|
||||||
|
@ -917,13 +948,6 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||||
}
|
}
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, command, Settings.serial_delimiter);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE, command, Settings.serial_delimiter);
|
||||||
}
|
}
|
||||||
else if (CMND_SERIALLOG == command_code) {
|
|
||||||
if ((payload >= LOG_LEVEL_NONE) && (payload <= LOG_LEVEL_ALL)) {
|
|
||||||
Settings.flag.mqtt_serial = 0;
|
|
||||||
SetSeriallog(payload);
|
|
||||||
}
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE_ACTIVE_NVALUE, command, Settings.seriallog_level, seriallog_level);
|
|
||||||
}
|
|
||||||
else if (CMND_SYSLOG == command_code) {
|
else if (CMND_SYSLOG == command_code) {
|
||||||
if ((payload >= LOG_LEVEL_NONE) && (payload <= LOG_LEVEL_ALL)) {
|
if ((payload >= LOG_LEVEL_NONE) && (payload <= LOG_LEVEL_ALL)) {
|
||||||
Settings.syslog_level = payload;
|
Settings.syslog_level = payload;
|
||||||
|
@ -1040,20 +1064,6 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||||
}
|
}
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE_UNIT, command, Settings.tele_period, (Settings.flag.value_units) ? " " D_UNIT_SECOND : "");
|
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_NVALUE_UNIT, command, Settings.tele_period, (Settings.flag.value_units) ? " " D_UNIT_SECOND : "");
|
||||||
}
|
}
|
||||||
else if (CMND_RESTART == command_code) {
|
|
||||||
switch (payload) {
|
|
||||||
case 1:
|
|
||||||
restart_flag = 2;
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_RESTARTING);
|
|
||||||
break;
|
|
||||||
case 99:
|
|
||||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
|
|
||||||
EspRestart();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_ONE_TO_RESTART);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (CMND_RESET == command_code) {
|
else if (CMND_RESET == command_code) {
|
||||||
switch (payload) {
|
switch (payload) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -1147,6 +1157,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||||
I2cScan(mqtt_data, sizeof(mqtt_data));
|
I2cScan(mqtt_data, sizeof(mqtt_data));
|
||||||
}
|
}
|
||||||
#endif // USE_I2C
|
#endif // USE_I2C
|
||||||
|
#endif // Not BE_MINIMAL
|
||||||
else type = NULL; // Unknown command
|
else type = NULL; // Unknown command
|
||||||
}
|
}
|
||||||
if (type == NULL) {
|
if (type == NULL) {
|
||||||
|
@ -2142,6 +2153,7 @@ void SerialInput()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_ENERGY_SENSOR
|
||||||
/*-------------------------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------------------------*\
|
||||||
* Sonoff S31 and Sonoff Pow R2 4800 baud serial interface
|
* Sonoff S31 and Sonoff Pow R2 4800 baud serial interface
|
||||||
\*-------------------------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------------------------*/
|
||||||
|
@ -2152,7 +2164,7 @@ void SerialInput()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // USE_ENERGY_SENSOR
|
||||||
/*-------------------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
if (serial_in_byte > 127) { // binary data...
|
if (serial_in_byte > 127) { // binary data...
|
||||||
|
|
|
@ -51,6 +51,7 @@ void KNX_CB_Action(message_t const &msg, void *arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USE_DHT // Default DHT11 sensor needs no external library
|
#define USE_DHT // Default DHT11 sensor needs no external library
|
||||||
|
#define USE_ENERGY_SENSOR // Use energy sensors
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* [sonoff-allsensors.bin]
|
* [sonoff-allsensors.bin]
|
||||||
|
@ -58,6 +59,7 @@ void KNX_CB_Action(message_t const &msg, void *arg);
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#ifdef USE_ALL_SENSORS
|
#ifdef USE_ALL_SENSORS
|
||||||
|
|
||||||
#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices
|
#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices
|
||||||
#define USE_DS18x20 // For more than one DS18x20 sensors with id sort, single scan and read retry (+1k3 code)
|
#define USE_DS18x20 // For more than one DS18x20 sensors with id sort, single scan and read retry (+1k3 code)
|
||||||
//#define USE_DS18x20_LEGACY // For more than one DS18x20 sensors with dynamic scan using library OneWire (+1k5 code)
|
//#define USE_DS18x20_LEGACY // For more than one DS18x20 sensors with dynamic scan using library OneWire (+1k5 code)
|
||||||
|
@ -65,16 +67,19 @@ void KNX_CB_Action(message_t const &msg, void *arg);
|
||||||
#define USE_SHT // Add I2C emulating code for SHT1X sensor (+1k4 code)
|
#define USE_SHT // Add I2C emulating code for SHT1X sensor (+1k4 code)
|
||||||
#define USE_SHT3X // Add I2C code for SHT3x sensor (+0k6 code)
|
#define USE_SHT3X // Add I2C code for SHT3x sensor (+0k6 code)
|
||||||
#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_LM75AD // Add I2C code for LM75AD sensor (+0k5 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 Bosch BME680 library (+4k code)
|
||||||
#define USE_SGP30 // Add I2C code for SGP30 sensor (+1k1 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)
|
||||||
|
//#define USE_SI1145 // Add I2C code for SI1145/46/47 sensor (+1k code)
|
||||||
#define USE_ADS1115 // Add I2C code for ADS1115 16 bit A/D converter based on Adafruit ADS1x15 library (no library needed) (+0k7 code)
|
#define USE_ADS1115 // Add I2C code for ADS1115 16 bit A/D converter based on Adafruit ADS1x15 library (no library needed) (+0k7 code)
|
||||||
//#define USE_ADS1115_I2CDEV // Add I2C code for ADS1115 16 bit A/D converter using library i2cdevlib-Core and i2cdevlib-ADS1115 (+2k code)
|
//#define USE_ADS1115_I2CDEV // Add I2C code for ADS1115 16 bit A/D converter using library i2cdevlib-Core and i2cdevlib-ADS1115 (+2k code)
|
||||||
#define USE_INA219 // Add I2C code for INA219 Low voltage and current sensor (+1k code)
|
#define USE_INA219 // Add I2C code for INA219 Low voltage and current sensor (+1k code)
|
||||||
#define USE_MGS // Add I2C code for Xadow and Grove Mutichannel Gas sensor using library Multichannel_Gas_Sensor (+10k code)
|
#define USE_MGS // Add I2C code for Xadow and Grove Mutichannel Gas sensor using library Multichannel_Gas_Sensor (+10k code)
|
||||||
|
//#define USE_APDS9960 // Add I2C code for APDS9960 Proximity Sensor. Disables SHT and VEML6070 (+4k7 code)
|
||||||
#define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k code)
|
#define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k code)
|
||||||
#define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code)
|
#define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code)
|
||||||
#ifndef CO2_LOW
|
#ifndef CO2_LOW
|
||||||
|
@ -87,6 +92,8 @@ void KNX_CB_Action(message_t const &msg, void *arg);
|
||||||
#define USE_NOVA_SDS // Add support for SDS011 and SDS021 particle concentration sensor (+0k7 code)
|
#define USE_NOVA_SDS // Add support for SDS011 and SDS021 particle concentration sensor (+0k7 code)
|
||||||
#define USE_PZEM004T // Add support for PZEM004T Energy monitor (+2k code)
|
#define USE_PZEM004T // Add support for PZEM004T Energy monitor (+2k code)
|
||||||
#define USE_SERIAL_BRIDGE // Add support for software Serial Bridge (+0k8 code)
|
#define USE_SERIAL_BRIDGE // Add support for software Serial Bridge (+0k8 code)
|
||||||
|
#define USE_SDM120 // Add support for Eastron SDM120-Modbus energy meter (+1k7 code)
|
||||||
|
#define USE_SDM630 // Add support for Eastron SDM630-Modbus energy meter (+2k code)
|
||||||
#define USE_IR_REMOTE // Send IR remote commands using library IRremoteESP8266 and ArduinoJson (+4k code, 0k3 mem, 48 iram)
|
#define USE_IR_REMOTE // Send IR remote commands using library IRremoteESP8266 and ArduinoJson (+4k code, 0k3 mem, 48 iram)
|
||||||
#define USE_IR_HVAC // Support for HVAC system using IR (+2k code)
|
#define USE_IR_HVAC // Support for HVAC system using IR (+2k code)
|
||||||
#define USE_IR_RECEIVE // Support for IR receiver (+5k5 code, 264 iram)
|
#define USE_IR_RECEIVE // Support for IR receiver (+5k5 code, 264 iram)
|
||||||
|
@ -105,36 +112,28 @@ void KNX_CB_Action(message_t const &msg, void *arg);
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#ifdef USE_CLASSIC
|
#ifdef USE_CLASSIC
|
||||||
#ifdef USE_KNX
|
|
||||||
#undef USE_KNX
|
#undef USE_KNX // Disable KNX IP Protocol Support
|
||||||
#endif
|
#undef USE_TIMERS // Disable support for up to 16 timers
|
||||||
#ifdef USE_TIMERS
|
#undef USE_TIMERS_WEB // Disable support for timer webpage
|
||||||
#undef USE_TIMERS
|
#undef USE_SUNRISE // Disable support for Sunrise and sunset tools
|
||||||
#endif
|
#undef USE_RULES // Disable support for rules
|
||||||
#ifdef USE_TIMERS_WEB
|
#undef USE_LM75AD // Disable sensor
|
||||||
#undef USE_TIMERS_WEB
|
#undef USE_BME680 // Disable sensor
|
||||||
#endif
|
#undef USE_SGP30 // Disable sensor
|
||||||
#ifdef USE_SUNRISE
|
#undef USE_SENSEAIR // Disable support for SenseAir K30, K70 and S8 CO2 sensor
|
||||||
#undef USE_SUNRISE
|
#undef USE_NOVA_SDS // Disable support for SDS011 and SDS021 particle concentration sensor
|
||||||
#endif
|
#undef USE_PZEM004T // Disable PZEM004T energy sensor
|
||||||
#ifdef USE_RULES
|
#undef USE_IR_RECEIVE // Disable support for IR receiver
|
||||||
#undef USE_RULES
|
#undef USE_SERIAL_BRIDGE // Disable support for software Serial Bridge
|
||||||
#endif
|
#undef USE_SDM120 // Disable support for Eastron SDM120-Modbus energy meter
|
||||||
#ifdef USE_SGP30
|
#undef USE_SDM630 // Disable support for Eastron SDM630-Modbus energy meter
|
||||||
#undef USE_SGP30
|
#undef USE_ARILUX_RF // Disable support for Arilux RF remote controller
|
||||||
#endif
|
#undef USE_SR04 // Disable support for for HC-SR04 ultrasonic devices
|
||||||
#ifdef USE_NOVA_SDS
|
#undef USE_TM1638 // Disable support for TM1638 switches copying Switch1 .. Switch8
|
||||||
#undef USE_NOVA_SDS
|
#undef USE_RF_FLASH // Disable support for flashing the EFM8BB1 chip on the Sonoff RF Bridge. C2CK must be connected to GPIO4, C2D to GPIO5 on the PCB
|
||||||
#endif
|
#undef DEBUG_THEO // Disable debug code
|
||||||
#ifdef USE_IR_RECEIVE
|
#undef USE_DEBUG_DRIVER // Disable debug code
|
||||||
#undef USE_IR_RECEIVE
|
|
||||||
#endif
|
|
||||||
#ifdef USE_SERIAL_BRIDGE
|
|
||||||
#undef USE_SERIAL_BRIDGE
|
|
||||||
#endif
|
|
||||||
#ifdef USE_SR04
|
|
||||||
#undef USE_SR04
|
|
||||||
#endif
|
|
||||||
#endif // USE_CLASSIC
|
#endif // USE_CLASSIC
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
|
@ -143,12 +142,11 @@ void KNX_CB_Action(message_t const &msg, void *arg);
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#ifdef USE_KNX_NO_EMULATION
|
#ifdef USE_KNX_NO_EMULATION
|
||||||
|
|
||||||
#ifndef USE_KNX
|
#ifndef USE_KNX
|
||||||
#define USE_KNX // Enable KNX IP Protocol Support (+23k code, +3k3 mem)
|
#define USE_KNX // Enable KNX IP Protocol Support (+23k code, +3k3 mem)
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_EMULATION
|
|
||||||
#undef USE_EMULATION // Disable Belkin WeMo and Hue Bridge emulation for Alexa (-16k code, -2k mem)
|
#undef USE_EMULATION // Disable Belkin WeMo and Hue Bridge emulation for Alexa (-16k code, -2k mem)
|
||||||
#endif
|
|
||||||
#endif // USE_KNX_NO_EMULATION
|
#endif // USE_KNX_NO_EMULATION
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
|
@ -166,90 +164,43 @@ void KNX_CB_Action(message_t const &msg, void *arg);
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#ifdef BE_MINIMAL
|
#ifdef BE_MINIMAL
|
||||||
#ifdef USE_MQTT_TLS
|
|
||||||
#undef USE_MQTT_TLS // Disable TLS support won't work as the MQTTHost is not set
|
#undef USE_ENERGY_SENSOR // Disable energy sensors
|
||||||
#endif
|
#undef USE_ARDUINO_OTA // Disable support for Arduino OTA
|
||||||
#ifdef USE_DISCOVERY
|
|
||||||
#undef USE_DISCOVERY // Disable Discovery services for both MQTT and web server
|
|
||||||
#endif
|
|
||||||
#ifdef USE_DOMOTICZ
|
|
||||||
#undef USE_DOMOTICZ // Disable Domoticz
|
#undef USE_DOMOTICZ // Disable Domoticz
|
||||||
#endif
|
|
||||||
#ifdef USE_HOME_ASSISTANT
|
|
||||||
#undef USE_HOME_ASSISTANT // Disable Home Assistant
|
#undef USE_HOME_ASSISTANT // Disable Home Assistant
|
||||||
#endif
|
#undef USE_MQTT_TLS // Disable TLS support won't work as the MQTTHost is not set
|
||||||
#ifdef USE_KNX
|
|
||||||
#undef USE_KNX // Disable KNX IP Protocol Support
|
#undef USE_KNX // Disable KNX IP Protocol Support
|
||||||
#endif
|
|
||||||
//#ifdef USE_WEBSERVER
|
|
||||||
//#undef USE_WEBSERVER // Disable Webserver
|
//#undef USE_WEBSERVER // Disable Webserver
|
||||||
//#endif
|
#undef USE_DISCOVERY // Disable Discovery services for both MQTT and web server
|
||||||
#ifdef USE_EMULATION
|
|
||||||
#undef USE_EMULATION // Disable Wemo or Hue emulation
|
#undef USE_EMULATION // Disable Wemo or Hue emulation
|
||||||
#endif
|
|
||||||
#ifdef USE_TIMERS
|
|
||||||
#undef USE_TIMERS // Disable support for up to 16 timers
|
#undef USE_TIMERS // Disable support for up to 16 timers
|
||||||
#endif
|
#undef USE_TIMERS_WEB // Disable support for timer webpage
|
||||||
#ifdef USE_SUNRISE
|
|
||||||
#undef USE_SUNRISE // Disable support for Sunrise and sunset tools
|
#undef USE_SUNRISE // Disable support for Sunrise and sunset tools
|
||||||
#endif
|
|
||||||
#ifdef USE_RULES
|
|
||||||
#undef USE_RULES // Disable support for rules
|
#undef USE_RULES // Disable support for rules
|
||||||
#endif
|
|
||||||
#ifdef USE_DHT
|
|
||||||
#undef USE_DHT // Disable internal DHT sensor
|
#undef USE_DHT // Disable internal DHT sensor
|
||||||
#endif
|
|
||||||
#ifdef USE_DS18x20
|
|
||||||
#undef USE_DS18x20 // Disable DS18x20 sensor
|
#undef USE_DS18x20 // Disable DS18x20 sensor
|
||||||
#endif
|
#undef USE_DS18x20_LEGACY // Disable DS18x20 sensor
|
||||||
#ifdef USE_DS18B20
|
|
||||||
#undef USE_DS18B20 // Disable internal DS18B20 sensor
|
#undef USE_DS18B20 // Disable internal DS18B20 sensor
|
||||||
#endif
|
|
||||||
#ifdef USE_I2C
|
|
||||||
#undef USE_I2C // Disable all I2C sensors and devices
|
#undef USE_I2C // Disable all I2C sensors and devices
|
||||||
#endif
|
|
||||||
#ifdef USE_SPI
|
|
||||||
#undef USE_SPI // Disable all SPI devices
|
#undef USE_SPI // Disable all SPI devices
|
||||||
#endif
|
|
||||||
#ifdef USE_DISPLAY
|
|
||||||
#undef USE_DISPLAY // Disable Display support
|
#undef USE_DISPLAY // Disable Display support
|
||||||
#endif
|
|
||||||
#ifdef USE_MHZ19
|
|
||||||
#undef USE_MHZ19 // Disable support for MH-Z19 CO2 sensor
|
#undef USE_MHZ19 // Disable support for MH-Z19 CO2 sensor
|
||||||
#endif
|
|
||||||
#ifdef USE_SENSEAIR
|
|
||||||
#undef USE_SENSEAIR // Disable support for SenseAir K30, K70 and S8 CO2 sensor
|
#undef USE_SENSEAIR // Disable support for SenseAir K30, K70 and S8 CO2 sensor
|
||||||
#endif
|
|
||||||
#ifdef USE_PMS5003
|
|
||||||
#undef USE_PMS5003 // Disable support for PMS5003 and PMS7003 particle concentration sensor
|
#undef USE_PMS5003 // Disable support for PMS5003 and PMS7003 particle concentration sensor
|
||||||
#endif
|
|
||||||
#ifdef USE_NOVA_SDS
|
|
||||||
#undef USE_NOVA_SDS // Disable support for SDS011 and SDS021 particle concentration sensor
|
#undef USE_NOVA_SDS // Disable support for SDS011 and SDS021 particle concentration sensor
|
||||||
#endif
|
|
||||||
#ifdef USE_PZEM004T
|
|
||||||
#undef USE_PZEM004T // Disable PZEM004T energy sensor
|
#undef USE_PZEM004T // Disable PZEM004T energy sensor
|
||||||
#endif
|
|
||||||
#ifdef USE_SERIAL_BRIDGE
|
|
||||||
#undef USE_SERIAL_BRIDGE // Disable support for software Serial Bridge
|
#undef USE_SERIAL_BRIDGE // Disable support for software Serial Bridge
|
||||||
#endif
|
#undef USE_SDM120 // Disable support for Eastron SDM120-Modbus energy meter
|
||||||
#ifdef USE_IR_REMOTE
|
#undef USE_SDM630 // Disable support for Eastron SDM630-Modbus energy meter
|
||||||
#undef USE_IR_REMOTE // Disable IR driver
|
#undef USE_IR_REMOTE // Disable IR driver
|
||||||
#endif
|
|
||||||
#ifdef USE_WS2812
|
|
||||||
#undef USE_WS2812 // Disable WS2812 Led string
|
#undef USE_WS2812 // Disable WS2812 Led string
|
||||||
#endif
|
|
||||||
#ifdef USE_ARILUX_RF
|
|
||||||
#undef USE_ARILUX_RF // Disable support for Arilux RF remote controller
|
#undef USE_ARILUX_RF // Disable support for Arilux RF remote controller
|
||||||
#endif
|
|
||||||
#ifdef USE_SR04
|
|
||||||
#undef USE_SR04 // Disable support for for HC-SR04 ultrasonic devices
|
#undef USE_SR04 // Disable support for for HC-SR04 ultrasonic devices
|
||||||
#endif
|
#undef USE_TM1638 // Disable support for TM1638 switches copying Switch1 .. Switch8
|
||||||
#ifdef DEBUG_THEO
|
#undef USE_RF_FLASH // Disable support for flashing the EFM8BB1 chip on the Sonoff RF Bridge. C2CK must be connected to GPIO4, C2D to GPIO5 on the PCB
|
||||||
#undef DEBUG_THEO // Disable debug code
|
#undef DEBUG_THEO // Disable debug code
|
||||||
#endif
|
|
||||||
#ifdef USE_DEBUG_DRIVER
|
|
||||||
#undef USE_DEBUG_DRIVER // Disable debug code
|
#undef USE_DEBUG_DRIVER // Disable debug code
|
||||||
#endif
|
|
||||||
#endif // BE_MINIMAL
|
#endif // BE_MINIMAL
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
// -- Master parameter control --------------------
|
// -- Master parameter control --------------------
|
||||||
#define CFG_HOLDER 4617 // [Reset 1] Change this value to load SECTION1 configuration parameters to flash
|
#define CFG_HOLDER 4617 // [Reset 1] Change this value (max 32000) to load SECTION1 configuration parameters to flash
|
||||||
|
|
||||||
// -- Project -------------------------------------
|
// -- Project -------------------------------------
|
||||||
#define PROJECT "sonoff" // PROJECT is used as the default topic delimiter
|
#define PROJECT "sonoff" // PROJECT is used as the default topic delimiter
|
||||||
|
@ -265,7 +265,7 @@
|
||||||
#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_LM75AD // Add I2C code for LM75AD sensor (+0k5 code)
|
#define USE_LM75AD // Add I2C code for LM75AD sensor (+0k5 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 Bosch BME680 library (+4k code)
|
||||||
#define USE_SGP30 // Add I2C code for SGP30 sensor (+1k1 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)
|
||||||
|
|
|
@ -367,6 +367,14 @@ void StartWebserver(int type, IPAddress ipweb)
|
||||||
if (!WebServer) {
|
if (!WebServer) {
|
||||||
WebServer = new ESP8266WebServer((HTTP_MANAGER==type) ? 80 : WEB_PORT);
|
WebServer = new ESP8266WebServer((HTTP_MANAGER==type) ? 80 : WEB_PORT);
|
||||||
WebServer->on("/", HandleRoot);
|
WebServer->on("/", HandleRoot);
|
||||||
|
WebServer->on("/up", HandleUpgradeFirmware);
|
||||||
|
WebServer->on("/u1", HandleUpgradeFirmwareStart); // OTA
|
||||||
|
WebServer->on("/u2", HTTP_POST, HandleUploadDone, HandleUploadLoop);
|
||||||
|
WebServer->on("/cs", HandleConsole);
|
||||||
|
WebServer->on("/ax", HandleAjaxConsoleRefresh);
|
||||||
|
WebServer->on("/ay", HandleAjaxStatusRefresh);
|
||||||
|
WebServer->on("/rb", HandleRestart);
|
||||||
|
#ifndef BE_MINIMAL
|
||||||
WebServer->on("/cn", HandleConfiguration);
|
WebServer->on("/cn", HandleConfiguration);
|
||||||
WebServer->on("/md", HandleModuleConfiguration);
|
WebServer->on("/md", HandleModuleConfiguration);
|
||||||
#if defined(USE_TIMERS) && defined(USE_TIMERS_WEB)
|
#if defined(USE_TIMERS) && defined(USE_TIMERS_WEB)
|
||||||
|
@ -389,17 +397,9 @@ void StartWebserver(int type, IPAddress ipweb)
|
||||||
WebServer->on("/sv", HandleSaveSettings);
|
WebServer->on("/sv", HandleSaveSettings);
|
||||||
WebServer->on("/rs", HandleRestoreConfiguration);
|
WebServer->on("/rs", HandleRestoreConfiguration);
|
||||||
WebServer->on("/rt", HandleResetConfiguration);
|
WebServer->on("/rt", HandleResetConfiguration);
|
||||||
WebServer->on("/up", HandleUpgradeFirmware);
|
|
||||||
WebServer->on("/u1", HandleUpgradeFirmwareStart); // OTA
|
|
||||||
WebServer->on("/u2", HTTP_POST, HandleUploadDone, HandleUploadLoop);
|
|
||||||
WebServer->on("/u2", HTTP_OPTIONS, HandlePreflightRequest);
|
WebServer->on("/u2", HTTP_OPTIONS, HandlePreflightRequest);
|
||||||
WebServer->on("/cm", HandleHttpCommand);
|
WebServer->on("/cm", HandleHttpCommand);
|
||||||
WebServer->on("/cs", HandleConsole);
|
|
||||||
WebServer->on("/ax", HandleAjaxConsoleRefresh);
|
|
||||||
WebServer->on("/ay", HandleAjaxStatusRefresh);
|
|
||||||
WebServer->on("/in", HandleInformation);
|
WebServer->on("/in", HandleInformation);
|
||||||
WebServer->on("/rb", HandleRestart);
|
|
||||||
WebServer->on("/fwlink", HandleRoot); // Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
|
|
||||||
#ifdef USE_EMULATION
|
#ifdef USE_EMULATION
|
||||||
if (EMUL_WEMO == Settings.flag2.emulation) {
|
if (EMUL_WEMO == Settings.flag2.emulation) {
|
||||||
WebServer->on("/upnp/control/basicevent1", HTTP_POST, HandleUpnpEvent);
|
WebServer->on("/upnp/control/basicevent1", HTTP_POST, HandleUpnpEvent);
|
||||||
|
@ -411,6 +411,8 @@ void StartWebserver(int type, IPAddress ipweb)
|
||||||
WebServer->on("/description.xml", HandleUpnpSetupHue);
|
WebServer->on("/description.xml", HandleUpnpSetupHue);
|
||||||
}
|
}
|
||||||
#endif // USE_EMULATION
|
#endif // USE_EMULATION
|
||||||
|
#endif // Not BE_MINIMAL
|
||||||
|
WebServer->on("/fwlink", HandleRoot); // Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
|
||||||
WebServer->onNotFound(HandleNotFound);
|
WebServer->onNotFound(HandleNotFound);
|
||||||
}
|
}
|
||||||
reset_web_log_flag = 0;
|
reset_web_log_flag = 0;
|
||||||
|
@ -520,6 +522,7 @@ void HandleRoot()
|
||||||
if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the page.
|
if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the page.
|
||||||
|
|
||||||
if (HTTP_MANAGER == webserver_state) {
|
if (HTTP_MANAGER == webserver_state) {
|
||||||
|
#ifndef BE_MINIMAL
|
||||||
if ((Settings.web_password[0] != 0) && !(WebServer->hasArg("USER1")) && !(WebServer->hasArg("PASS1"))) {
|
if ((Settings.web_password[0] != 0) && !(WebServer->hasArg("USER1")) && !(WebServer->hasArg("PASS1"))) {
|
||||||
HandleWifiLogin();
|
HandleWifiLogin();
|
||||||
} else {
|
} else {
|
||||||
|
@ -537,6 +540,7 @@ void HandleRoot()
|
||||||
HandleWifiLogin();
|
HandleWifiLogin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // Not BE_MINIMAL
|
||||||
} else {
|
} else {
|
||||||
char stemp[10];
|
char stemp[10];
|
||||||
String page = FPSTR(HTTP_HEAD);
|
String page = FPSTR(HTTP_HEAD);
|
||||||
|
@ -672,6 +676,7 @@ boolean HttpUser()
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef BE_MINIMAL
|
||||||
void HandleConfiguration()
|
void HandleConfiguration()
|
||||||
{
|
{
|
||||||
if (HttpUser()) { return; }
|
if (HttpUser()) { return; }
|
||||||
|
@ -1205,6 +1210,122 @@ void HandleRestoreConfiguration()
|
||||||
upload_file_type = UPL_SETTINGS;
|
upload_file_type = UPL_SETTINGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HandleInformation()
|
||||||
|
{
|
||||||
|
if (HttpUser()) { return; }
|
||||||
|
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_INFORMATION);
|
||||||
|
|
||||||
|
char stopic[TOPSZ];
|
||||||
|
|
||||||
|
int freeMem = ESP.getFreeHeap();
|
||||||
|
|
||||||
|
String page = FPSTR(HTTP_HEAD);
|
||||||
|
page.replace(F("{v}"), FPSTR(S_INFORMATION));
|
||||||
|
page += FPSTR(HTTP_HEAD_STYLE);
|
||||||
|
// page += F("<fieldset><legend><b> Information </b></legend>");
|
||||||
|
|
||||||
|
page += F("<style>td{padding:0px 5px;}</style>");
|
||||||
|
page += F("<div id='i' name='i'></div>");
|
||||||
|
|
||||||
|
// Save 1k of code space replacing table html with javascript replace codes
|
||||||
|
// }1 = </td></tr><tr><th>
|
||||||
|
// }2 = </th><td>
|
||||||
|
String func = FPSTR(HTTP_SCRIPT_INFO_BEGIN);
|
||||||
|
func += F("<table style='width:100%'><tr><th>");
|
||||||
|
func += F(D_PROGRAM_VERSION "}2"); func += my_version;
|
||||||
|
func += F("}1" D_BUILD_DATE_AND_TIME "}2"); func += GetBuildDateAndTime();
|
||||||
|
func += F("}1" D_CORE_AND_SDK_VERSION "}2" ARDUINO_ESP8266_RELEASE "/"); func += String(ESP.getSdkVersion());
|
||||||
|
func += F("}1" D_UPTIME "}2"); func += GetDateAndTime(DT_UPTIME);
|
||||||
|
snprintf_P(stopic, sizeof(stopic), PSTR(" at %X"), GetSettingsAddress());
|
||||||
|
func += F("}1" D_FLASH_WRITE_COUNT "}2"); func += String(Settings.save_flag); func += stopic;
|
||||||
|
func += F("}1" D_BOOT_COUNT "}2"); func += String(Settings.bootcount);
|
||||||
|
func += F("}1" D_RESTART_REASON "}2"); func += GetResetReason();
|
||||||
|
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : devices_present;
|
||||||
|
if (SONOFF_IFAN02 == Settings.module) { maxfn = 1; }
|
||||||
|
for (byte i = 0; i < maxfn; i++) {
|
||||||
|
func += F("}1" D_FRIENDLY_NAME " "); func += i +1; func += F("}2"); func += Settings.friendlyname[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
func += F("}1}2 "); // Empty line
|
||||||
|
func += F("}1" D_AP); func += String(Settings.sta_active +1);
|
||||||
|
func += F(" " D_SSID " (" D_RSSI ")}2"); func += Settings.sta_ssid[Settings.sta_active]; func += F(" ("); func += WifiGetRssiAsQuality(WiFi.RSSI()); func += F("%)");
|
||||||
|
func += F("}1" D_HOSTNAME "}2"); func += my_hostname;
|
||||||
|
if (static_cast<uint32_t>(WiFi.localIP()) != 0) {
|
||||||
|
func += F("}1" D_IP_ADDRESS "}2"); func += WiFi.localIP().toString();
|
||||||
|
func += F("}1" D_GATEWAY "}2"); func += IPAddress(Settings.ip_address[1]).toString();
|
||||||
|
func += F("}1" D_SUBNET_MASK "}2"); func += IPAddress(Settings.ip_address[2]).toString();
|
||||||
|
func += F("}1" D_DNS_SERVER "}2"); func += IPAddress(Settings.ip_address[3]).toString();
|
||||||
|
func += F("}1" D_MAC_ADDRESS "}2"); func += WiFi.macAddress();
|
||||||
|
}
|
||||||
|
if (static_cast<uint32_t>(WiFi.softAPIP()) != 0) {
|
||||||
|
func += F("}1" D_AP " " D_IP_ADDRESS "}2"); func += WiFi.softAPIP().toString();
|
||||||
|
func += F("}1" D_AP " " D_GATEWAY "}2"); func += WiFi.softAPIP().toString();
|
||||||
|
func += F("}1" D_AP " " D_MAC_ADDRESS "}2"); func += WiFi.softAPmacAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
func += F("}1}2 "); // Empty line
|
||||||
|
if (Settings.flag.mqtt_enabled) {
|
||||||
|
func += F("}1" D_MQTT_HOST "}2"); func += Settings.mqtt_host;
|
||||||
|
func += F("}1" D_MQTT_PORT "}2"); func += String(Settings.mqtt_port);
|
||||||
|
func += F("}1" D_MQTT_CLIENT " &<br/> " D_FALLBACK_TOPIC "}2"); func += mqtt_client;
|
||||||
|
func += F("}1" D_MQTT_USER "}2"); func += Settings.mqtt_user;
|
||||||
|
func += F("}1" D_MQTT_TOPIC "}2"); func += Settings.mqtt_topic;
|
||||||
|
func += F("}1" D_MQTT_GROUP_TOPIC "}2"); func += Settings.mqtt_grptopic;
|
||||||
|
GetTopic_P(stopic, CMND, mqtt_topic, "");
|
||||||
|
func += F("}1" D_MQTT_FULL_TOPIC "}2"); func += stopic;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
func += F("}1" D_MQTT "}2" D_DISABLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
func += F("}1}2 "); // Empty line
|
||||||
|
func += F("}1" D_EMULATION "}2");
|
||||||
|
#ifdef USE_EMULATION
|
||||||
|
if (EMUL_WEMO == Settings.flag2.emulation) {
|
||||||
|
func += F(D_BELKIN_WEMO);
|
||||||
|
}
|
||||||
|
else if (EMUL_HUE == Settings.flag2.emulation) {
|
||||||
|
func += F(D_HUE_BRIDGE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
func += F(D_NONE);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
func += F(D_DISABLED);
|
||||||
|
#endif // USE_EMULATION
|
||||||
|
|
||||||
|
func += F("}1" D_MDNS_DISCOVERY "}2");
|
||||||
|
#ifdef USE_DISCOVERY
|
||||||
|
func += F(D_ENABLED);
|
||||||
|
func += F("}1" D_MDNS_ADVERTISE "}2");
|
||||||
|
#ifdef WEBSERVER_ADVERTISE
|
||||||
|
func += F(D_WEB_SERVER);
|
||||||
|
#else
|
||||||
|
func += F(D_DISABLED);
|
||||||
|
#endif // WEBSERVER_ADVERTISE
|
||||||
|
#else
|
||||||
|
func += F(D_DISABLED);
|
||||||
|
#endif // USE_DISCOVERY
|
||||||
|
|
||||||
|
func += F("}1}2 "); // Empty line
|
||||||
|
func += F("}1" D_ESP_CHIP_ID "}2"); func += String(ESP.getChipId());
|
||||||
|
func += F("}1" D_FLASH_CHIP_ID "}2"); func += String(ESP.getFlashChipId());
|
||||||
|
func += F("}1" D_FLASH_CHIP_SIZE "}2"); func += String(ESP.getFlashChipRealSize() / 1024); func += F("kB");
|
||||||
|
func += F("}1" D_PROGRAM_FLASH_SIZE "}2"); func += String(ESP.getFlashChipSize() / 1024); func += F("kB");
|
||||||
|
func += F("}1" D_PROGRAM_SIZE "}2"); func += String(ESP.getSketchSize() / 1024); func += F("kB");
|
||||||
|
func += F("}1" D_FREE_PROGRAM_SPACE "}2"); func += String(ESP.getFreeSketchSpace() / 1024); func += F("kB");
|
||||||
|
func += F("}1" D_FREE_MEMORY "}2"); func += String(freeMem / 1024); func += F("kB");
|
||||||
|
func += F("</td></tr></table>");
|
||||||
|
func += FPSTR(HTTP_SCRIPT_INFO_END);
|
||||||
|
page.replace(F("</script>"), func);
|
||||||
|
page.replace(F("<body>"), F("<body onload='i()'>"));
|
||||||
|
|
||||||
|
// page += F("</fieldset>");
|
||||||
|
page += FPSTR(HTTP_BTN_MAIN);
|
||||||
|
ShowPage(page);
|
||||||
|
}
|
||||||
|
#endif // Not BE_MINIMAL
|
||||||
|
|
||||||
void HandleUpgradeFirmware()
|
void HandleUpgradeFirmware()
|
||||||
{
|
{
|
||||||
if (HttpUser()) { return; }
|
if (HttpUser()) { return; }
|
||||||
|
@ -1629,121 +1750,6 @@ void HandleAjaxConsoleRefresh()
|
||||||
WebServer->send(200, FPSTR(HDR_CTYPE_XML), message);
|
WebServer->send(200, FPSTR(HDR_CTYPE_XML), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleInformation()
|
|
||||||
{
|
|
||||||
if (HttpUser()) { return; }
|
|
||||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_INFORMATION);
|
|
||||||
|
|
||||||
char stopic[TOPSZ];
|
|
||||||
|
|
||||||
int freeMem = ESP.getFreeHeap();
|
|
||||||
|
|
||||||
String page = FPSTR(HTTP_HEAD);
|
|
||||||
page.replace(F("{v}"), FPSTR(S_INFORMATION));
|
|
||||||
page += FPSTR(HTTP_HEAD_STYLE);
|
|
||||||
// page += F("<fieldset><legend><b> Information </b></legend>");
|
|
||||||
|
|
||||||
page += F("<style>td{padding:0px 5px;}</style>");
|
|
||||||
page += F("<div id='i' name='i'></div>");
|
|
||||||
|
|
||||||
// Save 1k of code space replacing table html with javascript replace codes
|
|
||||||
// }1 = </td></tr><tr><th>
|
|
||||||
// }2 = </th><td>
|
|
||||||
String func = FPSTR(HTTP_SCRIPT_INFO_BEGIN);
|
|
||||||
func += F("<table style='width:100%'><tr><th>");
|
|
||||||
func += F(D_PROGRAM_VERSION "}2"); func += my_version;
|
|
||||||
func += F("}1" D_BUILD_DATE_AND_TIME "}2"); func += GetBuildDateAndTime();
|
|
||||||
func += F("}1" D_CORE_AND_SDK_VERSION "}2" ARDUINO_ESP8266_RELEASE "/"); func += String(ESP.getSdkVersion());
|
|
||||||
func += F("}1" D_UPTIME "}2"); func += GetDateAndTime(DT_UPTIME);
|
|
||||||
snprintf_P(stopic, sizeof(stopic), PSTR(" at %X"), GetSettingsAddress());
|
|
||||||
func += F("}1" D_FLASH_WRITE_COUNT "}2"); func += String(Settings.save_flag); func += stopic;
|
|
||||||
func += F("}1" D_BOOT_COUNT "}2"); func += String(Settings.bootcount);
|
|
||||||
func += F("}1" D_RESTART_REASON "}2"); func += GetResetReason();
|
|
||||||
uint8_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : devices_present;
|
|
||||||
if (SONOFF_IFAN02 == Settings.module) { maxfn = 1; }
|
|
||||||
for (byte i = 0; i < maxfn; i++) {
|
|
||||||
func += F("}1" D_FRIENDLY_NAME " "); func += i +1; func += F("}2"); func += Settings.friendlyname[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
func += F("}1}2 "); // Empty line
|
|
||||||
func += F("}1" D_AP); func += String(Settings.sta_active +1);
|
|
||||||
func += F(" " D_SSID " (" D_RSSI ")}2"); func += Settings.sta_ssid[Settings.sta_active]; func += F(" ("); func += WifiGetRssiAsQuality(WiFi.RSSI()); func += F("%)");
|
|
||||||
func += F("}1" D_HOSTNAME "}2"); func += my_hostname;
|
|
||||||
if (static_cast<uint32_t>(WiFi.localIP()) != 0) {
|
|
||||||
func += F("}1" D_IP_ADDRESS "}2"); func += WiFi.localIP().toString();
|
|
||||||
func += F("}1" D_GATEWAY "}2"); func += IPAddress(Settings.ip_address[1]).toString();
|
|
||||||
func += F("}1" D_SUBNET_MASK "}2"); func += IPAddress(Settings.ip_address[2]).toString();
|
|
||||||
func += F("}1" D_DNS_SERVER "}2"); func += IPAddress(Settings.ip_address[3]).toString();
|
|
||||||
func += F("}1" D_MAC_ADDRESS "}2"); func += WiFi.macAddress();
|
|
||||||
}
|
|
||||||
if (static_cast<uint32_t>(WiFi.softAPIP()) != 0) {
|
|
||||||
func += F("}1" D_AP " " D_IP_ADDRESS "}2"); func += WiFi.softAPIP().toString();
|
|
||||||
func += F("}1" D_AP " " D_GATEWAY "}2"); func += WiFi.softAPIP().toString();
|
|
||||||
func += F("}1" D_AP " " D_MAC_ADDRESS "}2"); func += WiFi.softAPmacAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
func += F("}1}2 "); // Empty line
|
|
||||||
if (Settings.flag.mqtt_enabled) {
|
|
||||||
func += F("}1" D_MQTT_HOST "}2"); func += Settings.mqtt_host;
|
|
||||||
func += F("}1" D_MQTT_PORT "}2"); func += String(Settings.mqtt_port);
|
|
||||||
func += F("}1" D_MQTT_CLIENT " &<br/> " D_FALLBACK_TOPIC "}2"); func += mqtt_client;
|
|
||||||
func += F("}1" D_MQTT_USER "}2"); func += Settings.mqtt_user;
|
|
||||||
func += F("}1" D_MQTT_TOPIC "}2"); func += Settings.mqtt_topic;
|
|
||||||
func += F("}1" D_MQTT_GROUP_TOPIC "}2"); func += Settings.mqtt_grptopic;
|
|
||||||
GetTopic_P(stopic, CMND, mqtt_topic, "");
|
|
||||||
func += F("}1" D_MQTT_FULL_TOPIC "}2"); func += stopic;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
func += F("}1" D_MQTT "}2" D_DISABLED);
|
|
||||||
}
|
|
||||||
|
|
||||||
func += F("}1}2 "); // Empty line
|
|
||||||
func += F("}1" D_EMULATION "}2");
|
|
||||||
#ifdef USE_EMULATION
|
|
||||||
if (EMUL_WEMO == Settings.flag2.emulation) {
|
|
||||||
func += F(D_BELKIN_WEMO);
|
|
||||||
}
|
|
||||||
else if (EMUL_HUE == Settings.flag2.emulation) {
|
|
||||||
func += F(D_HUE_BRIDGE);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
func += F(D_NONE);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
func += F(D_DISABLED);
|
|
||||||
#endif // USE_EMULATION
|
|
||||||
|
|
||||||
func += F("}1" D_MDNS_DISCOVERY "}2");
|
|
||||||
#ifdef USE_DISCOVERY
|
|
||||||
func += F(D_ENABLED);
|
|
||||||
func += F("}1" D_MDNS_ADVERTISE "}2");
|
|
||||||
#ifdef WEBSERVER_ADVERTISE
|
|
||||||
func += F(D_WEB_SERVER);
|
|
||||||
#else
|
|
||||||
func += F(D_DISABLED);
|
|
||||||
#endif // WEBSERVER_ADVERTISE
|
|
||||||
#else
|
|
||||||
func += F(D_DISABLED);
|
|
||||||
#endif // USE_DISCOVERY
|
|
||||||
|
|
||||||
func += F("}1}2 "); // Empty line
|
|
||||||
func += F("}1" D_ESP_CHIP_ID "}2"); func += String(ESP.getChipId());
|
|
||||||
func += F("}1" D_FLASH_CHIP_ID "}2"); func += String(ESP.getFlashChipId());
|
|
||||||
func += F("}1" D_FLASH_CHIP_SIZE "}2"); func += String(ESP.getFlashChipRealSize() / 1024); func += F("kB");
|
|
||||||
func += F("}1" D_PROGRAM_FLASH_SIZE "}2"); func += String(ESP.getFlashChipSize() / 1024); func += F("kB");
|
|
||||||
func += F("}1" D_PROGRAM_SIZE "}2"); func += String(ESP.getSketchSize() / 1024); func += F("kB");
|
|
||||||
func += F("}1" D_FREE_PROGRAM_SPACE "}2"); func += String(ESP.getFreeSketchSpace() / 1024); func += F("kB");
|
|
||||||
func += F("}1" D_FREE_MEMORY "}2"); func += String(freeMem / 1024); func += F("kB");
|
|
||||||
func += F("</td></tr></table>");
|
|
||||||
func += FPSTR(HTTP_SCRIPT_INFO_END);
|
|
||||||
page.replace(F("</script>"), func);
|
|
||||||
page.replace(F("<body>"), F("<body onload='i()'>"));
|
|
||||||
|
|
||||||
// page += F("</fieldset>");
|
|
||||||
page += FPSTR(HTTP_BTN_MAIN);
|
|
||||||
ShowPage(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HandleRestart()
|
void HandleRestart()
|
||||||
{
|
{
|
||||||
if (HttpUser()) { return; }
|
if (HttpUser()) { return; }
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define USE_ENERGY_SENSOR
|
|
||||||
|
|
||||||
#ifdef USE_ENERGY_SENSOR
|
#ifdef USE_ENERGY_SENSOR
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* HLW8012 and PZEM004T - Energy
|
* HLW8012 and PZEM004T - Energy
|
||||||
|
@ -93,18 +91,18 @@ void EnergyUpdateToday()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* HLW8012, BL0937 or HJL-01 - Energy (Sonoff Pow)
|
* HLW8012, BL0937 or HJL-01 - Energy (Sonoff Pow, HuaFan, KMC70011, BlitzWolf)
|
||||||
*
|
*
|
||||||
* Based on Source: Shenzhen Heli Technology Co., Ltd
|
* Based on Source: Shenzhen Heli Technology Co., Ltd
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
// HLW8012 based (Sonoff Pow, KMC70011)
|
// HLW8012 based (Sonoff Pow, KMC70011, HuaFan)
|
||||||
#define HLW_PREF 10000 // 1000.0W
|
#define HLW_PREF 10000 // 1000.0W
|
||||||
#define HLW_UREF 2200 // 220.0V
|
#define HLW_UREF 2200 // 220.0V
|
||||||
#define HLW_IREF 4545 // 4.545A
|
#define HLW_IREF 4545 // 4.545A
|
||||||
#define HLW_SEL_VOLTAGE 1
|
#define HLW_SEL_VOLTAGE 1
|
||||||
|
|
||||||
// HJL-01 based (Homecube, BlitzWolf)
|
// HJL-01 based (BlitzWolf, Homecube, Gosund)
|
||||||
#define HJL_PREF 1362
|
#define HJL_PREF 1362
|
||||||
#define HJL_UREF 822
|
#define HJL_UREF 822
|
||||||
#define HJL_IREF 3300
|
#define HJL_IREF 3300
|
||||||
|
|
Loading…
Reference in New Issue