From de41a88becf7485e563ef3ea07a14a6cb9ba2a89 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 1 Feb 2019 14:05:55 +0100 Subject: [PATCH 1/7] Fix stop flash rotate functionality Fix stop flash rotate functionality --- sonoff/settings.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonoff/settings.ino b/sonoff/settings.ino index 13634d541..55a73fc56 100644 --- a/sonoff/settings.ino +++ b/sonoff/settings.ino @@ -472,7 +472,7 @@ void SettingsLoad(void) if (Settings.save_flag > save_flag) { save_flag = Settings.save_flag; settings_location = flash_location; - if (Settings.flag.stop_flash_rotate) { + if (Settings.flag.stop_flash_rotate && (0 == i)) { // Stop only if eeprom area should be used and it is valid break; } } From edb0cf8f699c6e2a9f07cb2020ee0fac042ec8d7 Mon Sep 17 00:00:00 2001 From: netpok Date: Fri, 1 Feb 2019 14:54:35 +0100 Subject: [PATCH 2/7] Add WAGA life CHCZ02MB device --- sonoff/sonoff_template.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index 99f4d1458..08d731b5e 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -293,6 +293,7 @@ enum SupportedModules { ZX2820, MI_DESK_LAMP, SP10, + WAGA, MAXMODULE }; /********************************************************************************************/ @@ -574,6 +575,7 @@ const uint8_t kModuleNiceList[MAXMODULE] PROGMEM = { DIGOO, KA10, SP10, + WAGA, NEO_COOLCAM, // Socket Relay Devices OBI, OBI2, @@ -1814,6 +1816,26 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { GPIO_LED1, // GPIO13 Blue LED - Link status GPIO_REL1, // GPIO14 Relay 1 and red LED 0, 0, 0 + }, + { "WAGA CHCZ02MB", // WAGA life CHCZ02MB (HJL-01 Energy Monitoring) + // https://www.ebay.com/itm/332595697006 + GPIO_LED1, // GPIO00 Red LED + 0, // GPIO01 Serial TX + 0, // GPIO02 + GPIO_NRG_SEL_INV, // GPIO03 HJL-01 Sel output (1 = Voltage) + 0, // GPIO04 + GPIO_HJL_CF, // GPIO05 HJL-01 CF power + // GPIO06 (SD_CLK Flash) + // GPIO07 (SD_DATA0 Flash QIO/DIO/DOUT) + // GPIO08 (SD_DATA1 Flash QIO/DIO/DOUT) + 0, // GPIO09 (SD_DATA2 Flash QIO or ESP8285) + 0, // GPIO10 (SD_DATA3 Flash QIO or ESP8285) + // GPIO11 (SD_CMD Flash) + GPIO_REL1, // GPIO12 Relay + GPIO_KEY1, // GPIO13 Button + GPIO_NRG_CF1, // GPIO14 HJL-01 CF1 voltage / current + GPIO_LED2, // GPIO15 Blue LED - Link status + 0, 0 } }; From 1bb22c06a6c15198a6f3ff6fa442e1eef2b8f107 Mon Sep 17 00:00:00 2001 From: netpok Date: Fri, 1 Feb 2019 14:55:33 +0100 Subject: [PATCH 3/7] Update SP10 descriptions --- sonoff/sonoff_template.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index 08d731b5e..598d03e80 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -1798,7 +1798,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { GPIO_ROT_B, // GPIO13 Rotary switch B pin 0, 0, 0, 0 }, - { "SP10", // Tuya SP10 (ESP8285 - BL0937 Energy Monitoring) + { "SP10", // Tuya SP10 (BL0937 Energy Monitoring) // https://www.aliexpress.com/item/Smart-Mini-WiFi-Plug-Outlet-Switch-Work-With-ForEcho-Alexa-Google-Home-Remote-EU-Smart-Socket/32963670423.html 0, // GPIO00 GPIO_PWM1, // GPIO01 Nightlight @@ -1814,7 +1814,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { // GPIO11 (SD_CMD Flash) GPIO_NRG_SEL_INV, // GPIO12 BL0937 Sel output (1 = Voltage) GPIO_LED1, // GPIO13 Blue LED - Link status - GPIO_REL1, // GPIO14 Relay 1 and red LED + GPIO_REL1, // GPIO14 Relay and red LED 0, 0, 0 }, { "WAGA CHCZ02MB", // WAGA life CHCZ02MB (HJL-01 Energy Monitoring) From b927237aad9e6a828f77f934b7dc18d7c93a3451 Mon Sep 17 00:00:00 2001 From: netpok Date: Fri, 1 Feb 2019 15:01:45 +0100 Subject: [PATCH 4/7] Fix LED numbering --- sonoff/sonoff_template.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index 598d03e80..fa7d7d546 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -1819,7 +1819,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { }, { "WAGA CHCZ02MB", // WAGA life CHCZ02MB (HJL-01 Energy Monitoring) // https://www.ebay.com/itm/332595697006 - GPIO_LED1, // GPIO00 Red LED + GPIO_LED2, // GPIO00 Red LED 0, // GPIO01 Serial TX 0, // GPIO02 GPIO_NRG_SEL_INV, // GPIO03 HJL-01 Sel output (1 = Voltage) @@ -1834,7 +1834,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { GPIO_REL1, // GPIO12 Relay GPIO_KEY1, // GPIO13 Button GPIO_NRG_CF1, // GPIO14 HJL-01 CF1 voltage / current - GPIO_LED2, // GPIO15 Blue LED - Link status + GPIO_LED1, // GPIO15 Blue LED - Link status 0, 0 } }; From 7e56dc538dda9eb2ea08a72ce265ed79e92dd6ed Mon Sep 17 00:00:00 2001 From: andrethomas Date: Fri, 1 Feb 2019 18:46:37 +0200 Subject: [PATCH 5/7] MHZ19: Allow enable and disable of ABC --- sonoff/settings.h | 17 +++++++++++++++-- sonoff/xsns_15_mhz19.ino | 37 ++++++++++++++++++++++++++----------- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/sonoff/settings.h b/sonoff/settings.h index 83a26e311..22f6d940d 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -163,6 +163,20 @@ typedef union { }; } Mcp230xxCfg; +typedef union { + uint8_t data; + struct { + uint8_t spare0 : 1; + uint8_t spare1 : 1; + uint8_t spare2 : 1; + uint8_t spare3 : 1; + uint8_t spare4 : 1; + uint8_t spare5 : 1; + uint8_t spare6 : 1; + uint8_t mhz19b_abc_disable : 1; // Disable ABC (Automatic Baseline Correction for MHZ19(B) (0 = Enabled (default), 1 = Disabled with Sensor15 command) + }; +} SensorCfg1; + /* struct SYSCFG { unsigned long cfg_holder; // 000 Pre v6 header @@ -311,8 +325,7 @@ struct SYSCFG { uint8_t knx_CB_param[MAX_KNX_CB]; // 6EC Type of Output (set relay, toggle relay, reply sensor value) Mcp230xxCfg mcp230xx_config[16]; // 6F6 uint8_t mcp230xx_int_prio; // 716 - - uint8_t free_717[1]; // 717 + SensorCfg1 SensorBits1; // 717 On/Off settings used by Sensor Commands uint16_t mcp230xx_int_timer; // 718 uint8_t rgbwwTable[5]; // 71A diff --git a/sonoff/xsns_15_mhz19.ino b/sonoff/xsns_15_mhz19.ino index 509f9e0bc..747a8125f 100644 --- a/sonoff/xsns_15_mhz19.ino +++ b/sonoff/xsns_15_mhz19.ino @@ -39,7 +39,10 @@ enum MhzFilterOptions {MHZ19_FILTER_OFF, MHZ19_FILTER_OFF_ALLSAMPLES, MHZ19_FILT /*********************************************************************************************\ * Source: http://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf * - * Automatic Baseline Correction (ABC logic function) + * Automatic Baseline Correction (ABC logic function) is enabled by default but may be disabled with command + * Sensor15 0 + * and enabled again with command + * Sensor15 1 * * ABC logic function refers to that sensor itself do zero point judgment and automatic calibration procedure * intelligently after a continuous operation period. The automatic calibration cycle is every 24 hours after powered on. @@ -52,10 +55,6 @@ enum MhzFilterOptions {MHZ19_FILTER_OFF, MHZ19_FILTER_OFF_ALLSAMPLES, MHZ19_FILT * Please do zero calibration timely, such as manual or commend calibration. \*********************************************************************************************/ -#define MHZ19_ABC_ENABLE 1 // Automatic Baseline Correction (0 = off, 1 = on (default)) - -/*********************************************************************************************/ - #include #ifndef CO2_LOW @@ -72,6 +71,9 @@ TasmotaSerial *MhzSerial; const char kMhzModels[] PROGMEM = "|B"; +const char ABC_ENABLED[] PROGMEM = "ABC is Enabled"; +const char ABC_DISABLED[] PROGMEM = "ABC is Enabled"; + enum MhzCommands { MHZ_CMND_READPPM, MHZ_CMND_ABCENABLE, MHZ_CMND_ABCDISABLE, MHZ_CMND_ZEROPOINT, MHZ_CMND_RESET, MHZ_CMND_RANGE_1000, MHZ_CMND_RANGE_2000, MHZ_CMND_RANGE_3000, MHZ_CMND_RANGE_5000 }; const uint8_t kMhzCommands[][4] PROGMEM = { // 2 3 6 7 @@ -88,7 +90,6 @@ const uint8_t kMhzCommands[][4] PROGMEM = { uint8_t mhz_type = 1; uint16_t mhz_last_ppm = 0; uint8_t mhz_filter = MHZ19_FILTER_OPTION; -bool mhz_abc_enable = MHZ19_ABC_ENABLE; bool mhz_abc_must_apply = false; float mhz_temperature = 0; @@ -218,7 +219,7 @@ void MhzEverySecond(void) uint16_t u = (mhz_response[6] << 8) | mhz_response[7]; if (15000 == u) { // During (and only ever at) sensor boot, 'u' is reported as 15000 - if (!mhz_abc_enable) { + if (Settings.SensorBits1.mhz19b_abc_disable) { // After bootup of the sensor the ABC will be enabled. // Thus only actively disable after bootup. mhz_abc_must_apply = true; @@ -235,7 +236,7 @@ void MhzEverySecond(void) if (0 == s || 64 == s) { // Reading is stable. if (mhz_abc_must_apply) { mhz_abc_must_apply = false; - if (mhz_abc_enable) { + if (!Settings.SensorBits1.mhz19b_abc_disable) { MhzSendCmd(MHZ_CMND_ABCENABLE); } else { MhzSendCmd(MHZ_CMND_ABCDISABLE); @@ -252,8 +253,8 @@ void MhzEverySecond(void) /*********************************************************************************************\ * Command Sensor15 * - * 0 - (Not implemented) ABC Off - * 1 - (Not implemented) ABC On + * 0 - ABC Off + * 1 - ABC On (Default) * 2 - Manual start = ABC Off * 3 - (Not implemented) Optional filter settings * 9 - Reset @@ -273,6 +274,16 @@ bool MhzCommandSensor(void) bool serviced = true; switch (XdrvMailbox.payload) { + case 0: + Settings.SensorBits1.mhz19b_abc_disable = true; + MhzSendCmd(MHZ_CMND_ABCDISABLE); + snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, ABC_DISABLED); + break; + case 1: + Settings.SensorBits1.mhz19b_abc_disable = false; + MhzSendCmd(MHZ_CMND_ABCENABLE); + snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, ABC_ENABLED); + break; case 2: MhzSendCmd(MHZ_CMND_ZEROPOINT); snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, D_JSON_ZERO_POINT_CALIBRATION); @@ -298,7 +309,11 @@ bool MhzCommandSensor(void) snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, D_JSON_RANGE_5000); break; default: - serviced = false; + if (!Settings.SensorBits1.mhz19b_abc_disable) { + snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, ABC_ENABLED); + } else { + snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, ABC_DISABLED); + } } return serviced; From 4dc1d2f26004554a94df60b72f4a5b0aaa394b6f Mon Sep 17 00:00:00 2001 From: netpok Date: Sat, 2 Feb 2019 01:10:35 +0100 Subject: [PATCH 6/7] Fix led polarity --- sonoff/sonoff_template.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index fa7d7d546..1fbf50bf1 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -1819,7 +1819,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { }, { "WAGA CHCZ02MB", // WAGA life CHCZ02MB (HJL-01 Energy Monitoring) // https://www.ebay.com/itm/332595697006 - GPIO_LED2, // GPIO00 Red LED + GPIO_LED2_INV, // GPIO00 Red LED 0, // GPIO01 Serial TX 0, // GPIO02 GPIO_NRG_SEL_INV, // GPIO03 HJL-01 Sel output (1 = Voltage) @@ -1834,7 +1834,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = { GPIO_REL1, // GPIO12 Relay GPIO_KEY1, // GPIO13 Button GPIO_NRG_CF1, // GPIO14 HJL-01 CF1 voltage / current - GPIO_LED1, // GPIO15 Blue LED - Link status + GPIO_LED1_INV, // GPIO15 Blue LED - Link status 0, 0 } }; From 0c747a74991ed0c257c97809909673c6f55109ae Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 2 Feb 2019 15:16:35 +0100 Subject: [PATCH 7/7] Split module and GPIO ajax list Split module and GPIO ajax list --- sonoff/xdrv_01_webserver.ino | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/sonoff/xdrv_01_webserver.ino b/sonoff/xdrv_01_webserver.ino index 1974e9128..daf45be9f 100644 --- a/sonoff/xdrv_01_webserver.ino +++ b/sonoff/xdrv_01_webserver.ino @@ -145,28 +145,31 @@ const char HTTP_SCRIPT_CONSOL[] PROGMEM = "return false;" "}" ""; - const char HTTP_SCRIPT_MODULE1[] PROGMEM = "var os;" "function sk(s,g){" // s = value, g = id and name - "var o=os.replace(\"value='\"+s+\"'\",\"selected value='\"+s+\"'\");" + "var o=os.replace(/}1/g,\"