Browse Source

Key renaming, first round

v2
Xose Pérez 6 years ago
parent
commit
62d05b77ff
38 changed files with 399 additions and 203 deletions
  1. +3
    -3
      README.md
  2. +12
    -6
      code/espurna/alexa.ino
  3. +7
    -1
      code/espurna/api.ino
  4. +2
    -0
      code/espurna/broker.ino
  5. +2
    -0
      code/espurna/button.ino
  6. +2
    -0
      code/espurna/debug.ino
  7. +2
    -0
      code/espurna/domoticz.ino
  8. +4
    -0
      code/espurna/eeprom.ino
  9. +3
    -1
      code/espurna/espurna.ino
  10. +2
    -0
      code/espurna/gpio.ino
  11. +2
    -0
      code/espurna/homeassistant.ino
  12. +13
    -0
      code/espurna/i2c.ino
  13. +21
    -5
      code/espurna/influxdb.ino
  14. +2
    -0
      code/espurna/ir.ino
  15. +2
    -0
      code/espurna/led.ino
  16. +47
    -30
      code/espurna/light.ino
  17. +1
    -1
      code/espurna/mdns.ino
  18. +3
    -3
      code/espurna/migrate.ino
  19. +11
    -3
      code/espurna/mqtt.ino
  20. +17
    -8
      code/espurna/nofuss.ino
  21. +8
    -0
      code/espurna/ntp.ino
  22. +17
    -1
      code/espurna/ota.ino
  23. +23
    -15
      code/espurna/relay.ino
  24. +2
    -0
      code/espurna/rf.ino
  25. +3
    -1
      code/espurna/rfbridge.ino
  26. +2
    -0
      code/espurna/scheduler.ino
  27. +77
    -58
      code/espurna/sensor.ino
  28. +19
    -0
      code/espurna/settings.ino
  29. +2
    -0
      code/espurna/ssdp.ino
  30. +2
    -0
      code/espurna/system.ino
  31. +13
    -4
      code/espurna/telnet.ino
  32. +2
    -0
      code/espurna/thinkspeak.ino
  33. +2
    -0
      code/espurna/uartmqtt.ino
  34. +2
    -0
      code/espurna/utils.ino
  35. +2
    -0
      code/espurna/web.ino
  36. +2
    -0
      code/espurna/wifi.ino
  37. +14
    -14
      code/html/custom.js
  38. +49
    -49
      code/html/index.html

+ 3
- 3
README.md View File

@ -4,9 +4,9 @@ ESPurna ("spark" in Catalan) is a custom firmware for ESP8285/ESP8266 based smar
It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries. It uses the Arduino Core for ESP8266 framework and a number of 3rd party libraries.
[![version](https://img.shields.io/badge/version-1.13.1a-brightgreen.svg)](CHANGELOG.md) [![version](https://img.shields.io/badge/version-1.13.1a-brightgreen.svg)](CHANGELOG.md)
[![branch](https://img.shields.io/badge/branch-dev-orange.svg)](https://github.com/xoseperez/espurna/tree/dev/)
[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=dev)](https://travis-ci.org/xoseperez/espurna)
[![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/dev.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard)
[![branch](https://img.shields.io/badge/branch-softcfg-orange.svg)](https://github.com/xoseperez/espurna/tree/softcfg/)
[![travis](https://travis-ci.org/xoseperez/espurna.svg?branch=softcfg)](https://travis-ci.org/xoseperez/espurna)
[![codacy](https://img.shields.io/codacy/grade/c9496e25cf07434cba786b462cb15f49/softcfg.svg)](https://www.codacy.com/app/xoseperez/espurna/dashboard)
[![license](https://img.shields.io/github/license/xoseperez/espurna.svg)](LICENSE) [![license](https://img.shields.io/github/license/xoseperez/espurna.svg)](LICENSE)
<br /> <br />
[![donate](https://img.shields.io/badge/donate-PayPal-blue.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=xose%2eperez%40gmail%2ecom&lc=US&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHostedGuest) [![donate](https://img.shields.io/badge/donate-PayPal-blue.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=xose%2eperez%40gmail%2ecom&lc=US&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHostedGuest)


+ 12
- 6
code/espurna/alexa.ino View File

@ -4,6 +4,8 @@ ALEXA MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: alx
*/ */
#if ALEXA_SUPPORT #if ALEXA_SUPPORT
@ -24,24 +26,28 @@ static std::queue<AlexaDevChange> _alexa_dev_changes;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool _alexaWebSocketOnReceive(const char * key, JsonVariant& value) { bool _alexaWebSocketOnReceive(const char * key, JsonVariant& value) {
return (strncmp(key, "alexa", 5) == 0);
return (strncmp(key, "alx", 3) == 0);
} }
void _alexaWebSocketOnSend(JsonObject& root) { void _alexaWebSocketOnSend(JsonObject& root) {
root["alexaVisible"] = 1;
root["alexaEnabled"] = getSetting("alexaEnabled", ALEXA_ENABLED).toInt() == 1;
root["alxVisible"] = 1;
root["alxEnabled"] = getSetting("alxEnabled", ALEXA_ENABLED).toInt() == 1;
} }
void _alexaConfigure() { void _alexaConfigure() {
alexa.enable(getSetting("alexaEnabled", ALEXA_ENABLED).toInt() == 1);
alexa.enable(getSetting("alxEnabled", ALEXA_ENABLED).toInt() == 1);
} }
void _alexaBackwards() {
moveSetting("fauxmoEnabled", "alxEnabled"); // 1.9.0 - 2017-08-25
moveSetting("alexaEnabled", "alxEnabled"); // 1.13.1 - 2018-06-27
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void alexaSetup() { void alexaSetup() {
// Backwards compatibility
moveSetting("fauxmoEnabled", "alexaEnabled");
// Check backwards compatibility
_alexaBackwards();
// Load & cache settings // Load & cache settings
_alexaConfigure(); _alexaConfigure();


+ 7
- 1
code/espurna/api.ino View File

@ -4,6 +4,8 @@ API MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: api
*/ */
#if WEB_SUPPORT #if WEB_SUPPORT
@ -29,7 +31,7 @@ bool _apiWebSocketOnReceive(const char * key, JsonVariant& value) {
void _apiWebSocketOnSend(JsonObject& root) { void _apiWebSocketOnSend(JsonObject& root) {
root["apiEnabled"] = getSetting("apiEnabled", API_ENABLED).toInt() == 1; root["apiEnabled"] = getSetting("apiEnabled", API_ENABLED).toInt() == 1;
root["apiKey"] = getSetting("apiKey"); root["apiKey"] = getSetting("apiKey");
root["apiRealTime"] = getSetting("apiRealTime", API_REAL_TIME_VALUES).toInt() == 1;
root["apiRealTime"] = apiRealTime();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -199,4 +201,8 @@ void apiSetup() {
wsOnReceiveRegister(_apiWebSocketOnReceive); wsOnReceiveRegister(_apiWebSocketOnReceive);
} }
bool apiRealTime() {
return getSetting("apiRealTime", API_REAL_TIME_VALUES).toInt() == 1;
}
#endif // WEB_SUPPORT #endif // WEB_SUPPORT

+ 2
- 0
code/espurna/broker.ino View File

@ -4,6 +4,8 @@ BROKER MODULE
Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: bkr
*/ */
#if BROKER_SUPPORT #if BROKER_SUPPORT


+ 2
- 0
code/espurna/button.ino View File

@ -4,6 +4,8 @@ BUTTON MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: btn
*/ */
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


+ 2
- 0
code/espurna/debug.ino View File

@ -4,6 +4,8 @@ DEBUG MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: dbg
*/ */
#if DEBUG_SUPPORT #if DEBUG_SUPPORT


+ 2
- 0
code/espurna/domoticz.ino View File

@ -4,6 +4,8 @@ DOMOTICZ MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: dcz
*/ */
#if DOMOTICZ_SUPPORT #if DOMOTICZ_SUPPORT


+ 4
- 0
code/espurna/eeprom.ino View File

@ -2,6 +2,10 @@
EEPROM MODULE EEPROM MODULE
Copyright (C) 2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: eep
*/ */
#include <EEPROM_Rotate.h> #include <EEPROM_Rotate.h>


+ 3
- 1
code/espurna/espurna.ino View File

@ -17,6 +17,8 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
Module key prefix: esp (shared with others)
*/ */
#include "config/all.h" #include "config/all.h"
@ -49,7 +51,7 @@ void setup() {
// Init EEPROM // Init EEPROM
eepromSetup(); eepromSetup();
// Init Serial, SPIFFS and system check // Init Serial, SPIFFS and system check
systemSetup(); systemSetup();


+ 2
- 0
code/espurna/gpio.ino View File

@ -4,6 +4,8 @@ GPIO MODULE
Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: io
*/ */
unsigned int _gpio_locked = 0; unsigned int _gpio_locked = 0;


+ 2
- 0
code/espurna/homeassistant.ino View File

@ -4,6 +4,8 @@ HOME ASSISTANT MODULE
Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: ha
*/ */
#if HOMEASSISTANT_SUPPORT #if HOMEASSISTANT_SUPPORT


+ 13
- 0
code/espurna/i2c.ino View File

@ -4,6 +4,8 @@ I2C MODULE
Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: i2c
*/ */
#if I2C_SUPPORT #if I2C_SUPPORT
@ -104,6 +106,13 @@ int _i2cClearbus(int sda, int scl) {
} }
#if WEB_SUPPORT
bool _i2cWebSocketOnReceive(const char * key, JsonVariant& value) {
return (strncmp(key, "i2c", 3) == 0);
}
#endif // WEB_SUPPORT
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// I2C API // I2C API
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
@ -364,6 +373,10 @@ void i2cSetup() {
Wire.begin(sda, scl); Wire.begin(sda, scl);
#endif #endif
#if WEB_SUPPORT
wsOnReceiveRegister(_i2cWebSocketOnReceive);
#endif
DEBUG_MSG_P(PSTR("[I2C] Using GPIO%u for SDA and GPIO%u for SCL\n"), sda, scl); DEBUG_MSG_P(PSTR("[I2C] Using GPIO%u for SDA and GPIO%u for SCL\n"), sda, scl);
#if I2C_CLEAR_BUS #if I2C_CLEAR_BUS


+ 21
- 5
code/espurna/influxdb.ino View File

@ -4,6 +4,8 @@ INFLUXDB MODULE
Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: idb
*/ */
#if INFLUXDB_SUPPORT #if INFLUXDB_SUPPORT
@ -16,6 +18,8 @@ SyncClient _idb_client;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#if WEB_SUPPORT
bool _idbWebSocketOnReceive(const char * key, JsonVariant& value) { bool _idbWebSocketOnReceive(const char * key, JsonVariant& value) {
return (strncmp(key, "idb", 3) == 0); return (strncmp(key, "idb", 3) == 0);
} }
@ -25,9 +29,9 @@ void _idbWebSocketOnSend(JsonObject& root) {
root["idbEnabled"] = getSetting("idbEnabled", INFLUXDB_ENABLED).toInt() == 1; root["idbEnabled"] = getSetting("idbEnabled", INFLUXDB_ENABLED).toInt() == 1;
root["idbHost"] = getSetting("idbHost", INFLUXDB_HOST); root["idbHost"] = getSetting("idbHost", INFLUXDB_HOST);
root["idbPort"] = getSetting("idbPort", INFLUXDB_PORT).toInt(); root["idbPort"] = getSetting("idbPort", INFLUXDB_PORT).toInt();
root["idbDatabase"] = getSetting("idbDatabase", INFLUXDB_DATABASE);
root["idbUsername"] = getSetting("idbUsername", INFLUXDB_USERNAME);
root["idbPassword"] = getSetting("idbPassword", INFLUXDB_PASSWORD);
root["idbDB"] = getSetting("idbDB", INFLUXDB_DATABASE);
root["idbUser"] = getSetting("idbUser", INFLUXDB_USERNAME);
root["idbPass"] = getSetting("idbPass", INFLUXDB_PASSWORD);
} }
void _idbConfigure() { void _idbConfigure() {
@ -38,6 +42,14 @@ void _idbConfigure() {
} }
} }
#endif // WEB_SUPPORT
void _idbBackwards() {
moveSetting("idbDatabase", "idbDB"); // 1.13.1 - 2018-06-26
moveSetting("idbUserName", "idbUser"); // 1.13.1 - 2018-06-26
moveSetting("idbPassword", "idbPass"); // 1.13.1 - 2018-06-26
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool idbSend(const char * topic, const char * payload) { bool idbSend(const char * topic, const char * payload) {
@ -64,8 +76,8 @@ bool idbSend(const char * topic, const char * payload) {
char request[256]; char request[256];
snprintf(request, sizeof(request), "POST /write?db=%s&u=%s&p=%s HTTP/1.1\r\nHost: %s:%u\r\nContent-Length: %d\r\n\r\n%s", snprintf(request, sizeof(request), "POST /write?db=%s&u=%s&p=%s HTTP/1.1\r\nHost: %s:%u\r\nContent-Length: %d\r\n\r\n%s",
getSetting("idbDatabase", INFLUXDB_DATABASE).c_str(),
getSetting("idbUsername", INFLUXDB_USERNAME).c_str(), getSetting("idbPassword", INFLUXDB_PASSWORD).c_str(),
getSetting("idbDB", INFLUXDB_DATABASE).c_str(),
getSetting("idbUser", INFLUXDB_USERNAME).c_str(), getSetting("idbPass", INFLUXDB_PASSWORD).c_str(),
host, port, strlen(data), data); host, port, strlen(data), data);
if (_idb_client.printf(request) > 0) { if (_idb_client.printf(request) > 0) {
@ -100,12 +112,16 @@ bool idbEnabled() {
} }
void idbSetup() { void idbSetup() {
_idbBackwards();
_idbConfigure(); _idbConfigure();
#if WEB_SUPPORT #if WEB_SUPPORT
wsOnSendRegister(_idbWebSocketOnSend); wsOnSendRegister(_idbWebSocketOnSend);
wsOnAfterParseRegister(_idbConfigure); wsOnAfterParseRegister(_idbConfigure);
wsOnReceiveRegister(_idbWebSocketOnReceive); wsOnReceiveRegister(_idbWebSocketOnReceive);
#endif #endif
} }
#endif #endif

+ 2
- 0
code/espurna/ir.ino View File

@ -5,6 +5,8 @@ IR MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Copyright (C) 2017-2018 by François Déchery Copyright (C) 2017-2018 by François Déchery
Module key prefix: ir
*/ */
#if IR_SUPPORT #if IR_SUPPORT


+ 2
- 0
code/espurna/led.ino View File

@ -4,6 +4,8 @@ LED MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: led
*/ */
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


+ 47
- 30
code/espurna/light.ino View File

@ -4,6 +4,8 @@ LIGHT MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: lit
*/ */
#if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE #if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE
@ -462,19 +464,19 @@ void _lightProviderUpdate() {
void _lightColorSave() { void _lightColorSave() {
for (unsigned int i=0; i < _light_channel.size(); i++) { for (unsigned int i=0; i < _light_channel.size(); i++) {
setSetting("ch", i, _light_channel[i].inputValue);
setSetting("litCH", i, _light_channel[i].inputValue);
} }
setSetting("brightness", _light_brightness);
setSetting("mireds", _light_mireds);
setSetting("litBright", _light_brightness);
setSetting("litMireds", _light_mireds);
saveSettings(); saveSettings();
} }
void _lightColorRestore() { void _lightColorRestore() {
for (unsigned int i=0; i < _light_channel.size(); i++) { for (unsigned int i=0; i < _light_channel.size(); i++) {
_light_channel[i].inputValue = getSetting("ch", i, i==0 ? 255 : 0).toInt();
_light_channel[i].inputValue = getSetting("litCH", i, i==0 ? 255 : 0).toInt();
} }
_light_brightness = getSetting("brightness", LIGHT_MAX_BRIGHTNESS).toInt();
_light_mireds = getSetting("mireds", _light_mireds).toInt();
_light_brightness = getSetting("litBright", LIGHT_MAX_BRIGHTNESS).toInt();
_light_mireds = getSetting("litMireds", _light_mireds).toInt();
lightUpdate(false, false); lightUpdate(false, false);
} }
@ -574,7 +576,7 @@ void lightMQTT() {
if (_light_has_color) { if (_light_has_color) {
// Color // Color
if (getSetting("useCSS", LIGHT_USE_CSS).toInt() == 1) {
if (getSetting("litCSS", LIGHT_USE_CSS).toInt() == 1) {
_toRGB(buffer, sizeof(buffer)); _toRGB(buffer, sizeof(buffer));
} else { } else {
_toLong(buffer, sizeof(buffer)); _toLong(buffer, sizeof(buffer));
@ -760,25 +762,24 @@ void lightBrightnessStep(int steps) {
#if WEB_SUPPORT #if WEB_SUPPORT
bool _lightWebSocketOnReceive(const char * key, JsonVariant& value) { bool _lightWebSocketOnReceive(const char * key, JsonVariant& value) {
if (strncmp(key, "light", 5) == 0) return true;
if (strncmp(key, "use", 3) == 0) return true;
if (strncmp(key, "lit", 3) == 0) return true;
return false; return false;
} }
void _lightWebSocketOnSend(JsonObject& root) { void _lightWebSocketOnSend(JsonObject& root) {
root["colorVisible"] = 1;
root["litVisible"] = 1;
root["mqttGroupColor"] = getSetting("mqttGroupColor"); root["mqttGroupColor"] = getSetting("mqttGroupColor");
root["useColor"] = _light_has_color;
root["useWhite"] = _light_use_white;
root["useGamma"] = _light_use_gamma;
root["useTransitions"] = _light_use_transitions;
root["lightTime"] = _light_transition_time;
root["useCSS"] = getSetting("useCSS", LIGHT_USE_CSS).toInt() == 1;
bool useRGB = getSetting("useRGB", LIGHT_USE_RGB).toInt() == 1;
root["useRGB"] = useRGB;
root["litColor"] = _light_has_color;
root["litWhite"] = _light_use_white;
root["litGamma"] = _light_use_gamma;
root["litTrans"] = _light_use_transitions;
root["litTime"] = _light_transition_time;
root["litCSS"] = getSetting("litCSS", LIGHT_USE_CSS).toInt() == 1;
bool useRGB = getSetting("litRGB", LIGHT_USE_RGB).toInt() == 1;
root["litRGB"] = useRGB;
if (_light_has_color) { if (_light_has_color) {
if (_light_use_cct) { if (_light_use_cct) {
root["useCCT"] = _light_use_cct;
root["litCCT"] = _light_use_cct;
root["mireds"] = _light_mireds; root["mireds"] = _light_mireds;
} }
if (useRGB) { if (useRGB) {
@ -831,7 +832,7 @@ void _lightAPISetup() {
if (_light_has_color) { if (_light_has_color) {
apiRegister(MQTT_TOPIC_COLOR_RGB, apiRegister(MQTT_TOPIC_COLOR_RGB,
[](char * buffer, size_t len) { [](char * buffer, size_t len) {
if (getSetting("useCSS", LIGHT_USE_CSS).toInt() == 1) {
if (getSetting("litCSS", LIGHT_USE_CSS).toInt() == 1) {
_toRGB(buffer, len); _toRGB(buffer, len);
} else { } else {
_toLong(buffer, len); _toLong(buffer, len);
@ -902,7 +903,7 @@ void _lightAPISetup() {
void _lightInitCommands() { void _lightInitCommands() {
settingsRegisterCommand(F("BRIGHTNESS"), [](Embedis* e) {
settingsRegisterCommand(F("brightness"), [](Embedis* e) {
if (e->argc > 1) { if (e->argc > 1) {
lightBrightness(String(e->argv[1]).toInt()); lightBrightness(String(e->argv[1]).toInt());
lightUpdate(true, true); lightUpdate(true, true);
@ -985,32 +986,48 @@ unsigned long getIOFunc(unsigned long gpio) {
void _lightConfigure() { void _lightConfigure() {
_light_has_color = getSetting("useColor", LIGHT_USE_COLOR).toInt() == 1;
_light_has_color = getSetting("litColor", LIGHT_USE_COLOR).toInt() == 1;
if (_light_has_color && (_light_channel.size() < 3)) { if (_light_has_color && (_light_channel.size() < 3)) {
_light_has_color = false; _light_has_color = false;
setSetting("useColor", _light_has_color);
setSetting("litColor", _light_has_color);
} }
_light_use_white = getSetting("useWhite", LIGHT_USE_WHITE).toInt() == 1;
_light_use_white = getSetting("litWhite", LIGHT_USE_WHITE).toInt() == 1;
if (_light_use_white && (_light_channel.size() < 4)) { if (_light_use_white && (_light_channel.size() < 4)) {
_light_use_white = false; _light_use_white = false;
setSetting("useWhite", _light_use_white);
setSetting("litWhite", _light_use_white);
} }
_light_use_cct = getSetting("useCCT", LIGHT_USE_CCT).toInt() == 1;
_light_use_cct = getSetting("litCCT", LIGHT_USE_CCT).toInt() == 1;
if (_light_use_cct && ((_light_channel.size() < 5) || !_light_use_white)) { if (_light_use_cct && ((_light_channel.size() < 5) || !_light_use_white)) {
_light_use_cct = false; _light_use_cct = false;
setSetting("useCCT", _light_use_cct);
setSetting("litCCT", _light_use_cct);
} }
_light_use_gamma = getSetting("useGamma", LIGHT_USE_GAMMA).toInt() == 1;
_light_use_transitions = getSetting("useTransitions", LIGHT_USE_TRANSITIONS).toInt() == 1;
_light_transition_time = getSetting("lightTime", LIGHT_TRANSITION_TIME).toInt();
_light_use_gamma = getSetting("litGamma", LIGHT_USE_GAMMA).toInt() == 1;
_light_use_transitions = getSetting("litTrans", LIGHT_USE_TRANSITIONS).toInt() == 1;
_light_transition_time = getSetting("litTime", LIGHT_TRANSITION_TIME).toInt();
}
void _lightBackwards() {
moveSettings("ch", "litCH"); // 1.13.1 - 2018-06-26
moveSetting("useCSS", "litCSS"); // 1.13.1 - 2018-06-26
moveSetting("useRGB", "litRGB"); // 1.13.1 - 2018-06-26
moveSetting("useColor", "litColor"); // 1.13.1 - 2018-06-26
moveSetting("useWhite", "litWhite"); // 1.13.1 - 2018-06-26
moveSetting("useCCT", "litCCT"); // 1.13.1 - 2018-06-26
moveSetting("useGamma", "litGamma"); // 1.13.1 - 2018-06-26
moveSetting("useTransitions", "litTrans"); // 1.13.1 - 2018-06-26
moveSetting("lightTime", "litTime"); // 1.13.1 - 2018-06-26
moveSetting("brightness", "litBright"); // 1.13.1 - 2018-06-26
moveSetting("mireds", "litMireds"); // 1.13.1 - 2018-06-26
} }
void lightSetup() { void lightSetup() {
_lightBackwards();
#ifdef LIGHT_ENABLE_PIN #ifdef LIGHT_ENABLE_PIN
pinMode(LIGHT_ENABLE_PIN, OUTPUT); pinMode(LIGHT_ENABLE_PIN, OUTPUT);
digitalWrite(LIGHT_ENABLE_PIN, HIGH); digitalWrite(LIGHT_ENABLE_PIN, HIGH);


+ 1
- 1
code/espurna/mdns.ino View File

@ -40,7 +40,7 @@ void _mdnsServerStart() {
void mdnsServerSetup() { void mdnsServerSetup() {
#if WEB_SUPPORT #if WEB_SUPPORT
MDNS.addService("http", "tcp", getSetting("webPort", WEB_PORT).toInt());
MDNS.addService("http", "tcp", webPort());
#endif #endif
#if TELNET_SUPPORT #if TELNET_SUPPORT


+ 3
- 3
code/espurna/migrate.ino View File

@ -1032,9 +1032,9 @@ void migrate() {
setSetting("selGPIO", 12); setSetting("selGPIO", 12);
setSetting("cf1GPIO", 14); setSetting("cf1GPIO", 14);
setSetting("cfGPIO", 5); setSetting("cfGPIO", 5);
setSetting("pwrRatioC", 25740);
setSetting("pwrRatioV", 313400);
setSetting("pwrRatioP", 3414290);
setSetting("curRatio", 25740);
setSetting("volRatio", 313400);
setSetting("pwrRatio", 3414290);
setSetting("hlwSelC", LOW); setSetting("hlwSelC", LOW);
setSetting("hlwIntM", FALLING); setSetting("hlwIntM", FALLING);


+ 11
- 3
code/espurna/mqtt.ino View File

@ -4,6 +4,8 @@ MQTT MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: mqtt
*/ */
#if MQTT_SUPPORT #if MQTT_SUPPORT
@ -99,7 +101,7 @@ void _mqttConnect() {
if (_mqtt_clientid) free(_mqtt_clientid); if (_mqtt_clientid) free(_mqtt_clientid);
_mqtt_user = strdup(getSetting("mqttUser", MQTT_USER).c_str()); _mqtt_user = strdup(getSetting("mqttUser", MQTT_USER).c_str());
_mqtt_pass = strdup(getSetting("mqttPassword", MQTT_PASS).c_str());
_mqtt_pass = strdup(getSetting("mqttPass", MQTT_PASS).c_str());
_mqtt_will = strdup(mqttTopic(MQTT_TOPIC_STATUS, false).c_str()); _mqtt_will = strdup(mqttTopic(MQTT_TOPIC_STATUS, false).c_str());
_mqtt_clientid = strdup(getSetting("mqttClientID", getIdentifier()).c_str()); _mqtt_clientid = strdup(getSetting("mqttClientID", getIdentifier()).c_str());
@ -250,11 +252,16 @@ void _mqttConfigure() {
} }
void _mqttBackwards() { void _mqttBackwards() {
// 1.13.0 - 2018-05-30
String mqttTopic = getSetting("mqttTopic", MQTT_TOPIC); String mqttTopic = getSetting("mqttTopic", MQTT_TOPIC);
if (mqttTopic.indexOf("{identifier}") > 0) { if (mqttTopic.indexOf("{identifier}") > 0) {
mqttTopic.replace("{identifier}", "{hostname}"); mqttTopic.replace("{identifier}", "{hostname}");
setSetting("mqttTopic", mqttTopic); setSetting("mqttTopic", mqttTopic);
} }
moveSetting("mqttPassword", "mqttPass"); // 1.13.1 - 2018-06-26
} }
unsigned long _mqttNextMessageId() { unsigned long _mqttNextMessageId() {
@ -317,7 +324,7 @@ void _mqttWebSocketOnSend(JsonObject& root) {
root["mqttPort"] = getSetting("mqttPort", MQTT_PORT); root["mqttPort"] = getSetting("mqttPort", MQTT_PORT);
root["mqttUser"] = getSetting("mqttUser", MQTT_USER); root["mqttUser"] = getSetting("mqttUser", MQTT_USER);
root["mqttClientID"] = getSetting("mqttClientID"); root["mqttClientID"] = getSetting("mqttClientID");
root["mqttPassword"] = getSetting("mqttPassword", MQTT_PASS);
root["mqttPass"] = getSetting("mqttPass", MQTT_PASS);
root["mqttKeep"] = _mqtt_keepalive; root["mqttKeep"] = _mqtt_keepalive;
root["mqttRetain"] = _mqtt_retain; root["mqttRetain"] = _mqtt_retain;
root["mqttQoS"] = _mqtt_qos; root["mqttQoS"] = _mqtt_qos;
@ -750,8 +757,9 @@ void mqttReset() {
void mqttSetup() { void mqttSetup() {
// Check backwards compatibility
_mqttBackwards(); _mqttBackwards();
DEBUG_MSG_P(PSTR("[MQTT] Async %s, SSL %s, Autoconnect %s\n"), DEBUG_MSG_P(PSTR("[MQTT] Async %s, SSL %s, Autoconnect %s\n"),
MQTT_USE_ASYNC ? "ENABLED" : "DISABLED", MQTT_USE_ASYNC ? "ENABLED" : "DISABLED",
ASYNC_TCP_SSL_ENABLED ? "ENABLED" : "DISABLED", ASYNC_TCP_SSL_ENABLED ? "ENABLED" : "DISABLED",


+ 17
- 8
code/espurna/nofuss.ino View File

@ -4,6 +4,8 @@ NOFUSS MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: nof
*/ */
#if NOFUSS_SUPPORT #if NOFUSS_SUPPORT
@ -21,31 +23,31 @@ bool _nofussEnabled = false;
#if WEB_SUPPORT #if WEB_SUPPORT
bool _nofussWebSocketOnReceive(const char * key, JsonVariant& value) { bool _nofussWebSocketOnReceive(const char * key, JsonVariant& value) {
return (strncmp(key, "nofuss", 6) == 0);
return (strncmp(key, "nof", 6) == 0);
} }
void _nofussWebSocketOnSend(JsonObject& root) { void _nofussWebSocketOnSend(JsonObject& root) {
root["nofussVisible"] = 1;
root["nofussEnabled"] = getSetting("nofussEnabled", NOFUSS_ENABLED).toInt() == 1;
root["nofussServer"] = getSetting("nofussServer", NOFUSS_SERVER);
root["nofVisible"] = 1;
root["nofEnabled"] = getSetting("nofEnabled", NOFUSS_ENABLED).toInt() == 1;
root["nofServer"] = getSetting("nofServer", NOFUSS_SERVER);
} }
#endif #endif
void _nofussConfigure() { void _nofussConfigure() {
String nofussServer = getSetting("nofussServer", NOFUSS_SERVER);
String nofussServer = getSetting("nofServer", NOFUSS_SERVER);
#if MDNS_CLIENT_SUPPORT #if MDNS_CLIENT_SUPPORT
nofussServer = mdnsResolve(nofussServer); nofussServer = mdnsResolve(nofussServer);
#endif #endif
if (nofussServer.length() == 0) { if (nofussServer.length() == 0) {
setSetting("nofussEnabled", 0);
setSetting("nofEnabled", 0);
_nofussEnabled = false; _nofussEnabled = false;
} else { } else {
_nofussEnabled = getSetting("nofussEnabled", NOFUSS_ENABLED).toInt() == 1;
_nofussEnabled = getSetting("nofEnabled", NOFUSS_ENABLED).toInt() == 1;
} }
_nofussInterval = getSetting("nofussInterval", NOFUSS_INTERVAL).toInt();
_nofussInterval = getSetting("nofInterval", NOFUSS_INTERVAL).toInt();
_nofussLastCheck = 0; _nofussLastCheck = 0;
if (!_nofussEnabled) { if (!_nofussEnabled) {
@ -70,6 +72,12 @@ void _nofussConfigure() {
} }
void _nofussBackwards() {
moveSettings("nofussServer", "nofServer"); // 1.13.1 2018-06-26
moveSettings("nofussEnabled", "nofEnabled"); // 1.13.1 2018-06-26
moveSettings("nofussInterval", "nofInterval"); // 1.13.1 2018-06-26
}
#if TERMINAL_SUPPORT #if TERMINAL_SUPPORT
void _nofussInitCommands() { void _nofussInitCommands() {
@ -92,6 +100,7 @@ void nofussRun() {
void nofussSetup() { void nofussSetup() {
_nofussBackwards();
_nofussConfigure(); _nofussConfigure();
NoFUSSClient.onMessage([](nofuss_t code) { NoFUSSClient.onMessage([](nofuss_t code) {


+ 8
- 0
code/espurna/ntp.ino View File

@ -4,6 +4,8 @@ NTP MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: ntp
*/ */
#if NTP_SUPPORT #if NTP_SUPPORT
@ -115,14 +117,19 @@ void _ntpLoop() {
} }
void _ntpBackwards() { void _ntpBackwards() {
// 1.12.0 - 2018-01-21
moveSetting("ntpServer1", "ntpServer"); moveSetting("ntpServer1", "ntpServer");
delSetting("ntpServer2"); delSetting("ntpServer2");
delSetting("ntpServer3"); delSetting("ntpServer3");
// 1.12.0 - 2018-01-20
int offset = getSetting("ntpOffset", NTP_TIME_OFFSET).toInt(); int offset = getSetting("ntpOffset", NTP_TIME_OFFSET).toInt();
if (-30 < offset && offset < 30) { if (-30 < offset && offset < 30) {
offset *= 60; offset *= 60;
setSetting("ntpOffset", offset); setSetting("ntpOffset", offset);
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -155,6 +162,7 @@ time_t ntpLocal2UTC(time_t local) {
void ntpSetup() { void ntpSetup() {
// Check backwards compatibility
_ntpBackwards(); _ntpBackwards();
NTP.onNTPSyncEvent([](NTPSyncEvent_t error) { NTP.onNTPSyncEvent([](NTPSyncEvent_t error) {


+ 17
- 1
code/espurna/ota.ino View File

@ -4,6 +4,8 @@ OTA MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: ota
*/ */
#include "ArduinoOTA.h" #include "ArduinoOTA.h"
@ -126,7 +128,7 @@ void _otaFrom(const char * host, unsigned int port, const char * url) {
#if ASYNC_TCP_SSL_ENABLED #if ASYNC_TCP_SSL_ENABLED
if (443 == _ota_port) { if (443 == _ota_port) {
uint8_t fp[20] = {0}; uint8_t fp[20] = {0};
sslFingerPrintArray(getSetting("otafp", OTA_GITHUB_FP).c_str(), fp);
sslFingerPrintArray(getSetting("otaFP", OTA_GITHUB_FP).c_str(), fp);
SSL * ssl = _ota_client->getSSL(); SSL * ssl = _ota_client->getSSL();
if (ssl_match_fingerprint(ssl, fp) != SSL_OK) { if (ssl_match_fingerprint(ssl, fp) != SSL_OK) {
DEBUG_MSG_P(PSTR("[OTA] Warning: certificate doesn't match\n")); DEBUG_MSG_P(PSTR("[OTA] Warning: certificate doesn't match\n"));
@ -197,14 +199,28 @@ void _otaInitCommands() {
#endif // TERMINAL_SUPPORT #endif // TERMINAL_SUPPORT
#if WEB_SUPPORT
bool _otaWebSocketOnReceive(const char * key, JsonVariant& value) {
return (strncmp(key, "ota", 3) == 0);
}
#endif // WEB_SUPPORT
void _otaBackwards() {
moveSetting("otafs", "otaFS");
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void otaSetup() { void otaSetup() {
_otaBackwards();
_otaConfigure(); _otaConfigure();
#if WEB_SUPPORT #if WEB_SUPPORT
wsOnAfterParseRegister(_otaConfigure); wsOnAfterParseRegister(_otaConfigure);
wsOnReceiveRegister(_otaWebSocketOnReceive);
#endif #endif
#if TERMINAL_SUPPORT #if TERMINAL_SUPPORT


+ 23
- 15
code/espurna/relay.ino View File

@ -4,6 +4,8 @@ RELAY MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: rly
*/ */
#include <EEPROM_Rotate.h> #include <EEPROM_Rotate.h>
@ -223,8 +225,8 @@ void relayPulse(unsigned char id) {
DEBUG_MSG_P(PSTR("[RELAY] Scheduling relay #%d back in %lums (pulse)\n"), id, ms); DEBUG_MSG_P(PSTR("[RELAY] Scheduling relay #%d back in %lums (pulse)\n"), id, ms);
_relays[id].pulseTicker.once_ms(ms, relayToggle, id); _relays[id].pulseTicker.once_ms(ms, relayToggle, id);
// Reconfigure after dynamic pulse // Reconfigure after dynamic pulse
_relays[id].pulse = getSetting("relayPulse", id, RELAY_PULSE_MODE).toInt();
_relays[id].pulse_ms = 1000 * getSetting("relayTime", id, RELAY_PULSE_MODE).toFloat();
_relays[id].pulse = getSetting("rlyPulse", id, RELAY_PULSE_MODE).toInt();
_relays[id].pulse_ms = 1000 * getSetting("rlyTime", id, RELAY_PULSE_MODE).toFloat();
} }
} }
@ -323,7 +325,7 @@ void relaySync(unsigned char id) {
// Flag sync mode // Flag sync mode
_relayRecursive = true; _relayRecursive = true;
byte relaySync = getSetting("relaySync", RELAY_SYNC).toInt();
byte relaySync = getSetting("rlySync", RELAY_SYNC).toInt();
bool status = _relays[id].target_status; bool status = _relays[id].target_status;
// If RELAY_SYNC_SAME all relays should have the same state // If RELAY_SYNC_SAME all relays should have the same state
@ -415,21 +417,27 @@ unsigned char relayParsePayload(const char * payload) {
// BACKWARDS COMPATIBILITY // BACKWARDS COMPATIBILITY
void _relayBackwards() { void _relayBackwards() {
// 1.11.0 - 2017-12-26
byte relayMode = getSetting("relayMode", RELAY_BOOT_MODE).toInt(); byte relayMode = getSetting("relayMode", RELAY_BOOT_MODE).toInt();
byte relayPulseMode = getSetting("relayPulseMode", RELAY_PULSE_MODE).toInt(); byte relayPulseMode = getSetting("relayPulseMode", RELAY_PULSE_MODE).toInt();
float relayPulseTime = getSetting("relayPulseTime", RELAY_PULSE_TIME).toFloat(); float relayPulseTime = getSetting("relayPulseTime", RELAY_PULSE_TIME).toFloat();
if (relayPulseMode == RELAY_PULSE_NONE) relayPulseTime = 0; if (relayPulseMode == RELAY_PULSE_NONE) relayPulseTime = 0;
for (unsigned int i=0; i<_relays.size(); i++) { for (unsigned int i=0; i<_relays.size(); i++) {
if (!hasSetting("relayBoot", i)) setSetting("relayBoot", i, relayMode);
if (!hasSetting("relayPulse", i)) setSetting("relayPulse", i, relayPulseMode);
if (!hasSetting("relayTime", i)) setSetting("relayTime", i, relayPulseTime);
if (!hasSetting("relayBoot", i)) setSetting("rlyBoot", i, relayMode);
if (!hasSetting("relayPulse", i)) setSetting("rlyPulse", i, relayPulseMode);
if (!hasSetting("relayTime", i)) setSetting("rlyTime", i, relayPulseTime);
} }
delSetting("relayMode"); delSetting("relayMode");
delSetting("relayPulseMode"); delSetting("relayPulseMode");
delSetting("relayPulseTime"); delSetting("relayPulseTime");
// 1.13.1 - 2018-06-26
moveSettings("relayBoot", "rlyBoot");
moveSettings("relayPulse", "rlyPulse");
moveSettings("relayTime", "rlyTime");
moveSetting("relayOnDisc", "rlyOnDisc");
moveSetting("relaySync", "rlySync");
} }
void _relayBoot() { void _relayBoot() {
@ -491,8 +499,8 @@ void _relayConfigure() {
if (_relays[i].type == RELAY_TYPE_LATCHED || _relays[i].type == RELAY_TYPE_LATCHED_INVERSE) { if (_relays[i].type == RELAY_TYPE_LATCHED || _relays[i].type == RELAY_TYPE_LATCHED_INVERSE) {
pinMode(_relays[i].reset_pin, OUTPUT); pinMode(_relays[i].reset_pin, OUTPUT);
} }
_relays[i].pulse = getSetting("relayPulse", i, RELAY_PULSE_MODE).toInt();
_relays[i].pulse_ms = 1000 * getSetting("relayTime", i, RELAY_PULSE_MODE).toFloat();
_relays[i].pulse = getSetting("rlyPulse", i, RELAY_PULSE_MODE).toInt();
_relays[i].pulse_ms = 1000 * getSetting("rlyTime", i, RELAY_PULSE_MODE).toFloat();
} }
} }
@ -533,16 +541,16 @@ void _relayWebSocketOnStart(JsonObject& root) {
#if MQTT_SUPPORT #if MQTT_SUPPORT
line["group"] = getSetting("mqttGroup", i, ""); line["group"] = getSetting("mqttGroup", i, "");
line["group_inv"] = getSetting("mqttGroupInv", i, 0).toInt(); line["group_inv"] = getSetting("mqttGroupInv", i, 0).toInt();
line["on_disc"] = getSetting("relayOnDisc", i, 0).toInt();
line["on_disc"] = getSetting("rlyOnDisc", i, 0).toInt();
#endif #endif
} }
if (relayCount() > 1) { if (relayCount() > 1) {
root["multirelayVisible"] = 1;
root["relaySync"] = getSetting("relaySync", RELAY_SYNC);
root["mrlyVisible"] = 1;
root["rlySync"] = getSetting("rlySync", RELAY_SYNC);
} }
root["relayVisible"] = 1;
root["rlyVisible"] = 1;
} }
@ -812,7 +820,7 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo
if (type == MQTT_DISCONNECT_EVENT) { if (type == MQTT_DISCONNECT_EVENT) {
for (unsigned int i=0; i < _relays.size(); i++){ for (unsigned int i=0; i < _relays.size(); i++){
int reaction = getSetting("relayOnDisc", i, 0).toInt();
int reaction = getSetting("rlyOnDisc", i, 0).toInt();
if (1 == reaction) { // switch relay OFF if (1 == reaction) { // switch relay OFF
DEBUG_MSG_P(PSTR("[RELAY] Reset relay (%d) due to MQTT disconnection\n"), i); DEBUG_MSG_P(PSTR("[RELAY] Reset relay (%d) due to MQTT disconnection\n"), i);
relayStatusWrap(i, false, false); relayStatusWrap(i, false, false);


+ 2
- 0
code/espurna/rf.ino View File

@ -4,6 +4,8 @@ RF MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: rfb (shared with RFBridge)
*/ */
#if RF_SUPPORT #if RF_SUPPORT


+ 3
- 1
code/espurna/rfbridge.ino View File

@ -4,6 +4,8 @@ ITEAD RF BRIDGE MODULE
Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: rfb (shared with RFBridge)
*/ */
#ifdef ITEAD_SONOFF_RFBRIDGE #ifdef ITEAD_SONOFF_RFBRIDGE
@ -306,7 +308,7 @@ void _rfbDecode() {
_rfbToChar(&_uartbuf[1], buffer); _rfbToChar(&_uartbuf[1], buffer);
/* Look for the code, possibly replacing the code with the exact learned one on match /* Look for the code, possibly replacing the code with the exact learned one on match
* we want to do this on learn too to be sure that the learned code is the same if it
* we want to do this on learn too to be sure that the learned code is the same if it
* is equivalent * is equivalent
*/ */
DEBUG_MSG_P(PSTR("[RFBRIDGE] Received message '%s'\n"), buffer); DEBUG_MSG_P(PSTR("[RFBRIDGE] Received message '%s'\n"), buffer);


+ 2
- 0
code/espurna/scheduler.ino View File

@ -5,6 +5,8 @@ SCHEDULER MODULE
Copyright (C) 2017 by faina09 Copyright (C) 2017 by faina09
Adapted by Xose Pérez <xose dot perez at gmail dot com> Adapted by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: sch
*/ */
#if SCHEDULER_SUPPORT #if SCHEDULER_SUPPORT


+ 77
- 58
code/espurna/sensor.ino View File

@ -4,6 +4,8 @@ SENSOR MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: sns pwr ene cur vol tmp hum
*/ */
#if SENSOR_SUPPORT #if SENSOR_SUPPORT
@ -96,11 +98,13 @@ double _magnitudeProcess(unsigned char type, double value) {
#if WEB_SUPPORT #if WEB_SUPPORT
bool _sensorWebSocketOnReceive(const char * key, JsonVariant& value) { bool _sensorWebSocketOnReceive(const char * key, JsonVariant& value) {
if (strncmp(key, "pwr", 3) == 0) return true;
if (strncmp(key, "sns", 3) == 0) return true; if (strncmp(key, "sns", 3) == 0) return true;
if (strncmp(key, "pwr", 3) == 0) return true;
if (strncmp(key, "ene", 3) == 0) return true;
if (strncmp(key, "cur", 3) == 0) return true;
if (strncmp(key, "vol", 3) == 0) return true;
if (strncmp(key, "tmp", 3) == 0) return true; if (strncmp(key, "tmp", 3) == 0) return true;
if (strncmp(key, "hum", 3) == 0) return true; if (strncmp(key, "hum", 3) == 0) return true;
if (strncmp(key, "energy", 6) == 0) return true;
return false; return false;
} }
@ -136,8 +140,8 @@ void _sensorWebSocketSendData(JsonObject& root) {
} }
if (hasTemperature) root["temperatureVisible"] = 1;
if (hasHumidity) root["humidityVisible"] = 1;
if (hasTemperature) root["tmpVisible"] = 1;
if (hasHumidity) root["humVisible"] = 1;
} }
@ -151,7 +155,7 @@ void _sensorWebSocketStart(JsonObject& root) {
if (sensor->getID() == SENSOR_EMON_ANALOG_ID) { if (sensor->getID() == SENSOR_EMON_ANALOG_ID) {
root["emonVisible"] = 1; root["emonVisible"] = 1;
root["pwrVisible"] = 1; root["pwrVisible"] = 1;
root["pwrVoltage"] = ((EmonAnalogSensor *) sensor)->getVoltage();
root["volNominal"] = ((EmonAnalogSensor *) sensor)->getVoltage();
} }
#endif #endif
@ -191,13 +195,12 @@ void _sensorWebSocketStart(JsonObject& root) {
} }
if (_magnitudes.size() > 0) { if (_magnitudes.size() > 0) {
root["sensorsVisible"] = 1;
//root["apiRealTime"] = _sensor_realtime;
root["snsVisible"] = 1;
root["pwrUnits"] = _sensor_power_units; root["pwrUnits"] = _sensor_power_units;
root["energyUnits"] = _sensor_energy_units;
root["eneUnits"] = _sensor_energy_units;
root["tmpUnits"] = _sensor_temperature_units; root["tmpUnits"] = _sensor_temperature_units;
root["tmpCorrection"] = _sensor_temperature_correction;
root["humCorrection"] = _sensor_humidity_correction;
root["tmpOffset"] = _sensor_temperature_correction;
root["humOffset"] = _sensor_humidity_correction;
root["snsRead"] = _sensor_read_interval / 1000; root["snsRead"] = _sensor_read_interval / 1000;
root["snsReport"] = _sensor_report_every; root["snsReport"] = _sensor_report_every;
} }
@ -630,8 +633,8 @@ void _sensorInit() {
if (_sensors[i]->getID() == SENSOR_EMON_ANALOG_ID) { if (_sensors[i]->getID() == SENSOR_EMON_ANALOG_ID) {
EmonAnalogSensor * sensor = (EmonAnalogSensor *) _sensors[i]; EmonAnalogSensor * sensor = (EmonAnalogSensor *) _sensors[i];
sensor->setCurrentRatio(0, getSetting("pwrRatioC", EMON_CURRENT_RATIO).toFloat());
sensor->setVoltage(getSetting("pwrVoltage", EMON_MAINS_VOLTAGE).toInt());
sensor->setCurrentRatio(0, getSetting("curRatio", EMON_CURRENT_RATIO).toFloat());
sensor->setVoltage(getSetting("volNominal", EMON_MAINS_VOLTAGE).toInt());
} }
#endif // EMON_ANALOG_SUPPORT #endif // EMON_ANALOG_SUPPORT
@ -644,13 +647,13 @@ void _sensorInit() {
double value; double value;
value = getSetting("pwrRatioC", HLW8012_CURRENT_RATIO).toFloat();
value = getSetting("curRatio", HLW8012_CURRENT_RATIO).toFloat();
if (value > 0) sensor->setCurrentRatio(value); if (value > 0) sensor->setCurrentRatio(value);
value = getSetting("pwrRatioV", HLW8012_VOLTAGE_RATIO).toFloat();
value = getSetting("volRatio", HLW8012_VOLTAGE_RATIO).toFloat();
if (value > 0) sensor->setVoltageRatio(value); if (value > 0) sensor->setVoltageRatio(value);
value = getSetting("pwrRatioP", HLW8012_POWER_RATIO).toFloat();
value = getSetting("pwrRatio", HLW8012_POWER_RATIO).toFloat();
if (value > 0) sensor->setPowerRatio(value); if (value > 0) sensor->setPowerRatio(value);
} }
@ -665,13 +668,13 @@ void _sensorInit() {
double value; double value;
value = getSetting("pwrRatioC", 0).toFloat();
value = getSetting("curRatio", 0).toFloat();
if (value > 0) sensor->setCurrentRatio(value); if (value > 0) sensor->setCurrentRatio(value);
value = getSetting("pwrRatioV", 0).toFloat();
value = getSetting("volRatio", 0).toFloat();
if (value > 0) sensor->setVoltageRatio(value); if (value > 0) sensor->setVoltageRatio(value);
value = getSetting("pwrRatioP", 0).toFloat();
value = getSetting("pwrRatio", 0).toFloat();
if (value > 0) sensor->setPowerRatio(value); if (value > 0) sensor->setPowerRatio(value);
} }
@ -687,12 +690,12 @@ void _sensorConfigure() {
// General sensor settings // General sensor settings
_sensor_read_interval = 1000 * constrain(getSetting("snsRead", SENSOR_READ_INTERVAL).toInt(), SENSOR_READ_MIN_INTERVAL, SENSOR_READ_MAX_INTERVAL); _sensor_read_interval = 1000 * constrain(getSetting("snsRead", SENSOR_READ_INTERVAL).toInt(), SENSOR_READ_MIN_INTERVAL, SENSOR_READ_MAX_INTERVAL);
_sensor_report_every = constrain(getSetting("snsReport", SENSOR_REPORT_EVERY).toInt(), SENSOR_REPORT_MIN_EVERY, SENSOR_REPORT_MAX_EVERY); _sensor_report_every = constrain(getSetting("snsReport", SENSOR_REPORT_EVERY).toInt(), SENSOR_REPORT_MIN_EVERY, SENSOR_REPORT_MAX_EVERY);
_sensor_realtime = getSetting("apiRealTime", API_REAL_TIME_VALUES).toInt() == 1;
_sensor_realtime = apiRealTime();
_sensor_power_units = getSetting("pwrUnits", SENSOR_POWER_UNITS).toInt(); _sensor_power_units = getSetting("pwrUnits", SENSOR_POWER_UNITS).toInt();
_sensor_energy_units = getSetting("energyUnits", SENSOR_ENERGY_UNITS).toInt();
_sensor_energy_units = getSetting("eneUnits", SENSOR_ENERGY_UNITS).toInt();
_sensor_temperature_units = getSetting("tmpUnits", SENSOR_TEMPERATURE_UNITS).toInt(); _sensor_temperature_units = getSetting("tmpUnits", SENSOR_TEMPERATURE_UNITS).toInt();
_sensor_temperature_correction = getSetting("tmpCorrection", SENSOR_TEMPERATURE_CORRECTION).toFloat();
_sensor_humidity_correction = getSetting("humCorrection", SENSOR_HUMIDITY_CORRECTION).toFloat();
_sensor_temperature_correction = getSetting("tmpOffset", SENSOR_TEMPERATURE_CORRECTION).toFloat();
_sensor_humidity_correction = getSetting("humOffset", SENSOR_HUMIDITY_CORRECTION).toFloat();
// Specific sensor settings // Specific sensor settings
for (unsigned char i=0; i<_sensors.size(); i++) { for (unsigned char i=0; i<_sensors.size(); i++) {
@ -704,22 +707,22 @@ void _sensorConfigure() {
double value; double value;
EmonAnalogSensor * sensor = (EmonAnalogSensor *) _sensors[i]; EmonAnalogSensor * sensor = (EmonAnalogSensor *) _sensors[i];
if (value = getSetting("pwrExpectedP", 0).toInt()) {
if (value = getSetting("pwrExpected", 0).toInt()) {
sensor->expectedPower(0, value); sensor->expectedPower(0, value);
setSetting("pwrRatioC", sensor->getCurrentRatio(0));
setSetting("curRatio", sensor->getCurrentRatio(0));
} }
if (getSetting("pwrResetCalibration", 0).toInt() == 1) {
if (getSetting("snsResetCalibrarion", 0).toInt() == 1) {
sensor->setCurrentRatio(0, EMON_CURRENT_RATIO); sensor->setCurrentRatio(0, EMON_CURRENT_RATIO);
delSetting("pwrRatioC");
delSetting("curRatio");
} }
if (getSetting("pwrResetE", 0).toInt() == 1) {
if (getSetting("eneReset", 0).toInt() == 1) {
sensor->resetEnergy(); sensor->resetEnergy();
_sensorReset(); _sensorReset();
} }
sensor->setVoltage(getSetting("pwrVoltage", EMON_MAINS_VOLTAGE).toInt());
sensor->setVoltage(getSetting("volNominal", EMON_MAINS_VOLTAGE).toInt());
} }
@ -728,7 +731,7 @@ void _sensorConfigure() {
#if EMON_ADC121_SUPPORT #if EMON_ADC121_SUPPORT
if (_sensors[i]->getID() == SENSOR_EMON_ADC121_ID) { if (_sensors[i]->getID() == SENSOR_EMON_ADC121_ID) {
EmonADC121Sensor * sensor = (EmonADC121Sensor *) _sensors[i]; EmonADC121Sensor * sensor = (EmonADC121Sensor *) _sensors[i];
if (getSetting("pwrResetE", 0).toInt() == 1) {
if (getSetting("eneReset", 0).toInt() == 1) {
sensor->resetEnergy(); sensor->resetEnergy();
_sensorReset(); _sensorReset();
} }
@ -738,7 +741,7 @@ void _sensorConfigure() {
#if EMON_ADS1X15_SUPPORT #if EMON_ADS1X15_SUPPORT
if (_sensors[i]->getID() == SENSOR_EMON_ADS1X15_ID) { if (_sensors[i]->getID() == SENSOR_EMON_ADS1X15_ID) {
EmonADS1X15Sensor * sensor = (EmonADS1X15Sensor *) _sensors[i]; EmonADS1X15Sensor * sensor = (EmonADS1X15Sensor *) _sensors[i];
if (getSetting("pwrResetE", 0).toInt() == 1) {
if (getSetting("eneReset", 0).toInt() == 1) {
sensor->resetEnergy(); sensor->resetEnergy();
_sensorReset(); _sensorReset();
} }
@ -753,31 +756,31 @@ void _sensorConfigure() {
double value; double value;
HLW8012Sensor * sensor = (HLW8012Sensor *) _sensors[i]; HLW8012Sensor * sensor = (HLW8012Sensor *) _sensors[i];
if (value = getSetting("pwrExpectedC", 0).toFloat()) {
if (value = getSetting("curExpected", 0).toFloat()) {
sensor->expectedCurrent(value); sensor->expectedCurrent(value);
setSetting("pwrRatioC", sensor->getCurrentRatio());
setSetting("curRatio", sensor->getCurrentRatio());
} }
if (value = getSetting("pwrExpectedV", 0).toInt()) {
if (value = getSetting("volExpected", 0).toInt()) {
sensor->expectedVoltage(value); sensor->expectedVoltage(value);
setSetting("pwrRatioV", sensor->getVoltageRatio());
setSetting("volRatio", sensor->getVoltageRatio());
} }
if (value = getSetting("pwrExpectedP", 0).toInt()) {
if (value = getSetting("pwrExpected", 0).toInt()) {
sensor->expectedPower(value); sensor->expectedPower(value);
setSetting("pwrRatioP", sensor->getPowerRatio());
setSetting("pwrRatio", sensor->getPowerRatio());
} }
if (getSetting("pwrResetE", 0).toInt() == 1) {
if (getSetting("eneReset", 0).toInt() == 1) {
sensor->resetEnergy(); sensor->resetEnergy();
_sensorReset(); _sensorReset();
} }
if (getSetting("pwrResetCalibration", 0).toInt() == 1) {
if (getSetting("snsResetCalibrarion", 0).toInt() == 1) {
sensor->resetRatios(); sensor->resetRatios();
delSetting("pwrRatioC");
delSetting("pwrRatioV");
delSetting("pwrRatioP");
delSetting("curRatio");
delSetting("volRatio");
delSetting("pwrRatio");
} }
} }
@ -791,31 +794,31 @@ void _sensorConfigure() {
double value; double value;
CSE7766Sensor * sensor = (CSE7766Sensor *) _sensors[i]; CSE7766Sensor * sensor = (CSE7766Sensor *) _sensors[i];
if (value = getSetting("pwrExpectedC", 0).toFloat()) {
if (value = getSetting("curExpected", 0).toFloat()) {
sensor->expectedCurrent(value); sensor->expectedCurrent(value);
setSetting("pwrRatioC", sensor->getCurrentRatio());
setSetting("curRatio", sensor->getCurrentRatio());
} }
if (value = getSetting("pwrExpectedV", 0).toInt()) {
if (value = getSetting("volExpected", 0).toInt()) {
sensor->expectedVoltage(value); sensor->expectedVoltage(value);
setSetting("pwrRatioV", sensor->getVoltageRatio());
setSetting("volRatio", sensor->getVoltageRatio());
} }
if (value = getSetting("pwrExpectedP", 0).toInt()) {
if (value = getSetting("pwrExpected", 0).toInt()) {
sensor->expectedPower(value); sensor->expectedPower(value);
setSetting("pwrRatioP", sensor->getPowerRatio());
setSetting("pwrRatio", sensor->getPowerRatio());
} }
if (getSetting("pwrResetE", 0).toInt() == 1) {
if (getSetting("eneReset", 0).toInt() == 1) {
sensor->resetEnergy(); sensor->resetEnergy();
_sensorReset(); _sensorReset();
} }
if (getSetting("pwrResetCalibration", 0).toInt() == 1) {
if (getSetting("snsResetCalibrarion", 0).toInt() == 1) {
sensor->resetRatios(); sensor->resetRatios();
delSetting("pwrRatioC");
delSetting("pwrRatioV");
delSetting("pwrRatioP");
delSetting("curRatio");
delSetting("volRatio");
delSetting("pwrRatio");
} }
} }
@ -830,15 +833,31 @@ void _sensorConfigure() {
} }
// Save settings // Save settings
delSetting("pwrExpectedP");
delSetting("pwrExpectedC");
delSetting("pwrExpectedV");
delSetting("pwrResetCalibration");
delSetting("pwrResetE");
delSetting("pwrExpected");
delSetting("curExpected");
delSetting("volExpected");
delSetting("snsResetCalibrarion");
delSetting("eneReset");
saveSettings(); saveSettings();
} }
void _sensorBackwards() {
moveSetting("powerUnits", "pwrUnits"); // 1.12.5 - 2018-04-03
moveSetting("tmpCorrection", "tmpOffset"); // 1.13.1 - 2018-06-26
moveSetting("humCorrection", "humOffset"); // 1.13.1 - 2018-06-26
moveSetting("energyUnits", "eneUnits"); // 1.13.1 - 2018-06-26
moveSetting("pwrRatioC", "curRatio"); // 1.13.1 - 2018-06-26
moveSetting("pwrRatioP", "pwrRatio"); // 1.13.1 - 2018-06-26
moveSetting("pwrRatioV", "volRatio"); // 1.13.1 - 2018-06-26
moveSetting("pwrVoltage", "volNominal"); // 1.13.1 - 2018-06-26
moveSetting("pwrExpectedP", "pwrExpected"); // 1.13.1 - 2018-06-26
moveSetting("pwrExpectedC", "curExpected"); // 1.13.1 - 2018-06-26
moveSetting("pwrExpectedV", "volExpected"); // 1.13.1 - 2018-06-26
moveSetting("pwrResetCalibration", "snsResetCalibration"); // 1.13.1 - 2018-06-26
moveSetting("pwrResetE", "eneReset"); // 1.13.1 - 2018-06-26
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Public // Public
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -918,7 +937,7 @@ String magnitudeUnits(unsigned char type) {
void sensorSetup() { void sensorSetup() {
// Backwards compatibility // Backwards compatibility
moveSetting("powerUnits", "pwrUnits");
_sensorBackwards();
// Load sensors // Load sensors
_sensorLoad(); _sensorLoad();


+ 19
- 0
code/espurna/settings.ino View File

@ -4,6 +4,8 @@ SETTINGS MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: cfg
*/ */
#include <EEPROM_Rotate.h> #include <EEPROM_Rotate.h>
@ -306,6 +308,23 @@ void moveSetting(const char * from, const char * to) {
delSetting(from); delSetting(from);
} }
void moveSetting(const char * from, const char * to, unsigned int index) {
String value = getSetting(from, index, "");
if (value.length() > 0) setSetting(to, index, value);
delSetting(from, index);
}
void moveSettings(const char * from, const char * to) {
unsigned int index = 0;
while (index < 100) {
String value = getSetting(from, index, "");
if (value.length() == 0) break;
setSetting(to, index, value);
delSetting(from, index);
index++;
}
}
template<typename T> String getSetting(const String& key, T defaultValue) { template<typename T> String getSetting(const String& key, T defaultValue) {
String value; String value;
if (!Embedis::get(key, value)) value = String(defaultValue); if (!Embedis::get(key, value)) value = String(defaultValue);


+ 2
- 0
code/espurna/ssdp.ino View File

@ -6,6 +6,8 @@ Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com>
Uses SSDP library by PawelDino (https://github.com/PawelDino) Uses SSDP library by PawelDino (https://github.com/PawelDino)
https://github.com/esp8266/Arduino/issues/2283#issuecomment-299635604 https://github.com/esp8266/Arduino/issues/2283#issuecomment-299635604
Module key prefix: ssdp
*/ */
#if SSDP_SUPPORT #if SSDP_SUPPORT


+ 2
- 0
code/espurna/system.ino View File

@ -4,6 +4,8 @@ SYSTEM MODULE
Copyright (C) 2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: esp (shared with others)
*/ */
#include <EEPROM_Rotate.h> #include <EEPROM_Rotate.h>


+ 13
- 4
code/espurna/telnet.ino View File

@ -6,6 +6,8 @@ Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com>
Parts of the code have been borrowed from Thomas Sarlandie's NetServer Parts of the code have been borrowed from Thomas Sarlandie's NetServer
(https://github.com/sarfata/kbox-firmware/tree/master/src/esp) (https://github.com/sarfata/kbox-firmware/tree/master/src/esp)
Module key prefix: tel
*/ */
#if TELNET_SUPPORT #if TELNET_SUPPORT
@ -23,12 +25,12 @@ bool _telnetFirst = true;
#if WEB_SUPPORT #if WEB_SUPPORT
bool _telnetWebSocketOnReceive(const char * key, JsonVariant& value) { bool _telnetWebSocketOnReceive(const char * key, JsonVariant& value) {
return (strncmp(key, "telnet", 6) == 0);
return (strncmp(key, "telt", 3) == 0);
} }
void _telnetWebSocketOnSend(JsonObject& root) { void _telnetWebSocketOnSend(JsonObject& root) {
root["telnetVisible"] = 1;
root["telnetSTA"] = getSetting("telnetSTA", TELNET_STA).toInt() == 1;
root["telVisible"] = 1;
root["telSTA"] = getSetting("telSTA", TELNET_STA).toInt() == 1;
} }
#endif #endif
@ -93,7 +95,7 @@ void _telnetNewClient(AsyncClient *client) {
#ifdef ESPURNA_CORE #ifdef ESPURNA_CORE
bool telnetSTA = true; bool telnetSTA = true;
#else #else
bool telnetSTA = getSetting("telnetSTA", TELNET_STA).toInt() == 1;
bool telnetSTA = getSetting("telSTA", TELNET_STA).toInt() == 1;
#endif #endif
if (!telnetSTA) { if (!telnetSTA) {
@ -160,6 +162,10 @@ void _telnetNewClient(AsyncClient *client) {
} }
void _telnetBackwards() {
moveSetting("telnetSTA", "telSTA"); // 1.13.1 -- 2018-06-26
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Public API // Public API
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -178,6 +184,9 @@ unsigned char telnetWrite(unsigned char ch) {
void telnetSetup() { void telnetSetup() {
// Backwards compatibility
_telnetBackwards();
_telnetServer = new AsyncServer(TELNET_PORT); _telnetServer = new AsyncServer(TELNET_PORT);
_telnetServer->onClient([](void *s, AsyncClient* c) { _telnetServer->onClient([](void *s, AsyncClient* c) {
_telnetNewClient(c); _telnetNewClient(c);


+ 2
- 0
code/espurna/thinkspeak.ino View File

@ -4,6 +4,8 @@ THINGSPEAK MODULE
Copyright (C) 2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: tspk
*/ */
#if THINGSPEAK_SUPPORT #if THINGSPEAK_SUPPORT


+ 2
- 0
code/espurna/uartmqtt.ino View File

@ -5,6 +5,8 @@ UART_MQTT MODULE
Copyright (C) 2018 by Albert Weterings Copyright (C) 2018 by Albert Weterings
Adapted by Xose Pérez <xose dot perez at gmail dot com> Adapted by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: u2m
*/ */
#if UART_MQTT_SUPPORT #if UART_MQTT_SUPPORT


+ 2
- 0
code/espurna/utils.ino View File

@ -4,6 +4,8 @@ UTILS MODULE
Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: esp (shared with others)
*/ */
#include <Ticker.h> #include <Ticker.h>


+ 2
- 0
code/espurna/web.ino View File

@ -4,6 +4,8 @@ WEBSERVER MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: web
*/ */
#if WEB_SUPPORT #if WEB_SUPPORT


+ 2
- 0
code/espurna/wifi.ino View File

@ -4,6 +4,8 @@ WIFI MODULE
Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com> Copyright (C) 2016-2018 by Xose Pérez <xose dot perez at gmail dot com>
Module key prefix: wifi
*/ */
#include "JustWifi.h" #include "JustWifi.h"


+ 14
- 14
code/html/custom.js View File

@ -12,8 +12,8 @@ var numReboot = 0;
var numReconnect = 0; var numReconnect = 0;
var numReload = 0; var numReload = 0;
var useWhite = false;
var useCCT = false;
var litWhite = false;
var litCCT = false;
var now = 0; var now = 0;
var ago = 0; var ago = 0;
@ -201,8 +201,8 @@ function addValue(data, name, value) {
var is_group = [ var is_group = [
"ssid", "pass", "gw", "mask", "ip", "dns", "ssid", "pass", "gw", "mask", "ip", "dns",
"schEnabled", "schSwitch","schAction","schType","schHour","schMinute","schWDs","schUTC", "schEnabled", "schSwitch","schAction","schType","schHour","schMinute","schWDs","schUTC",
"relayBoot", "relayPulse", "relayTime",
"mqttGroup", "mqttGroupInv", "relayOnDisc",
"rlyBoot", "rlyPulse", "rlyTime",
"mqttGroup", "mqttGroupInv", "rlyOnDisc",
"dczRelayIdx", "dczMagnitude", "dczRelayIdx", "dczMagnitude",
"tspkRelay", "tspkMagnitude", "tspkRelay", "tspkMagnitude",
"ledMode", "ledMode",
@ -802,12 +802,12 @@ function initRelayConfig(data) {
var line = $(template).clone(); var line = $(template).clone();
$("span.gpio", line).html(relay.gpio); $("span.gpio", line).html(relay.gpio);
$("span.id", line).html(i); $("span.id", line).html(i);
$("select[name='relayBoot']", line).val(relay.boot);
$("select[name='relayPulse']", line).val(relay.pulse);
$("input[name='relayTime']", line).val(relay.pulse_ms);
$("select[name='rlyBoot']", line).val(relay.boot);
$("select[name='rlyPulse']", line).val(relay.pulse);
$("input[name='rlyTime']", line).val(relay.pulse_ms);
$("input[name='mqttGroup']", line).val(relay.group); $("input[name='mqttGroup']", line).val(relay.group);
$("select[name='mqttGroupInv']", line).val(relay.group_inv); $("select[name='mqttGroupInv']", line).val(relay.group_inv);
$("select[name='relayOnDisc']", line).val(relay.on_disc);
$("select[name='rlyOnDisc']", line).val(relay.on_disc);
line.appendTo("#relayConfig"); line.appendTo("#relayConfig");
} }
@ -924,9 +924,9 @@ function initChannels(num) {
var max = num; var max = num;
if (colors) { if (colors) {
max = num % 3; max = num % 3;
if ((max > 0) & useWhite) {
if ((max > 0) & litWhite) {
max--; max--;
if (useCCT) {
if (litCCT) {
max--; max--;
} }
} }
@ -1125,13 +1125,13 @@ function processData(data) {
return; return;
} }
if ("useWhite" === key) {
useWhite = value;
if ("litWhite" === key) {
litWhite = value;
} }
if ("useCCT" === key) {
if ("litCCT" === key) {
initCCT(); initCCT();
useCCT = value;
litCCT = value;
} }
<!-- endRemoveIf(!light)--> <!-- endRemoveIf(!light)-->


+ 49
- 49
code/html/index.html View File

@ -100,7 +100,7 @@
</li> </li>
<!-- removeIf(!light)--> <!-- removeIf(!light)-->
<li class="pure-menu-item module module-color">
<li class="pure-menu-item module module-lit">
<a href="#" class="pure-menu-link" data="panel-color">LIGHTS</a> <a href="#" class="pure-menu-link" data="panel-color">LIGHTS</a>
</li> </li>
<!-- endRemoveIf(!light)--> <!-- endRemoveIf(!light)-->
@ -124,12 +124,12 @@
</li> </li>
<!-- removeIf(!sensor)--> <!-- removeIf(!sensor)-->
<li class="pure-menu-item module module-sensors">
<li class="pure-menu-item module module-sns">
<a href="#" class="pure-menu-link" data="panel-sensors">SENSORS</a> <a href="#" class="pure-menu-link" data="panel-sensors">SENSORS</a>
</li> </li>
<!-- endRemoveIf(!sensor)--> <!-- endRemoveIf(!sensor)-->
<li class="pure-menu-item module module-relay">
<li class="pure-menu-item module module-rly">
<a href="#" class="pure-menu-link" data="panel-relay">SWITCHES</a> <a href="#" class="pure-menu-link" data="panel-relay">SWITCHES</a>
</li> </li>
@ -350,9 +350,9 @@
</div> </div>
</div> </div>
<div class="pure-g module module-alexa">
<div class="pure-g module module-alx">
<label class="pure-u-1 pure-u-lg-1-4">Alexa integration</label> <label class="pure-u-1 pure-u-lg-1-4">Alexa integration</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="alexaEnabled" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="alxEnabled" /></div>
</div> </div>
</fieldset> </fieldset>
@ -370,11 +370,11 @@
<fieldset> <fieldset>
<legend class="module module-multirelay">General</legend>
<legend class="module module-mrly">General</legend>
<div class="pure-g module module-multirelay">
<div class="pure-g module module-mrly">
<label class="pure-u-1 pure-u-lg-1-4">Switch sync mode</label> <label class="pure-u-1 pure-u-lg-1-4">Switch sync mode</label>
<select name="relaySync" class="pure-u-1 pure-u-lg-3-4" tabindex="3">
<select name="rlySync" class="pure-u-1 pure-u-lg-3-4" tabindex="3">
<option value="0">No synchronisation</option> <option value="0">No synchronisation</option>
<option value="1">Zero or one switches active</option> <option value="1">Zero or one switches active</option>
<option value="2">One and just one switch active</option> <option value="2">One and just one switch active</option>
@ -405,7 +405,7 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Use color</label> <label class="pure-u-1 pure-u-lg-1-4">Use color</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="useColor" action="reload" tabindex="8" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="litColor" action="reload" tabindex="8" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Use the first three channels as RGB channels. This will also enable the color picker in the web UI. Will only work if the device has at least 3 dimmable channels.<br />Reload the page to update the web interface.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">Use the first three channels as RGB channels. This will also enable the color picker in the web UI. Will only work if the device has at least 3 dimmable channels.<br />Reload the page to update the web interface.</div>
@ -413,7 +413,7 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Use RGB picker</label> <label class="pure-u-1 pure-u-lg-1-4">Use RGB picker</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="useRGB" action="reload" tabindex="11" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="litRGB" action="reload" tabindex="11" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Use RGB color picker if enabled (plus brightness), otherwise use HSV (hue-saturation-value) style</div> <div class="pure-u-1 pure-u-lg-3-4 hint">Use RGB color picker if enabled (plus brightness), otherwise use HSV (hue-saturation-value) style</div>
@ -421,7 +421,7 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Use white channel</label> <label class="pure-u-1 pure-u-lg-1-4">Use white channel</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="useWhite" action="reload" tabindex="9" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="litWhite" action="reload" tabindex="9" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Use forth dimmable channel as (cold) white light calculated out of the RGB values.<br />Will only work if the device has at least 4 dimmable channels.<br />Enabling this will render useless the "Channel 4" slider in the status page.<br />Reload the page to update the web interface.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">Use forth dimmable channel as (cold) white light calculated out of the RGB values.<br />Will only work if the device has at least 4 dimmable channels.<br />Enabling this will render useless the "Channel 4" slider in the status page.<br />Reload the page to update the web interface.</div>
@ -429,7 +429,7 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Use white color temperature</label> <label class="pure-u-1 pure-u-lg-1-4">Use white color temperature</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="useCCT" action="reload" tabindex="10" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="litCCT" action="reload" tabindex="10" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Use fifth dimmable channel as warm white light and the forth dimmable channel as cold white.<br />Will only work if the device has at least 5 dimmable channels and "white channel" above is also ON.<br />Enabling this will render useless the "Channel 5" slider in the status page.<br />Reload the page to update the web interface.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">Use fifth dimmable channel as warm white light and the forth dimmable channel as cold white.<br />Will only work if the device has at least 5 dimmable channels and "white channel" above is also ON.<br />Enabling this will render useless the "Channel 5" slider in the status page.<br />Reload the page to update the web interface.</div>
@ -437,7 +437,7 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Use gamma correction</label> <label class="pure-u-1 pure-u-lg-1-4">Use gamma correction</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="useGamma" tabindex="11" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="litGamma" tabindex="11" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Use gamma correction for RGB channels.<br />Will only work if "use colorpicker" above is also ON.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">Use gamma correction for RGB channels.<br />Will only work if "use colorpicker" above is also ON.</div>
@ -445,7 +445,7 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Use CSS style</label> <label class="pure-u-1 pure-u-lg-1-4">Use CSS style</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="useCSS" tabindex="12" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="litCSS" tabindex="12" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Use CSS style to report colors to MQTT and REST API. <br />Red will be reported as "#FF0000" if ON, otherwise "255,0,0"</div> <div class="pure-u-1 pure-u-lg-3-4 hint">Use CSS style to report colors to MQTT and REST API. <br />Red will be reported as "#FF0000" if ON, otherwise "255,0,0"</div>
@ -453,7 +453,7 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Color transitions</label> <label class="pure-u-1 pure-u-lg-1-4">Color transitions</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="useTransitions" tabindex="13" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="litTrans" tabindex="13" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">If enabled color changes will be smoothed.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">If enabled color changes will be smoothed.</div>
@ -461,7 +461,7 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Transition time</label> <label class="pure-u-1 pure-u-lg-1-4">Transition time</label>
<div class="pure-u-1 pure-u-lg-1-4"><input class="pure-u-1" type="number" name="lightTime" min="10" max="5000" tabindex="14" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input class="pure-u-1" type="number" name="litTime" min="10" max="5000" tabindex="14" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Time in millisecons to transition from one color to another.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">Time in millisecons to transition from one color to another.</div>
@ -555,23 +555,23 @@
</div> </div>
</div> </div>
<div class="pure-g module module-telnet">
<div class="pure-g module module-tel">
<label class="pure-u-1 pure-u-lg-1-4">Enable TELNET</label> <label class="pure-u-1 pure-u-lg-1-4">Enable TELNET</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="telnetSTA" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="telSTA" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Turn ON to be able to telnet to your device while connected to your home router.<br />TELNET is always enabled in AP mode.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">Turn ON to be able to telnet to your device while connected to your home router.<br />TELNET is always enabled in AP mode.</div>
</div> </div>
<div class="pure-g module module-nofuss">
<div class="pure-g module module-nof">
<label class="pure-u-1 pure-u-lg-1-4">Automatic remote updates (NoFUSS)</label> <label class="pure-u-1 pure-u-lg-1-4">Automatic remote updates (NoFUSS)</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="nofussEnabled" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="nofEnabled" /></div>
</div> </div>
<div class="pure-g module module-nofuss">
<div class="pure-g module module-nof">
<label class="pure-u-1 pure-u-lg-1-4">NoFUSS server</label> <label class="pure-u-1 pure-u-lg-1-4">NoFUSS server</label>
<input name="nofussServer" class="pure-u-1 pure-u-lg-3-4" type="text" tabindex="15" />
<input name="nofServer" class="pure-u-1 pure-u-lg-3-4" type="text" tabindex="15" />
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">This name address of the NoFUSS server for automatic remote updates (see https://bitbucket.org/xoseperez/nofuss).</div> <div class="pure-u-1 pure-u-lg-3-4 hint">This name address of the NoFUSS server for automatic remote updates (see https://bitbucket.org/xoseperez/nofuss).</div>
</div> </div>
@ -648,9 +648,9 @@
<div id="schedules"></div> <div id="schedules"></div>
<button type="button" class="pure-button button-add-switch-schedule module module-relay">Add switch schedule</button>
<button type="button" class="pure-button button-add-switch-schedule module module-rly">Add switch schedule</button>
<!-- removeIf(!light)--> <!-- removeIf(!light)-->
<button type="button" class="pure-button button-add-light-schedule module module-color">Add channel schedule</button>
<button type="button" class="pure-button button-add-light-schedule module module-lit">Add channel schedule</button>
<!-- endRemoveIf(!light)--> <!-- endRemoveIf(!light)-->
</fieldset> </fieldset>
@ -692,7 +692,7 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">MQTT Password</label> <label class="pure-u-1 pure-u-lg-1-4">MQTT Password</label>
<input class="pure-u-1 pure-u-lg-1-4" name="mqttPassword" type="password" tabindex="24" placeholder="Leave blank if no pass" autocomplete="false" />
<input class="pure-u-1 pure-u-lg-1-4" name="mqttPass" type="password" tabindex="24" placeholder="Leave blank if no pass" autocomplete="false" />
</div> </div>
<div class="pure-g"> <div class="pure-g">
@ -749,11 +749,11 @@
This is the root topic for this device. The {hostname} and {mac} placeholders will be replaced by the device hostname and MAC address.<br /> This is the root topic for this device. The {hostname} and {mac} placeholders will be replaced by the device hostname and MAC address.<br />
- <strong>&lt;root&gt;/relay/#/set</strong> Send a 0 or a 1 as a payload to this topic to switch it on or off. You can also send a 2 to toggle its current state. Replace # with the switch ID (starting from 0). If the board has only one switch it will be 0.<br /> - <strong>&lt;root&gt;/relay/#/set</strong> Send a 0 or a 1 as a payload to this topic to switch it on or off. You can also send a 2 to toggle its current state. Replace # with the switch ID (starting from 0). If the board has only one switch it will be 0.<br />
<!-- removeIf(!light)--> <!-- removeIf(!light)-->
<span class="module module-color">- <strong>&lt;root&gt;/rgb/set</strong> Set the color using this topic, your can either send an "#RRGGBB" value or "RRR,GGG,BBB" (0-255 each).<br /></span>
<span class="module module-color">- <strong>&lt;root&gt;/hsv/set</strong> Set the color using hue (0-360), saturation (0-100) and value (0-100) values, comma separated.<br /></span>
<span class="module module-color">- <strong>&lt;root&gt;/brightness/set</strong> Set the brighness (0-255).<br /></span>
<span class="module module-color">- <strong>&lt;root&gt;/channel/#/set</strong> Set the value for a single color channel (0-255). Replace # with the channel ID (starting from 0 and up to 4 for RGBWC lights).<br /></span>
<span class="module module-color">- <strong>&lt;root&gt;/mired/set</strong> Set the temperature color in mired.<br /></span>
<span class="module module-lit">- <strong>&lt;root&gt;/rgb/set</strong> Set the color using this topic, your can either send an "#RRGGBB" value or "RRR,GGG,BBB" (0-255 each).<br /></span>
<span class="module module-lit">- <strong>&lt;root&gt;/hsv/set</strong> Set the color using hue (0-360), saturation (0-100) and value (0-100) values, comma separated.<br /></span>
<span class="module module-lit">- <strong>&lt;root&gt;/brightness/set</strong> Set the brighness (0-255).<br /></span>
<span class="module module-lit">- <strong>&lt;root&gt;/channel/#/set</strong> Set the value for a single color channel (0-255). Replace # with the channel ID (starting from 0 and up to 4 for RGBWC lights).<br /></span>
<span class="module module-lit">- <strong>&lt;root&gt;/mired/set</strong> Set the temperature color in mired.<br /></span>
<!-- endRemoveIf(!light)--> <!-- endRemoveIf(!light)-->
- <strong>&lt;root&gt;/status</strong> The device will report a 1 to this topic every few minutes. Upon MQTT disconnecting this will be set to 0.<br /> - <strong>&lt;root&gt;/status</strong> The device will report a 1 to this topic every few minutes. Upon MQTT disconnecting this will be set to 0.<br />
- Other values reported (depending on the build) are: <strong>firmware</strong> and <strong>version</strong>, <strong>hostname</strong>, <strong>IP</strong>, <strong>MAC</strong>, signal strenth (<strong>RSSI</strong>), <strong>uptime</strong> (in seconds), <strong>free heap</strong> and <strong>power supply</strong>. - Other values reported (depending on the build) are: <strong>firmware</strong> and <strong>version</strong>, <strong>hostname</strong>, <strong>IP</strong>, <strong>MAC</strong>, signal strenth (<strong>RSSI</strong>), <strong>uptime</strong> (in seconds), <strong>free heap</strong> and <strong>power supply</strong>.
@ -994,17 +994,17 @@
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Database</label> <label class="pure-u-1 pure-u-lg-1-4">Database</label>
<input class="pure-u-1 pure-u-lg-3-4" name="idbDatabase" type="text" tabindex="43" />
<input class="pure-u-1 pure-u-lg-3-4" name="idbDB" type="text" tabindex="43" />
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Username</label> <label class="pure-u-1 pure-u-lg-1-4">Username</label>
<input class="pure-u-1 pure-u-lg-3-4" name="idbUsername" type="text" tabindex="44" autocomplete="false" />
<input class="pure-u-1 pure-u-lg-3-4" name="idbUser" type="text" tabindex="44" autocomplete="false" />
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-lg-1-4">Password</label> <label class="pure-u-1 pure-u-lg-1-4">Password</label>
<input class="pure-u-1 pure-u-lg-3-4" name="idbPassword" type="password" tabindex="45" autocomplete="false" />
<input class="pure-u-1 pure-u-lg-3-4" name="idbPass" type="password" tabindex="45" autocomplete="false" />
</div> </div>
</fieldset> </fieldset>
@ -1097,13 +1097,13 @@
<div class="pure-g module module-hlw module-cse module-emon module-pzem"> <div class="pure-g module module-hlw module-cse module-emon module-pzem">
<label class="pure-u-1 pure-u-lg-1-4">Energy units</label> <label class="pure-u-1 pure-u-lg-1-4">Energy units</label>
<select name="energyUnits" tabindex="16" class="pure-u-1 pure-u-lg-1-4">
<select name="eneUnits" tabindex="16" class="pure-u-1 pure-u-lg-1-4">
<option value="0">Joules (J)</option> <option value="0">Joules (J)</option>
<option value="1">Kilowatts·hour (kWh)</option> <option value="1">Kilowatts·hour (kWh)</option>
</select> </select>
</div> </div>
<div class="pure-g module module-temperature">
<div class="pure-g module module-tmp">
<label class="pure-u-1 pure-u-lg-1-4">Temperature units</label> <label class="pure-u-1 pure-u-lg-1-4">Temperature units</label>
<select name="tmpUnits" tabindex="16" class="pure-u-1 pure-u-lg-1-4"> <select name="tmpUnits" tabindex="16" class="pure-u-1 pure-u-lg-1-4">
<option value="0">Celsius (&deg;C)</option> <option value="0">Celsius (&deg;C)</option>
@ -1111,9 +1111,9 @@
</select> </select>
</div> </div>
<div class="pure-g module module-temperature">
<div class="pure-g module module-tmp">
<label class="pure-u-1 pure-u-lg-1-4">Temperature correction</label> <label class="pure-u-1 pure-u-lg-1-4">Temperature correction</label>
<input name="tmpCorrection" class="pure-u-1 pure-u-lg-1-4" type="number" action="reboot" min="-100" step="0.1" max="100" tabindex="18" />
<input name="tmpOffset" class="pure-u-1 pure-u-lg-1-4" type="number" action="reboot" min="-100" step="0.1" max="100" tabindex="18" />
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint"> <div class="pure-u-1 pure-u-lg-3-4 hint">
@ -1121,9 +1121,9 @@
</div> </div>
</div> </div>
<div class="pure-g module module-humidity">
<div class="pure-g module module-hum">
<label class="pure-u-1 pure-u-lg-1-4">Humidity correction</label> <label class="pure-u-1 pure-u-lg-1-4">Humidity correction</label>
<input name="humCorrection" class="pure-u-1 pure-u-lg-1-4" type="number" action="reboot" min="-100" step="0.1" max="100" tabindex="18" />
<input name="humOffset" class="pure-u-1 pure-u-lg-1-4" type="number" action="reboot" min="-100" step="0.1" max="100" tabindex="18" />
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint"> <div class="pure-u-1 pure-u-lg-3-4 hint">
@ -1135,35 +1135,35 @@
<div class="pure-g module module-emon"> <div class="pure-g module module-emon">
<label class="pure-u-1 pure-u-lg-1-4">Voltage</label> <label class="pure-u-1 pure-u-lg-1-4">Voltage</label>
<input class="pure-u-1 pure-u-lg-3-4" name="pwrVoltage" type="text" tabindex="51" />
<input class="pure-u-1 pure-u-lg-3-4" name="volNominal" type="text" tabindex="51" />
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Mains voltage in your system (in V).</div> <div class="pure-u-1 pure-u-lg-3-4 hint">Mains voltage in your system (in V).</div>
</div> </div>
<div class="pure-g module module-hlw module-cse"> <div class="pure-g module module-hlw module-cse">
<label class="pure-u-1 pure-u-lg-1-4">Expected Current</label> <label class="pure-u-1 pure-u-lg-1-4">Expected Current</label>
<input class="pure-u-1 pure-u-lg-3-4 pwrExpected" name="pwrExpectedC" type="text" tabindex="52" placeholder="0" />
<input class="pure-u-1 pure-u-lg-3-4 pwrExpected" name="curExpected" type="text" tabindex="52" placeholder="0" />
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">In Amperes (A). If you are using a pure resistive load like a bulb, this will be the ratio between the two previous values, i.e. power / voltage. You can also use a current clamp around one of the power wires to get this value.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">In Amperes (A). If you are using a pure resistive load like a bulb, this will be the ratio between the two previous values, i.e. power / voltage. You can also use a current clamp around one of the power wires to get this value.</div>
</div> </div>
<div class="pure-g module module-hlw module-cse"> <div class="pure-g module module-hlw module-cse">
<label class="pure-u-1 pure-u-lg-1-4">Expected Voltage</label> <label class="pure-u-1 pure-u-lg-1-4">Expected Voltage</label>
<input class="pure-u-1 pure-u-lg-3-4 pwrExpected" name="pwrExpectedV" type="text" tabindex="53" placeholder="0" />
<input class="pure-u-1 pure-u-lg-3-4 pwrExpected" name="volExpected" type="text" tabindex="53" placeholder="0" />
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">In Volts (V). Enter your the nominal AC voltage for your household or facility, or use multimeter to get this value.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">In Volts (V). Enter your the nominal AC voltage for your household or facility, or use multimeter to get this value.</div>
</div> </div>
<div class="pure-g module module-hlw module-cse module-emon"> <div class="pure-g module module-hlw module-cse module-emon">
<label class="pure-u-1 pure-u-lg-1-4">Expected Power</label> <label class="pure-u-1 pure-u-lg-1-4">Expected Power</label>
<input class="pure-u-1 pure-u-lg-3-4 pwrExpected" name="pwrExpectedP" type="text" tabindex="54" placeholder="0" />
<input class="pure-u-1 pure-u-lg-3-4 pwrExpected" name="pwrExpected" type="text" tabindex="54" placeholder="0" />
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">In Watts (W). Calibrate your sensor connecting a pure resistive load (like a bulb) and enter here the its nominal power or use a multimeter.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">In Watts (W). Calibrate your sensor connecting a pure resistive load (like a bulb) and enter here the its nominal power or use a multimeter.</div>
</div> </div>
<div class="pure-g module module-hlw module-cse module-emon"> <div class="pure-g module module-hlw module-cse module-emon">
<label class="pure-u-1 pure-u-lg-1-4">Reset calibration</label> <label class="pure-u-1 pure-u-lg-1-4">Reset calibration</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="pwrResetCalibration" tabindex="55" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="snsResetCalibrarion" tabindex="55" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Move this switch to ON and press "Save" to revert to factory calibration values.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">Move this switch to ON and press "Save" to revert to factory calibration values.</div>
@ -1171,7 +1171,7 @@
<div class="pure-g module module-hlw module-cse module-emon"> <div class="pure-g module module-hlw module-cse module-emon">
<label class="pure-u-1 pure-u-lg-1-4">Reset energy</label> <label class="pure-u-1 pure-u-lg-1-4">Reset energy</label>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="pwrResetE" tabindex="56" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input type="checkbox" name="eneReset" tabindex="56" /></div>
<div class="pure-u-0 pure-u-lg-1-2"></div> <div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint">Move this switch to ON and press "Save" to set energy count to 0.</div> <div class="pure-u-1 pure-u-lg-3-4 hint">Move this switch to ON and press "Save" to set energy count to 0.</div>
@ -1346,7 +1346,7 @@
<legend>Switch #<span class="id"></span> (GPIO<span class="gpio"></span>)</legend> <legend>Switch #<span class="id"></span> (GPIO<span class="gpio"></span>)</legend>
<div class="pure-g"> <div class="pure-g">
<div class="pure-u-1 pure-u-lg-1-4"><label>Boot mode</label></div> <div class="pure-u-1 pure-u-lg-1-4"><label>Boot mode</label></div>
<select class="pure-u-1 pure-u-lg-3-4" name="relayBoot">
<select class="pure-u-1 pure-u-lg-3-4" name="rlyBoot">
<option value="0">Always OFF</option> <option value="0">Always OFF</option>
<option value="1">Always ON</option> <option value="1">Always ON</option>
<option value="2">Same as before</option> <option value="2">Same as before</option>
@ -1355,7 +1355,7 @@
</div> </div>
<div class="pure-g"> <div class="pure-g">
<div class="pure-u-1 pure-u-lg-1-4"><label>Pulse mode</label></div> <div class="pure-u-1 pure-u-lg-1-4"><label>Pulse mode</label></div>
<select class="pure-u-1 pure-u-lg-3-4" name="relayPulse">
<select class="pure-u-1 pure-u-lg-3-4" name="rlyPulse">
<option value="0">Don't pulse</option> <option value="0">Don't pulse</option>
<option value="1">Normally OFF</option> <option value="1">Normally OFF</option>
<option value="2">Normally ON</option> <option value="2">Normally ON</option>
@ -1363,7 +1363,7 @@
</div> </div>
<div class="pure-g"> <div class="pure-g">
<div class="pure-u-1 pure-u-lg-1-4"><label>Pulse time (s)</label></div> <div class="pure-u-1 pure-u-lg-1-4"><label>Pulse time (s)</label></div>
<div class="pure-u-1 pure-u-lg-1-4"><input name="relayTime" class="pure-u-1" type="number" min="0" step="0.1" max="3600" /></div>
<div class="pure-u-1 pure-u-lg-1-4"><input name="rlyTime" class="pure-u-1" type="number" min="0" step="0.1" max="3600" /></div>
</div> </div>
<div class="pure-g module module-mqtt"> <div class="pure-g module module-mqtt">
<div class="pure-u-1 pure-u-lg-1-4"><label>MQTT group</label></div> <div class="pure-u-1 pure-u-lg-1-4"><label>MQTT group</label></div>
@ -1378,7 +1378,7 @@
</div> </div>
<div class="pure-g module module-mqtt"> <div class="pure-g module module-mqtt">
<div class="pure-u-1 pure-u-lg-1-4"><label>On MQTT disconnect</label></div> <div class="pure-u-1 pure-u-lg-1-4"><label>On MQTT disconnect</label></div>
<select class="pure-u-1 pure-u-lg-3-4" name="relayOnDisc">
<select class="pure-u-1 pure-u-lg-3-4" name="rlyOnDisc">
<option value="0">Don't change</option> <option value="0">Don't change</option>
<option value="1">Turn the switch OFF</option> <option value="1">Turn the switch OFF</option>
<option value="2">Turn the switch ON</option> <option value="2">Turn the switch ON</option>


Loading…
Cancel
Save