Browse Source

Merge branch 'dev' into sensors

Conflicts:
	code/espurna/data/index.html.gz
	code/espurna/static/index.html.gz.h
	code/html/custom.js
fastled
Xose Pérez 7 years ago
parent
commit
78edb8a71e
12 changed files with 3445 additions and 3428 deletions
  1. +0
    -1
      code/espurna/button.ino
  2. +10
    -10
      code/espurna/config/general.h
  3. +1
    -0
      code/espurna/config/version.h
  4. BIN
      code/espurna/data/index.html.gz
  5. +1
    -1
      code/espurna/espurna.ino
  6. +0
    -614
      code/espurna/hardware.ino
  7. +644
    -0
      code/espurna/migrate.ino
  8. +127
    -117
      code/espurna/relay.ino
  9. +2602
    -2605
      code/espurna/static/index.html.gz.h
  10. +1
    -1
      code/espurna/ws.ino
  11. +27
    -33
      code/html/custom.js
  12. +32
    -46
      code/html/index.html

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

@ -110,7 +110,6 @@ void buttonEvent(unsigned int id, unsigned char event) {
if (action == BUTTON_MODE_RESET) { if (action == BUTTON_MODE_RESET) {
deferredReset(100, CUSTOM_RESET_HARDWARE); deferredReset(100, CUSTOM_RESET_HARDWARE);
} }
if (action == BUTTON_MODE_PULSE) relayPulseToggle();
if (action == BUTTON_MODE_FACTORY) { if (action == BUTTON_MODE_FACTORY) {
DEBUG_MSG_P(PSTR("\n\nFACTORY RESET\n\n")); DEBUG_MSG_P(PSTR("\n\nFACTORY RESET\n\n"));
settingsFactoryReset(); settingsFactoryReset();


+ 10
- 10
code/espurna/config/general.h View File

@ -194,10 +194,10 @@ PROGMEM const char* const custom_reset_string[] = {
// RELAY // RELAY
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#define RELAY_MODE_OFF 0
#define RELAY_MODE_ON 1
#define RELAY_MODE_SAME 2
#define RELAY_MODE_TOOGLE 3
#define RELAY_BOOT_OFF 0
#define RELAY_BOOT_ON 1
#define RELAY_BOOT_SAME 2
#define RELAY_BOOT_TOOGLE 3
#define RELAY_TYPE_NORMAL 0 #define RELAY_TYPE_NORMAL 0
#define RELAY_TYPE_INVERSE 1 #define RELAY_TYPE_INVERSE 1
@ -217,18 +217,18 @@ PROGMEM const char* const custom_reset_string[] = {
#define RELAY_PROVIDER_LIGHT 2 #define RELAY_PROVIDER_LIGHT 2
#define RELAY_PROVIDER_RFBRIDGE 3 #define RELAY_PROVIDER_RFBRIDGE 3
// Pulse time in milliseconds
#define RELAY_PULSE_TIME 1.0
// 0 means OFF, 1 ON and 2 whatever was before
#define RELAY_MODE RELAY_MODE_OFF
// Default boot mode: 0 means OFF, 1 ON and 2 whatever was before
#define RELAY_BOOT_MODE RELAY_BOOT_OFF
// 0 means ANY, 1 zero or one and 2 one and only one // 0 means ANY, 1 zero or one and 2 one and only one
#define RELAY_SYNC RELAY_SYNC_ANY #define RELAY_SYNC RELAY_SYNC_ANY
// 0 means no pulses, 1 means normally off, 2 normally on
// Default pulse mode: 0 means no pulses, 1 means normally off, 2 normally on
#define RELAY_PULSE_MODE RELAY_PULSE_NONE #define RELAY_PULSE_MODE RELAY_PULSE_NONE
// Default pulse time in seconds
#define RELAY_PULSE_TIME 1.0
// Relay requests flood protection window - in seconds // Relay requests flood protection window - in seconds
#define RELAY_FLOOD_WINDOW 3 #define RELAY_FLOOD_WINDOW 3


+ 1
- 0
code/espurna/config/version.h View File

@ -2,3 +2,4 @@
#define APP_VERSION "1.10.2b" #define APP_VERSION "1.10.2b"
#define APP_AUTHOR "xose.perez@gmail.com" #define APP_AUTHOR "xose.perez@gmail.com"
#define APP_WEBSITE "http://tinkerman.cat" #define APP_WEBSITE "http://tinkerman.cat"
#define CFG_VERSION 3

BIN
code/espurna/data/index.html.gz View File


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

@ -380,7 +380,7 @@ void setup() {
sensorSetup(); sensorSetup();
// Prepare configuration for version 2.0 // Prepare configuration for version 2.0
hwUpwardsCompatibility();
migrate();
saveSettings(); saveSettings();


+ 0
- 614
code/espurna/hardware.ino View File

@ -1,614 +0,0 @@
/*
HARDWARE MODULE
Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com>
*/
/*
The goal of this file is to store board configuration values in EEPROM so
the migration to future version 2 will be straigh forward.
*/
void hwUpwardsCompatibility() {
unsigned int board = getSetting("board", 0).toInt();
if (board > 0) return;
#if defined(NODEMCU_LOLIN)
setSetting("board", 2);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(WEMOS_D1_MINI_RELAYSHIELD)
setSetting("board", 3);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 5);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_BASIC)
setSetting("board", 4);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_TH)
setSetting("board", 5);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_SV)
setSetting("board", 6);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_TOUCH)
setSetting("board", 7);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_POW)
setSetting("board", 8);
setSetting("ledGPIO", 1, 15);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("selGPIO", 5);
setSetting("cf1GPIO", 13);
setSetting("cfGPIO", 14);
#elif defined(ITEAD_SONOFF_DUAL)
setSetting("board", 9);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnRelay", 3, 1);
setSetting("relayProvider", RELAY_PROVIDER_DUAL);
setSetting("relays", 2);
#elif defined(ITEAD_1CH_INCHING)
setSetting("board", 10);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_4CH)
setSetting("board", 11);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnGPIO", 2, 9);
setSetting("btnGPIO", 3, 10);
setSetting("btnGPIO", 4, 14);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("btnRelay", 3, 3);
setSetting("btnRelay", 4, 4);
setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 5);
setSetting("relayGPIO", 3, 4);
setSetting("relayGPIO", 4, 15);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
setSetting("relayType", 3, RELAY_TYPE_NORMAL);
setSetting("relayType", 4, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SLAMPHER)
setSetting("board", 12);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_S20)
setSetting("board", 13);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ELECTRODRAGON_WIFI_IOT)
setSetting("board", 14);
setSetting("ledGPIO", 1, 16);
setSetting("ledLogic", 1, 0);
setSetting("btnGPIO", 1, 0);
setSetting("btnGPIO", 2, 2);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 13);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
#elif defined(WORKCHOICE_ECOPLUG)
setSetting("board", 15);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 0);
setSetting("btnGPIO", 1, 13);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 15);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(JANGOE_WIFI_RELAY_NC)
setSetting("board", 16);
setSetting("btnGPIO", 1, 12);
setSetting("btnGPIO", 2, 13);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 2);
setSetting("relayGPIO", 2, 14);
setSetting("relayType", 1, RELAY_TYPE_INVERSE);
setSetting("relayType", 2, RELAY_TYPE_INVERSE);
#elif defined(JANGOE_WIFI_RELAY_NO)
setSetting("board", 17);
setSetting("btnGPIO", 1, 12);
setSetting("btnGPIO", 2, 13);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 2);
setSetting("relayGPIO", 2, 14);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
#elif defined(OPENENERGYMONITOR_MQTT_RELAY)
setSetting("board", 18);
setSetting("ledGPIO", 1, 16);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(JORGEGARCIA_WIFI_RELAYS)
setSetting("board", 19);
setSetting("relayGPIO", 1, 0);
setSetting("relayGPIO", 2, 2);
setSetting("relayType", 1, RELAY_TYPE_INVERSE);
setSetting("relayType", 2, RELAY_TYPE_INVERSE);
#elif defined(AITHINKER_AI_LIGHT)
setSetting("board", 20);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_MY92XX);
setSetting("myModel", MY92XX_MODEL_MY9291);
setSetting("myChips", 1);
setSetting("myDIGPIO", 13);
setSetting("myDCKIGPIO", 15);
setSetting("relays", 1);
#elif defined(MAGICHOME_LED_CONTROLLER)
setSetting("board", 21);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 1);
setSetting("chGPIO", 1, 14);
setSetting("chGPIO", 2, 5);
setSetting("chGPIO", 3, 12);
setSetting("chGPIO", 4, 13);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("chLogic", 4, 0);
setSetting("relays", 1);
#elif defined(MAGICHOME_LED_CONTROLLER_IR)
setSetting("board", 21);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 1);
setSetting("chGPIO", 1, 5);
setSetting("chGPIO", 2, 12);
setSetting("chGPIO", 3, 13);
setSetting("chGPIO", 4, 14);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("chLogic", 4, 0);
setSetting("relays", 1);
#elif defined(ITEAD_MOTOR)
setSetting("board", 22);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(TINKERMAN_ESPURNA_H06)
setSetting("board", 23);
setSetting("ledGPIO", 1, 5);
setSetting("ledLogic", 1, 0);
setSetting("btnGPIO", 1, 4);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_INVERSE);
setSetting("selGPIO", 2);
setSetting("cf1GPIO", 13);
setSetting("cfGPIO", 14);
#elif defined(HUACANXING_H801)
setSetting("board", 24);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 1, 5);
setSetting("ledLogic", 1, 1);
setSetting("chGPIO", 1, 15);
setSetting("chGPIO", 2, 13);
setSetting("chGPIO", 3, 12);
setSetting("chGPIO", 4, 14);
setSetting("chGPIO", 5, 4);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("chLogic", 4, 0);
setSetting("chLogic", 5, 0);
setSetting("relays", 1);
#elif defined(ITEAD_BNSZ01)
setSetting("board", 25);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 3, 13);
setSetting("ledLogic", 1, 1);
setSetting("chGPIO", 1, 12);
setSetting("chLogic", 1, 0);
setSetting("relays", 1);
#elif defined(ITEAD_SONOFF_RFBRIDGE)
setSetting("board", 26);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("relayProvider", RELAY_PROVIDER_RFBRIDGE);
setSetting("relays", 6);
#elif defined(ITEAD_SONOFF_4CH_PRO)
setSetting("board", 27);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnGPIO", 2, 9);
setSetting("btnGPIO", 3, 10);
setSetting("btnGPIO", 4, 14);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("btnRelay", 3, 3);
setSetting("btnRelay", 4, 4);
setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 5);
setSetting("relayGPIO", 3, 4);
setSetting("relayGPIO", 4, 15);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
setSetting("relayType", 3, RELAY_TYPE_NORMAL);
setSetting("relayType", 4, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_B1)
setSetting("board", 28);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_MY92XX);
setSetting("myModel", MY92XX_MODEL_MY9231);
setSetting("myChips", 2);
setSetting("myDIGPIO", 12);
setSetting("myDCKIGPIO", 14);
setSetting("relays", 1);
#elif defined(ITEAD_SONOFF_LED)
setSetting("board", 29);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("chGPIO", 1, 12);
setSetting("chLogic", 1, 0);
setSetting("chGPIO", 2, 14);
setSetting("chLogic", 2, 0);
setSetting("relays", 1);
#elif defined(ITEAD_SONOFF_T1_1CH)
setSetting("board", 30);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 9);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 5);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_T1_2CH)
setSetting("board", 31);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnGPIO", 2, 10);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 4);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_T1_3CH)
setSetting("board", 32);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnGPIO", 2, 9);
setSetting("btnGPIO", 3, 10);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("btnRelay", 3, 3);
setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 5);
setSetting("relayGPIO", 3, 4);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
setSetting("relayType", 3, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_RF)
setSetting("board", 33);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(WION_50055)
setSetting("board", 34);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 0);
setSetting("btnGPIO", 1, 13);
setSetting("btnRelay", 1,1);
setSetting("relayGPIO", 1, 15);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(EXS_WIFI_RELAY_V31)
setSetting("board", 35);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 13);
setSetting("relayResetGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(HUACANXING_H802)
setSetting("board", 36);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("chGPIO", 1, 12);
setSetting("chGPIO", 2, 14);
setSetting("chGPIO", 3, 13);
setSetting("chGPIO", 4, 15);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("chLogic", 4, 0);
setSetting("relays", 1);
#elif defined(GENERIC_V9261F)
setSetting("board", 37);
#elif defined(GENERIC_ECH1560)
setSetting("board", 38);
#elif defined(TINKERMAN_ESPURNA_H08)
setSetting("board", 39);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 0);
setSetting("btnGPIO", 1, 4);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("selGPIO", 5);
setSetting("cf1GPIO", 13);
setSetting("cfGPIO", 14);
#elif defined(MANCAVEMADE_ESPLIVE)
setSetting("board", 40);
setSetting("btnGPIO", 1, 4);
setSetting("btnGPIO", 2, 5);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 13);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
#elif defined(INTERMITTECH_QUINLED)
setSetting("board", 41);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 1, 1);
setSetting("ledLogic", 1, 1);
setSetting("chGPIO", 1, 0);
setSetting("chGPIO", 2, 2);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("relays", 1);
#elif defined(MAGICHOME_LED_CONTROLLER_20)
setSetting("board", 42);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("chGPIO", 1, 5);
setSetting("chGPIO", 2, 12);
setSetting("chGPIO", 3, 13);
setSetting("chGPIO", 4, 15);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("chLogic", 4, 0);
setSetting("relays", 1);
#elif defined(ARILUX_AL_LC06)
setSetting("board", 43);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("chGPIO", 1, 12);
setSetting("chGPIO", 2, 14);
setSetting("chGPIO", 3, 13);
setSetting("chGPIO", 4, 15);
setSetting("chGPIO", 5, 5);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("chLogic", 4, 0);
setSetting("chLogic", 5, 0);
setSetting("relays", 1);
#elif defined(XENON_SM_PW702U)
setSetting("board", 44);
setSetting("ledGPIO", 1, 4);
setSetting("ledLogic", 1, 0);
setSetting("btnGPIO", 1, 13);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(AUTHOMETION_LYT8266)
setSetting("board", 45);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("chGPIO", 1, 13);
setSetting("chGPIO", 2, 12);
setSetting("chGPIO", 3, 14);
setSetting("chGPIO", 4, 2);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("chLogic", 4, 0);
setSetting("relays", 1);
setSetting("enGPIO", 15);
#elif defined(ARILUX_E27)
setSetting("board", 46);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_MY92XX);
setSetting("myModel", MY92XX_MODEL_MY9291);
setSetting("myChips", 1);
setSetting("myDIGPIO", 13);
setSetting("myDCKIGPIO", 15);
setSetting("relays", 1);
#elif defined(YJZK_SWITCH_2CH)
setSetting("board", 47);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 0);
setSetting("ledWifi", 0);
setSetting("btnGPIO", 1, 0);
setSetting("btnGPIO", 2, 9);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 5);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_DUAL_R2)
setSetting("board", 48);
setSetting("ledGPIO", 1, 13);
setSetting("ledLogic", 1, 1);
setSetting("btnGPIO", 1, 0);
setSetting("btnGPIO", 2, 9);
setSetting("btnGPIO", 3, 10);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("btnRelay", 3, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 5);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
#else
#error "UNSUPPORTED HARDWARE!"
#endif
saveSettings();
}

+ 644
- 0
code/espurna/migrate.ino View File

@ -0,0 +1,644 @@
/*
MIGRATE MODULE
Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com>
*/
void _cmpMoveIndexDown(const char * key, int offset = 0) {
if (hasSetting(key, 0)) return;
for (unsigned char index = 1; index < 10; index++) {
if (hasSetting(key, index)) {
setSetting(key, index - 1, getSetting(key, index).toInt() + offset);
} else {
delSetting(key, index - 1);
}
}
}
// Configuration versions
//
// 1: based on Embedis, no board definitions
// 2: based on Embedis, with board definitions 1-based
// 3: based on Embedis, with board definitions 0-based
void migrate() {
// Get config version
unsigned int board = getSetting("board", 0).toInt();
unsigned int config_version = getSetting("cfg", board > 0 ? 2 : 1).toInt();
// Update if not on latest version
if (config_version == CFG_VERSION) return;
setSetting("cfg", CFG_VERSION);
if (config_version == 2) {
_cmpMoveIndexDown("ledGPIO");
_cmpMoveIndexDown("ledLogic");
_cmpMoveIndexDown("btnGPIO");
_cmpMoveIndexDown("btnRelay", -1);
_cmpMoveIndexDown("relayGPIO");
_cmpMoveIndexDown("relayType");
}
if (config_version == 1) {
#if defined(NODEMCU_LOLIN)
setSetting("board", 2);
setSetting("ledGPIO", 0, 2);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(WEMOS_D1_MINI_RELAYSHIELD)
setSetting("board", 3);
setSetting("ledGPIO", 0, 2);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 5);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_BASIC)
setSetting("board", 4);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_TH)
setSetting("board", 5);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_SV)
setSetting("board", 6);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_TOUCH)
setSetting("board", 7);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_POW)
setSetting("board", 8);
setSetting("ledGPIO", 0, 15);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
setSetting("selGPIO", 5);
setSetting("cf1GPIO", 13);
setSetting("cfGPIO", 14);
#elif defined(ITEAD_SONOFF_DUAL)
setSetting("board", 9);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnRelay", 0, 0xFF);
setSetting("btnRelay", 1, 0xFF);
setSetting("btnRelay", 2, 0);
setSetting("relayProvider", RELAY_PROVIDER_DUAL);
setSetting("relays", 2);
#elif defined(ITEAD_1CH_INCHING)
setSetting("board", 10);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_4CH)
setSetting("board", 11);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 9);
setSetting("btnGPIO", 2, 10);
setSetting("btnGPIO", 3, 14);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("btnRelay", 3, 3);
setSetting("relayGPIO", 0, 12);
setSetting("relayGPIO", 1, 5);
setSetting("relayGPIO", 2, 4);
setSetting("relayGPIO", 3, 15);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
setSetting("relayType", 3, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SLAMPHER)
setSetting("board", 12);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_S20)
setSetting("board", 13);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(ELECTRODRAGON_WIFI_IOT)
setSetting("board", 14);
setSetting("ledGPIO", 0, 16);
setSetting("ledLogic", 0, 0);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 2);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 0, 12);
setSetting("relayGPIO", 1, 13);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(WORKCHOICE_ECOPLUG)
setSetting("board", 15);
setSetting("ledGPIO", 0, 2);
setSetting("ledLogic", 0, 0);
setSetting("btnGPIO", 0, 13);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 15);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(JANGOE_WIFI_RELAY_NC)
setSetting("board", 16);
setSetting("btnGPIO", 0, 12);
setSetting("btnGPIO", 1, 13);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 0, 2);
setSetting("relayGPIO", 1, 14);
setSetting("relayType", 0, RELAY_TYPE_INVERSE);
setSetting("relayType", 1, RELAY_TYPE_INVERSE);
#elif defined(JANGOE_WIFI_RELAY_NO)
setSetting("board", 17);
setSetting("btnGPIO", 0, 12);
setSetting("btnGPIO", 1, 13);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 0, 2);
setSetting("relayGPIO", 1, 14);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(OPENENERGYMONITOR_MQTT_RELAY)
setSetting("board", 18);
setSetting("ledGPIO", 0, 16);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(JORGEGARCIA_WIFI_RELAYS)
setSetting("board", 19);
setSetting("relayGPIO", 0, 0);
setSetting("relayGPIO", 1, 2);
setSetting("relayType", 0, RELAY_TYPE_INVERSE);
setSetting("relayType", 1, RELAY_TYPE_INVERSE);
#elif defined(AITHINKER_AI_LIGHT)
setSetting("board", 20);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_MY92XX);
setSetting("myModel", MY92XX_MODEL_MY9291);
setSetting("myChips", 1);
setSetting("myDIGPIO", 13);
setSetting("myDCKIGPIO", 15);
setSetting("relays", 1);
#elif defined(MAGICHOME_LED_CONTROLLER)
setSetting("board", 21);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 0, 2);
setSetting("ledLogic", 0, 1);
setSetting("chGPIO", 0, 14);
setSetting("chGPIO", 1, 5);
setSetting("chGPIO", 2, 12);
setSetting("chGPIO", 3, 13);
setSetting("chLogic", 0, 0);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("relays", 1);
#elif defined(MAGICHOME_LED_CONTROLLER_IR)
setSetting("board", 21);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 0, 2);
setSetting("ledLogic", 0, 1);
setSetting("chGPIO", 0, 5);
setSetting("chGPIO", 1, 12);
setSetting("chGPIO", 2, 13);
setSetting("chGPIO", 3, 14);
setSetting("chLogic", 0, 0);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("relays", 1);
#elif defined(ITEAD_MOTOR)
setSetting("board", 22);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(TINKERMAN_ESPURNA_H06)
setSetting("board", 23);
setSetting("ledGPIO", 0, 5);
setSetting("ledLogic", 0, 0);
setSetting("btnGPIO", 0, 4);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_INVERSE);
setSetting("selGPIO", 2);
setSetting("cf1GPIO", 13);
setSetting("cfGPIO", 14);
#elif defined(HUACANXING_H801)
setSetting("board", 24);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 0, 5);
setSetting("ledLogic", 0, 1);
setSetting("chGPIO", 0, 15);
setSetting("chGPIO", 1, 13);
setSetting("chGPIO", 2, 12);
setSetting("chGPIO", 3, 14);
setSetting("chGPIO", 4, 4);
setSetting("chLogic", 0, 0);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("chLogic", 4, 0);
setSetting("relays", 1);
#elif defined(ITEAD_BNSZ01)
setSetting("board", 25);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("chGPIO", 0, 12);
setSetting("chLogic", 0, 0);
setSetting("relays", 1);
#elif defined(ITEAD_SONOFF_RFBRIDGE)
setSetting("board", 26);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("relayProvider", RELAY_PROVIDER_RFBRIDGE);
setSetting("relays", 6);
#elif defined(ITEAD_SONOFF_4CH_PRO)
setSetting("board", 27);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 9);
setSetting("btnGPIO", 2, 10);
setSetting("btnGPIO", 3, 14);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("btnRelay", 3, 3);
setSetting("relayGPIO", 0, 12);
setSetting("relayGPIO", 1, 5);
setSetting("relayGPIO", 2, 4);
setSetting("relayGPIO", 3, 15);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
setSetting("relayType", 3, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_B1)
setSetting("board", 28);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_MY92XX);
setSetting("myModel", MY92XX_MODEL_MY9231);
setSetting("myChips", 2);
setSetting("myDIGPIO", 12);
setSetting("myDCKIGPIO", 14);
setSetting("relays", 1);
#elif defined(ITEAD_SONOFF_LED)
setSetting("board", 29);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("chGPIO", 0, 12);
setSetting("chLogic", 0, 0);
setSetting("chGPIO", 1, 14);
setSetting("chLogic", 1, 0);
setSetting("relays", 1);
#elif defined(ITEAD_SONOFF_T1_1CH)
setSetting("board", 30);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 9);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 5);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_T1_2CH)
setSetting("board", 31);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 10);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 0, 12);
setSetting("relayGPIO", 1, 4);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_T1_3CH)
setSetting("board", 32);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 9);
setSetting("btnGPIO", 2, 10);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 0, 12);
setSetting("relayGPIO", 1, 5);
setSetting("relayGPIO", 2, 4);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_RF)
setSetting("board", 33);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(WION_50055)
setSetting("board", 34);
setSetting("ledGPIO", 0, 2);
setSetting("ledLogic", 0, 0);
setSetting("btnGPIO", 0, 13);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 15);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(EXS_WIFI_RELAY_V31)
setSetting("board", 35);
setSetting("btnGPIO", 0, 0);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 13);
setSetting("relayResetGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(HUACANXING_H802)
setSetting("board", 36);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("chGPIO", 0, 12);
setSetting("chGPIO", 1, 14);
setSetting("chGPIO", 2, 13);
setSetting("chGPIO", 3, 15);
setSetting("chLogic", 0, 0);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("relays", 1);
#elif defined(GENERIC_V9261F)
setSetting("board", 37);
#elif defined(GENERIC_ECH1560)
setSetting("board", 38);
#elif defined(TINKERMAN_ESPURNA_H08)
setSetting("board", 39);
setSetting("ledGPIO", 0, 2);
setSetting("ledLogic", 0, 0);
setSetting("btnGPIO", 0, 4);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
setSetting("selGPIO", 5);
setSetting("cf1GPIO", 13);
setSetting("cfGPIO", 14);
#elif defined(MANCAVEMADE_ESPLIVE)
setSetting("board", 40);
setSetting("btnGPIO", 0, 4);
setSetting("btnGPIO", 1, 5);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 0, 12);
setSetting("relayGPIO", 1, 13);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(INTERMITTECH_QUINLED)
setSetting("board", 41);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("ledGPIO", 0, 1);
setSetting("ledLogic", 0, 1);
setSetting("chGPIO", 0, 0);
setSetting("chGPIO", 1, 2);
setSetting("chLogic", 0, 0);
setSetting("chLogic", 1, 0);
setSetting("relays", 1);
#elif defined(MAGICHOME_LED_CONTROLLER_20)
setSetting("board", 42);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("chGPIO", 0, 5);
setSetting("chGPIO", 1, 12);
setSetting("chGPIO", 2, 13);
setSetting("chGPIO", 3, 15);
setSetting("chLogic", 0, 0);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("relays", 1);
#elif defined(ARILUX_AL_LC06)
setSetting("board", 43);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("chGPIO", 0, 12);
setSetting("chGPIO", 1, 14);
setSetting("chGPIO", 2, 13);
setSetting("chGPIO", 3, 15);
setSetting("chGPIO", 4, 5);
setSetting("chLogic", 0, 0);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("chLogic", 4, 0);
setSetting("relays", 1);
#elif defined(XENON_SM_PW702U)
setSetting("board", 44);
setSetting("ledGPIO", 0, 4);
setSetting("ledLogic", 0, 0);
setSetting("btnGPIO", 0, 13);
setSetting("btnRelay", 0, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
#elif defined(AUTHOMETION_LYT8266)
setSetting("board", 45);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_DIMMER);
setSetting("chGPIO", 0, 13);
setSetting("chGPIO", 1, 12);
setSetting("chGPIO", 2, 14);
setSetting("chGPIO", 3, 2);
setSetting("chLogic", 0, 0);
setSetting("chLogic", 1, 0);
setSetting("chLogic", 2, 0);
setSetting("chLogic", 3, 0);
setSetting("relays", 1);
setSetting("enGPIO", 15);
#elif defined(ARILUX_E27)
setSetting("board", 46);
setSetting("relayProvider", RELAY_PROVIDER_LIGHT);
setSetting("lightProvider", LIGHT_PROVIDER_MY92XX);
setSetting("myModel", MY92XX_MODEL_MY9291);
setSetting("myChips", 1);
setSetting("myDIGPIO", 13);
setSetting("myDCKIGPIO", 15);
setSetting("relays", 1);
#elif defined(YJZK_SWITCH_2CH)
setSetting("board", 47);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 0);
setSetting("ledWifi", 0);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 9);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 0, 12);
setSetting("relayGPIO", 1, 5);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_DUAL_R2)
setSetting("board", 48);
setSetting("ledGPIO", 0, 13);
setSetting("ledLogic", 0, 1);
setSetting("btnGPIO", 0, 0);
setSetting("btnGPIO", 1, 9);
setSetting("btnGPIO", 2, 10);
setSetting("btnRelay", 0, 0);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 0);
setSetting("relayGPIO", 0, 12);
setSetting("relayGPIO", 1, 5);
setSetting("relayType", 0, RELAY_TYPE_NORMAL);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#else
#error "UNSUPPORTED HARDWARE!"
#endif
}
saveSettings();
}

+ 127
- 117
code/espurna/relay.ino View File

@ -17,24 +17,26 @@ typedef struct {
// Configuration variables // Configuration variables
unsigned char pin; // GPIO pin for the relay unsigned char pin; // GPIO pin for the relay
unsigned char type;
unsigned char reset_pin;
unsigned long delay_on;
unsigned long delay_off;
unsigned char type; // RELAY_TYPE_NORMAL, RELAY_TYPE_INVERSE or RELAY_TYPE_LATCHED
unsigned char reset_pin; // GPIO to reset the relay if RELAY_TYPE_LATCHED
unsigned long pulse; // RELAY_PULSE_NONE, RELAY_PULSE_OFF or RELAY_PULSE_ON
unsigned long pulse_ms; // Pulse length in millis
unsigned long delay_on; // Delay to turn relay ON
unsigned long delay_off; // Delay to turn relay OFF
// Status variables // Status variables
bool current_status;
bool target_status;
unsigned int fw_start;
unsigned char fw_count;
unsigned int change_time;
bool report;
bool group_report;
bool current_status; // Holds the current (physical) status of the relay
bool target_status; // Holds the target status
unsigned int fw_start; // Flood window start time
unsigned char fw_count; // Number of changes within the current flood window
unsigned int change_time; // Scheduled time to change
bool report; // Whether to report to own topic
bool group_report; // Whether to report to group topic
// Helping objects // Helping objects
Ticker pulseTicker;
Ticker pulseTicker; // Holds the pulse back timer
} relay_t; } relay_t;
std::vector<relay_t> _relays; std::vector<relay_t> _relays;
@ -45,10 +47,6 @@ Ticker _relaySaveTicker;
// RELAY PROVIDERS // RELAY PROVIDERS
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#if RELAY_PROVIDER == RELAY_PROVIDER_DUAL
#endif
void _relayProviderStatus(unsigned char id, bool status) { void _relayProviderStatus(unsigned char id, bool status) {
// Check relay ID // Check relay ID
@ -111,43 +109,20 @@ void _relayProviderStatus(unsigned char id, bool status) {
void relayPulse(unsigned char id) { void relayPulse(unsigned char id) {
byte relayPulseMode = getSetting("relayPulseMode", RELAY_PULSE_MODE).toInt();
if (relayPulseMode == RELAY_PULSE_NONE) return;
long relayPulseTime = 1000.0 * getSetting("relayPulseTime", RELAY_PULSE_TIME).toFloat();
if (relayPulseTime == 0) return;
byte mode = _relays[id].pulse;
if (mode == RELAY_PULSE_NONE) return;
unsigned long ms = _relays[id].pulse_ms;
if (ms == 0) return;
bool status = relayStatus(id); bool status = relayStatus(id);
bool pulseStatus = (relayPulseMode == RELAY_PULSE_ON);
bool pulseStatus = (mode == RELAY_PULSE_ON);
if (pulseStatus == status) { if (pulseStatus == status) {
_relays[id].pulseTicker.detach(); _relays[id].pulseTicker.detach();
return;
} else {
_relays[id].pulseTicker.once_ms(ms, relayToggle, id);
} }
_relays[id].pulseTicker.once_ms(relayPulseTime, relayToggle, id);
}
unsigned int relayPulseMode() {
unsigned int value = getSetting("relayPulseMode", RELAY_PULSE_MODE).toInt();
return value;
}
void relayPulseMode(unsigned int value) {
setSetting("relayPulseMode", value);
#if WEB_SUPPORT
char message[20];
snprintf_P(message, sizeof(message), PSTR("{\"relayPulseMode\": %d}"), value);
wsSend(message);
#endif
}
void relayPulseToggle() {
unsigned int value = relayPulseMode();
value = (value == RELAY_PULSE_NONE) ? RELAY_PULSE_OFF : RELAY_PULSE_NONE;
relayPulseMode(value);
} }
bool relayStatus(unsigned char id, bool status, bool report, bool group_report) { bool relayStatus(unsigned char id, bool status, bool report, bool group_report) {
@ -220,7 +195,7 @@ bool relayStatus(unsigned char id) {
// Check relay ID // Check relay ID
if (id >= _relays.size()) return false; if (id >= _relays.size()) return false;
// GEt status from storage
// Get status from storage
return _relays[id].current_status; return _relays[id].current_status;
} }
@ -278,24 +253,6 @@ void relaySave() {
EEPROM.commit(); EEPROM.commit();
} }
void relayRetrieve(bool invert) {
_relayRecursive = true;
unsigned char bit = 1;
unsigned char mask = invert ? ~EEPROM.read(EEPROM_RELAY_STATUS) : EEPROM.read(EEPROM_RELAY_STATUS);
DEBUG_MSG_P(PSTR("[RELAY] Retrieving mask: %d\n"), mask);
for (unsigned int id=0; id < _relays.size(); id++) {
_relays[id].target_status = ((mask & bit) == bit);
_relays[id].report = true;
_relays[id].group_report = false; // Don't do group report on start
bit += bit;
}
if (invert) {
EEPROM.write(EEPROM_RELAY_STATUS, mask);
EEPROM.commit();
}
_relayRecursive = false;
}
void relayToggle(unsigned char id, bool report, bool group_report) { void relayToggle(unsigned char id, bool report, bool group_report) {
if (id >= _relays.size()) return; if (id >= _relays.size()) return;
relayStatus(id, !relayStatus(id), report, group_report); relayStatus(id, !relayStatus(id), report, group_report);
@ -341,59 +298,113 @@ unsigned char relayParsePayload(const char * payload) {
} }
// BACKWARDS COMPATIBILITY
void _relayBackwards() {
byte relayMode = getSetting("relayMode", RELAY_BOOT_MODE).toInt();
byte relayPulseMode = getSetting("relayPulseMode", RELAY_PULSE_MODE).toInt();
float relayPulseTime = getSetting("relayPulseTime", RELAY_PULSE_TIME).toFloat();
if (relayPulseMode == RELAY_PULSE_NONE) relayPulseTime = 0;
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);
}
delSetting("relayMode");
delSetting("relayPulseMode");
delSetting("relayPulseTime");
}
void _relayBoot() {
_relayRecursive = true;
unsigned char bit = 1;
bool trigger_save = false;
// Get last statuses from EEPROM
unsigned char mask = EEPROM.read(EEPROM_RELAY_STATUS);
DEBUG_MSG_P(PSTR("[RELAY] Retrieving mask: %d\n"), mask);
// Walk the relays
for (unsigned int i=0; i<_relays.size(); i++) {
_relays[i].current_status = false;
_relays[i].target_status = false;
unsigned char boot_mode = getSetting("relayBoot", i, RELAY_BOOT_MODE).toInt();
switch (boot_mode) {
case RELAY_BOOT_OFF:
relayStatus(i, false);
break;
case RELAY_BOOT_ON:
relayStatus(i, true);
break;
case RELAY_BOOT_SAME:
relayStatus(i, (mask & bit) == bit);
break;
case RELAY_BOOT_TOOGLE:
relayStatus(i, (mask & bit) != bit);
mask ^= bit;
trigger_save = true;
break;
}
bit <<= 1;
}
// Save if there is any relay in the RELAY_BOOT_TOOGLE mode
if (trigger_save) {
EEPROM.write(EEPROM_RELAY_STATUS, mask);
EEPROM.commit();
}
_relayRecursive = false;
}
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// WEBSOCKETS // WEBSOCKETS
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#if WEB_SUPPORT #if WEB_SUPPORT
void _relayWebSocketUpdate() {
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
// Statuses
void _relayWebSocketUpdate(JsonObject& root) {
JsonArray& relay = root.createNestedArray("relayStatus"); JsonArray& relay = root.createNestedArray("relayStatus");
for (unsigned char i=0; i<relayCount(); i++) { for (unsigned char i=0; i<relayCount(); i++) {
relay.add(_relays[i].target_status); relay.add(_relays[i].target_status);
} }
String output;
root.printTo(output);
wsSend((char *) output.c_str());
} }
void _relayWebSocketOnSend(JsonObject& root) {
void _relayWebSocketOnStart(JsonObject& root) {
if (relayCount() == 0) return; if (relayCount() == 0) return;
root["relayVisible"] = 1;
// Statuses // Statuses
JsonArray& relay = root.createNestedArray("relayStatus");
for (unsigned char relayID=0; relayID<relayCount(); relayID++) {
relay.add(relayStatus(relayID));
}
_relayWebSocketUpdate(root);
// Configuration // Configuration
root["relayMode"] = getSetting("relayMode", RELAY_MODE);
root["relayPulseMode"] = getSetting("relayPulseMode", RELAY_PULSE_MODE);
root["relayPulseTime"] = getSetting("relayPulseTime", RELAY_PULSE_TIME).toFloat();
JsonArray& config = root.createNestedArray("relayConfig");
for (unsigned char i=0; i<relayCount(); i++) {
JsonObject& line = config.createNestedObject();
line["gpio"] = _relays[i].pin;
line["type"] = _relays[i].type;
line["reset"] = _relays[i].reset_pin;
line["boot"] = getSetting("relayBoot", i, RELAY_BOOT_MODE).toInt();
line["pulse"] = _relays[i].pulse;
line["pulse_ms"] = _relays[i].pulse_ms / 1000.0;
#if MQTT_SUPPORT
line["group"] = getSetting("mqttGroup", i, "");
line["group_inv"] = getSetting("mqttGroupInv", i, 0).toInt() == 1;
#endif
}
if (relayCount() > 1) { if (relayCount() > 1) {
root["multirelayVisible"] = 1; root["multirelayVisible"] = 1;
root["relaySync"] = getSetting("relaySync", RELAY_SYNC); root["relaySync"] = getSetting("relaySync", RELAY_SYNC);
} }
// Group topics
#if MQTT_SUPPORT
JsonArray& groups = root.createNestedArray("relayGroups");
for (unsigned char i=0; i<relayCount(); i++) {
JsonObject& group = groups.createNestedObject();
group["mqttGroup"] = getSetting("mqttGroup", i, "");
group["mqttGroupInv"] = getSetting("mqttGroupInv", i, 0).toInt() == 1;
}
#endif
root["relayVisible"] = 1;
} }
@ -407,7 +418,7 @@ void _relayWebSocketOnAction(const char * action, JsonObject& data) {
if (value == 3) { if (value == 3) {
_relayWebSocketUpdate();
wsSend(_relayWebSocketUpdate);
} else if (value < 3) { } else if (value < 3) {
@ -432,9 +443,19 @@ void _relayWebSocketOnAction(const char * action, JsonObject& data) {
} }
void _relayConfigure() {
for (unsigned int i=0; i<_relays.size(); i++) {
pinMode(_relays[i].pin, OUTPUT);
if (_relays[i].type == RELAY_TYPE_LATCHED) 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();
}
}
void relaySetupWS() { void relaySetupWS() {
wsOnSendRegister(_relayWebSocketOnSend);
wsOnSendRegister(_relayWebSocketOnStart);
wsOnActionRegister(_relayWebSocketOnAction); wsOnActionRegister(_relayWebSocketOnAction);
wsOnAfterParseRegister(_relayConfigure);
} }
#endif // WEB_SUPPORT #endif // WEB_SUPPORT
@ -560,12 +581,12 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo
for (unsigned int i=0; i < _relays.size(); i++) { for (unsigned int i=0; i < _relays.size(); i++) {
String t = getSetting("mqttGroup", i, ""); String t = getSetting("mqttGroup", i, "");
if (t.equals(topic)) { if (t.equals(topic)) {
is_group_topic = true;
relayID = i;
if (getSetting("mqttGroupInv", relayID, 0).toInt() == 1) {
if (getSetting("mqttGroupInv", i, 0).toInt() == 1) {
if (value < 2) value = 1 - value; if (value < 2) value = 1 - value;
} }
DEBUG_MSG_P(PSTR("[RELAY] Matched group topic for relayID %d\n"), relayID);
DEBUG_MSG_P(PSTR("[RELAY] Matched group topic for relayID %d\n"), i);
is_group_topic = true;
relayID = i;
break; break;
} }
} }
@ -577,12 +598,6 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo
String t = mqttSubtopic((char *) topic); String t = mqttSubtopic((char *) topic);
if (!t.startsWith(MQTT_TOPIC_RELAY)) return; if (!t.startsWith(MQTT_TOPIC_RELAY)) return;
// Pulse topic
if (t.endsWith("pulse")) {
relayPulseMode(value);
return;
}
// Get relay ID // Get relay ID
relayID = t.substring(strlen(MQTT_TOPIC_RELAY)+1).toInt(); relayID = t.substring(strlen(MQTT_TOPIC_RELAY)+1).toInt();
if (relayID >= relayCount()) { if (relayID >= relayCount()) {
@ -653,14 +668,9 @@ void relaySetup() {
#endif #endif
byte relayMode = getSetting("relayMode", RELAY_MODE).toInt();
for (unsigned int i=0; i < _relays.size(); i++) {
pinMode(_relays[i].pin, OUTPUT);
if (relayMode == RELAY_MODE_OFF) relayStatus(i, false);
if (relayMode == RELAY_MODE_ON) relayStatus(i, true);
}
if (relayMode == RELAY_MODE_SAME) relayRetrieve(false);
if (relayMode == RELAY_MODE_TOOGLE) relayRetrieve(true);
_relayBackwards();
_relayConfigure();
_relayBoot();
relayLoop(); relayLoop();
#if WEB_SUPPORT #if WEB_SUPPORT
@ -702,7 +712,7 @@ void relayLoop(void) {
relayPulse(id); relayPulse(id);
_relaySaveTicker.once_ms(RELAY_SAVE_DELAY, relaySave); _relaySaveTicker.once_ms(RELAY_SAVE_DELAY, relaySave);
#if WEB_SUPPORT #if WEB_SUPPORT
_relayWebSocketUpdate();
wsSend(_relayWebSocketUpdate);
#endif #endif
} }


+ 2602
- 2605
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


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

@ -146,8 +146,8 @@ void _wsParse(AsyncWebSocketClient *client, uint8_t * payload, size_t length) {
if (password.length() > 0) { if (password.length() > 0) {
setSetting(key, password); setSetting(key, password);
save = true; save = true;
wsSend_P(client_id, PSTR("{\"action\": \"reload\"}"));
} }
wsSend_P(client_id, PSTR("{\"action\": \"reload\"}"));
} else { } else {
wsSend_P(client_id, PSTR("{\"message\": 7}")); wsSend_P(client_id, PSTR("{\"message\": 7}"));
} }


+ 27
- 33
code/html/custom.js View File

@ -96,7 +96,15 @@ function validateForm(form) {
} }
// These fields will always be a list of values // These fields will always be a list of values
var is_group = ["ssid", "pass", "gw", "mask", "ip", "dns", "mqttGroup", "mqttGroupInv", "dczRelayIdx", "ledMode", "ntpServer", "adminPass"];
var is_group = [
"ssid", "pass", "gw", "mask", "ip", "dns",
"relayBoot", "relayPulse", "relayTime",
"mqttGroup", "mqttGroupInv",
"dczRelayIdx",
"ledMode",
"ntpServer",
"adminPass"
];
function getData(form) { function getData(form) {
@ -475,20 +483,23 @@ function initRelays(data) {
} }
function addRelayGroup() {
function initRelayConfig(data) {
var numGroups = $("#relayGroups > div").length;
var tabindex = 200 + numGroups * 2;
var template = $("#relayGroupTemplate").children();
var line = $(template).clone();
var element = $("span.relay_id", line);
if (element.length) element.html(numGroups+1);
$(line).find("input").each(function() {
$(this).attr("tabindex", tabindex++);
});
line.appendTo("#relayGroups");
var current = $("#relayConfig > div").length;
if (current > 0) return;
return line;
var template = $("#relayConfigTemplate").children();
for (var i=0; i < data.length; i++) {
var line = $(template).clone();
$("span.gpio", line).html(data[i].gpio);
$("span.id", line).html(i+1);
$("select[name='relayBoot']", line).val(data[i].boot);
$("select[name='relayPulse']", line).val(data[i].pulse);
$("input[name='relayTime']", line).val(data[i].pulse_ms);
$("intut[name='mqttGroup']", line).val(data[i].group || 0);
$("select[name='mqttGroupInv']", line).val(data[i].group_inv || 0);
line.appendTo("#relayConfig");
}
} }
@ -831,26 +842,9 @@ function processData(data) {
return; return;
} }
// Relay groups
if (key == "relayGroups") {
var groups = data.relayGroups;
for (var i in groups) {
// add a new row
var line = addRelayGroup();
// fill in the blanks
var group = data.relayGroups[i];
Object.keys(group).forEach(function(key) {
var element = $("input[name=" + key + "]", line);
if (element.length) element.val(group[key]);
});
}
return;
// Relay configuration
if (key == "relayConfig") {
initRelayConfig(data[key]);
} }
// --------------------------------------------------------------------- // ---------------------------------------------------------------------


+ 32
- 46
code/html/index.html View File

@ -333,19 +333,7 @@
<fieldset> <fieldset>
<div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4">Switch boot mode</label>
<div class="pure-u-1 pure-u-md-3-4">
<select name="relayMode" class="pure-u-3-4" tabindex="2">
<option value="0">Always OFF</option>
<option value="1">Always ON</option>
<option value="2">Same as before</option>
<option value="3">Toogle before</option>
</select>
</div>
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">Here you can define what will be the status of the switch after a reboot.</div>
</div>
<div class="pure-g module module-multirelay"><legend>General</legend></div>
<div class="pure-g module module-multirelay"> <div class="pure-g module module-multirelay">
<label class="pure-u-1 pure-u-md-1-4">Switch sync mode</label> <label class="pure-u-1 pure-u-md-1-4">Switch sync mode</label>
@ -361,34 +349,7 @@
<div class="pure-u-1 pure-u-md-3-4 hint">Define how the different switches should be synchronized.</div> <div class="pure-u-1 pure-u-md-3-4 hint">Define how the different switches should be synchronized.</div>
</div> </div>
<div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4">Switch pulse mode</label>
<div class="pure-u-1 pure-u-md-3-4">
<select name="relayPulseMode" class="pure-u-3-4" tabindex="4">
<option value="0">Don't pulse</option>
<option value="1">Normally OFF (stays on for a short time)</option>
<option value="2">Normally ON (stays off for a short time)</option>
</select>
</div>
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">When pulse mode is enabled the switch will automatically switch back to its normal state after the pulse time (below).</div>
</div>
<div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4">Switch pulse time</label>
<input name="relayPulseTime" class="pure-u-1 pure-u-md-3-4" type="number" min="0" step="0.1" max="3600" tabindex="5" />
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">Pulse time in seconds (maximum value is 3600s, i.e. 1 hour, accepts decimals).</div>
</div>
<div class="pure-g">
<legend>MQTT group topics</legend>
</div>
<div id="relayGroups" class="module module-mqtt">
</div>
<div id="relayConfig"></div>
</fieldset> </fieldset>
@ -945,7 +906,7 @@
</div> <!-- layout --> </div> <!-- layout -->
<!-- Templates -->
<!-- Templates -------------------------------------------------------->
<div id="rfbNodeTemplate" class="template"> <div id="rfbNodeTemplate" class="template">
@ -1028,11 +989,36 @@
</div> </div>
</div> </div>
<div id="relayGroupTemplate" class="template">
<div id="relayConfigTemplate" class="template">
<div class="pure-g"><legend>Switch #<span class="id"></span> (GPIO<span class="gpio"></span>)</legend></div>
<div class="pure-g"> <div class="pure-g">
<div class="pure-u-1 pure-u-sm-1-4"><label>Switch <span class="relay_id"></span></label></div>
<div class="pure-u-1 pure-u-sm-1-2"><input class="pure-u-sm-23-24" name="mqttGroup" tabindex="0" data="0" /></div>
<select class="pure-u-1 pure-u-sm-1-4" name="mqttGroupInv">
<div class="pure-u-1 pure-u-sm-1-4"><label>Boot mode</label></div>
<select class="pure-u-1 pure-u-sm-3-4" name="relayBoot">
<option value="0">Always OFF</option>
<option value="1">Always ON</option>
<option value="2">Same as before</option>
<option value="3">Toogle before</option>
</select>
</div>
<div class="pure-g">
<div class="pure-u-1 pure-u-sm-1-4"><label>Pulse mode</label></div>
<select class="pure-u-1 pure-u-sm-3-4" name="relayPulse">
<option value="0">Don't pulse</option>
<option value="1">Normally OFF</option>
<option value="2">Normally ON</option>
</select>
</div>
<div class="pure-g">
<div class="pure-u-1 pure-u-sm-1-4"><label>Pulse time (s)</label></div>
<div class="pure-u-1 pure-u-sm-1-4"><input name="relayTime" class="pure-u-23-24" type="number" min="0" step="0.1" max="3600" /></div>
</div>
<div class="pure-g module module-mqtt">
<div class="pure-u-1 pure-u-sm-1-4"><label>MQTT group</label></div>
<div class="pure-u-1 pure-u-sm-3-4"><input class="pure-u-23-24" name="mqttGroup" tabindex="0" data="0" action="reconnect" /></div>
</div>
<div class="pure-g module module-mqtt">
<div class="pure-u-1 pure-u-sm-1-4"><label>MQTT group sync</label></div>
<select class="pure-u-1 pure-u-sm-3-4" name="mqttGroupInv">
<option value="0">Same</option> <option value="0">Same</option>
<option value="1">Inverse</option> <option value="1">Inverse</option>
</select> </select>


Loading…
Cancel
Save