From 6c903d4fefd2edab7b2451e66f62ef17d6a59bea Mon Sep 17 00:00:00 2001 From: arendst Date: Wed, 27 Dec 2017 14:10:55 +0100 Subject: [PATCH] v5.10.0d 5.10.0d * Renamed commands Color2,3,4 to Color3,4,5 * Add command Color2 to set color while keeping same dimmer value * Add led signal to Carbon Dioxide (CO2) sensors (see user_config.h) * Fix Wemo Emulation again (#1357) * Updated German translation (#1438) --- README.md | 2 +- sonoff/_releasenotes.ino | 9 ++++- sonoff/language/de-DE.h | 44 +++++++++++----------- sonoff/settings.h | 4 +- sonoff/sonoff.ino | 7 ++-- sonoff/user_config.h | 12 ++++-- sonoff/xdrv_light.ino | 55 ++++++++++++++++++++++----- sonoff/xdrv_wemohue.ino | 75 ++++++++++++++++++++----------------- sonoff/xsns_15_mhz19.ino | 10 ++++- sonoff/xsns_17_senseair.ino | 8 ++++ 10 files changed, 149 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index c2f88067f786..5e05b13ae4c0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ## Sonoff-Tasmota Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE. -Current version is **5.10.0c** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. +Current version is **5.10.0d** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. ### ATTENTION All versions diff --git a/sonoff/_releasenotes.ino b/sonoff/_releasenotes.ino index bab94bd58ef2..c3773add0920 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,4 +1,11 @@ -/* 5.10.0c +/* 5.10.0d + * Renamed commands Color2,3,4 to Color3,4,5 + * Add command Color2 to set color while keeping same dimmer value + * Add led signal to Carbon Dioxide (CO2) sensors (see user_config.h) + * Fix Wemo Emulation again (#1357) + * Updated German translation (#1438) + * + * 5.10.0c * Consolidate device serial (MH-Z19, SenseAir and Pzem004T) into TasmotaSerial library * Consolidate PWM device recognition * Fix Wemo Emulation (#1357) diff --git a/sonoff/language/de-DE.h b/sonoff/language/de-DE.h index 18a7a5d617ea..a89aa29e5a4a 100644 --- a/sonoff/language/de-DE.h +++ b/sonoff/language/de-DE.h @@ -48,10 +48,10 @@ #define D_ACTIVE "aktiv" #define D_ADDRESS "Addresse" #define D_ADMIN "Admin" -#define D_AIR_QUALITY "Ausschlagsqualität" -#define D_AIRQUALITY "AusschlagsQualität" +#define D_AIR_QUALITY "Luftqualität" +#define D_AIRQUALITY "LuftQualität" #define D_AP "AP" // Access Point -#define D_APMAC_ADDRESS "APMac" +#define D_APMAC_ADDRESS "AP-Mac" #define D_APPENDED "angehängt" #define D_AS "wie" #define D_AUTO "AUTO" @@ -66,7 +66,7 @@ #define D_BUTTON "Knopf" #define D_BY "von" // Written by me #define D_CELSIUS "Celsius" -#define D_CO2 "Kohlenstoffdioxid" +#define D_CO2 "CO²" #define D_CODE "code" // Button code #define D_COLDLIGHT "kalt" #define D_COMMAND "Befehl" @@ -92,14 +92,14 @@ #define D_EVERY "alle" #define D_FAHRENHEIT "Fahrenheit" #define D_FAILED "fehlgeschlagen" -#define D_FALLBACK "Rückgriff" -#define D_FALLBACK_TOPIC "Rückgriff topic" -#define D_FALLBACKTOPIC "RückgriffTopic" +#define D_FALLBACK "Fallback" +#define D_FALLBACK_TOPIC "Fallback topic" +#define D_FALLBACKTOPIC "FallbackTopic" #define D_FALSE "falsch" #define D_FILE "Datei" #define D_FLASHMODE "FlashMode" #define D_FLASHSIZE "FlashSize" -#define D_FREE_MEMORY "Freier Speicher" +#define D_FREE_MEMORY "Freier Arbeitsspeicher" #define D_FREEMEMORY "frei" #define D_FROM "von" #define D_GAS "Gas" @@ -144,9 +144,9 @@ #define D_POWERUSAGE "Leistung" #define D_PRESSURE "Druck" #define D_PRESSUREATSEALEVEL "MeeresDruck" -#define D_PROGRAM_FLASH_SIZE "Programm Flash Größe" +#define D_PROGRAM_FLASH_SIZE "Ges. Flash Speicher" #define D_PROGRAMFLASHSIZE "ProgramFlashSize" -#define D_PROGRAM_SIZE "Programmgröße" +#define D_PROGRAM_SIZE "Ben. Flash Speicher" #define D_PROGRAMSIZE "ProgramSize" #define D_PROJECT "Projekt" #define D_RECEIVED "erhalten" @@ -170,7 +170,7 @@ #define D_STARTED "gestartet" #define D_STARTDST "StartDST" // Start Daylight Savings Time #define D_STD_TIME "STD" -#define D_STOP "stopp" +#define D_STOP "Stop" #define D_SUBNET_MASK "Subnetzmaske" #define D_SUBNETMASK "Subnetmaske" #define D_SUBSCRIBE_TO "subscribe to" @@ -244,7 +244,7 @@ #define D_CONNECT_FAILED_WRONG_PASSWORD "Verbindung fehlgeschlagen mit AP weil das Passwort falsch ist" #define D_CONNECT_FAILED_AP_TIMEOUT "Verbindung fehlgeschlagen da der AP nicht antwortet (timeout)" #define D_ATTEMPTING_CONNECTION "Verbindungsversuch..." -#define D_CHECKING_CONNECTION "prüfe Verbindung..." +#define D_CHECKING_CONNECTION "Prüfe Verbindung..." #define D_QUERY_DONE "Suchanfrage abgeschlossen. MQTT-Services gefunden" #define D_MQTT_SERVICE_FOUND "MQTT-Service gefunden bei" #define D_I2CSCAN_DEVICES_FOUND_AT "Gerät(e) gefunden bei" @@ -262,7 +262,7 @@ #define D_REDIRECTED "umgeleitet zu captive portal" #define D_WIFIMANAGER_SET_ACCESSPOINT_AND_STATION "WLAN-Manager AccessPoint gesetzt und behält Station" #define D_WIFIMANAGER_SET_ACCESSPOINT "WLAN-Manager AccessPoint gesetzt" -#define D_TRYING_TO_CONNECT "versuche Gerät mit Netzwerk zu verbinden" +#define D_TRYING_TO_CONNECT "Versuche Gerät mit Netzwerk zu verbinden" #define D_RESTART_IN "Neustart in" #define D_SECONDS "Sekunden" @@ -272,9 +272,9 @@ #define D_INFORMATION "Informationen" #define D_FIRMWARE_UPGRADE "Firmware Update" #define D_CONSOLE "Konsole" -#define D_CONFIRM_RESTART "Neustart bestätigen" +#define D_CONFIRM_RESTART "Wirklich neustarten?" -#define D_CONFIGURE_MODULE "Modul konfigurieren" +#define D_CONFIGURE_MODULE "Gerät konfigurieren" #define D_CONFIGURE_WIFI "WLAN konfigurieren" #define D_CONFIGURE_MQTT "MQTT konfigurieren" #define D_CONFIGURE_DOMOTICZ "Domoticz konfigurieren" @@ -286,8 +286,8 @@ #define D_RESTORE_CONFIGURATION "Konfiguration wiederherstellen" #define D_MAIN_MENU "Hauptmenü" -#define D_MODULE_PARAMETERS "Modul Einstellungen" -#define D_MODULE_TYPE "Modul Typ" +#define D_MODULE_PARAMETERS "Geräte Einstellungen" +#define D_MODULE_TYPE "Geräte Typ" #define D_GPIO "GPIO" #define D_SERIAL_IN "serieller Eingang [serial in]" #define D_SERIAL_OUT "serieller Ausgang [serial out]" @@ -315,8 +315,8 @@ #define D_LOGGING_PARAMETERS "Logging Einstellungen" #define D_LOG_LEVEL "Log level" #define D_MORE_DEBUG "More debug" -#define D_SYSLOG_HOST "Syslog Host" -#define D_SYSLOG_PORT "Syslog Port" +#define D_SYSLOG_HOST "Sys Log Host" +#define D_SYSLOG_PORT "Sys Log Port" #define D_TELEMETRY_PERIOD "Telemetry period" #define D_OTHER_PARAMETERS "Sonstige Einstellungen" @@ -348,8 +348,8 @@ #define D_MDNS_ADVERTISE "mDNS-Bekanntmachung" #define D_ESP_CHIP_ID "ESP Chip ID" #define D_FLASH_CHIP_ID "Flash Chip ID" -#define D_FLASH_CHIP_SIZE "Flash Größe" -#define D_FREE_PROGRAM_SPACE "Freier Programm Speicher" +#define D_FLASH_CHIP_SIZE "Realer Flash Speicher" +#define D_FREE_PROGRAM_SPACE "Verf. Flash Speicher" #define D_UPGRADE_BY_WEBSERVER "Update über Web-Server" #define D_OTA_URL "OTA-URL" @@ -370,7 +370,7 @@ #define D_UPLOAD_ERROR_CODE "Upload Fehler Nummer" #define D_ENTER_COMMAND "Befehl eingeben" -#define D_ENABLE_WEBLOG_FOR_RESPONSE "aktivere weblog 2 falls Reaktion erwartet" +#define D_ENABLE_WEBLOG_FOR_RESPONSE "Aktivere Web Log Level 2 falls Reaktion erwartet" #define D_NEED_USER_AND_PASSWORD "Benutzer benötigt=&password=" // xdrv_domoticz.ino diff --git a/sonoff/settings.h b/sonoff/settings.h index b718bf005e35..4c549e6c7561 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -43,9 +43,9 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t pwm_control : 1; // bit 15 (v5.8.1) uint32_t ws_clock_reverse : 1; // bit 16 (v5.8.1) uint32_t decimal_text : 1; // bit 17 (v5.8.1) - uint32_t spare18 : 1; + uint32_t light_signal : 1; // bit 18 (v5.10.0c) uint32_t spare19 : 1; - uint32_t voltage_resolution : 1; + uint32_t voltage_resolution : 1; // Replaced by below uint32_t spare21 : 1; uint32_t spare22 : 1; uint32_t spare23 : 1; diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index a08318e2aee9..770aab982dd6 100644 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -25,8 +25,8 @@ - Select IDE Tools - Flash Size: "1M (no SPIFFS)" ====================================================*/ -#define VERSION 0x050A0003 -#define VERSION_STRING "5.10.0c" // Would be great to have a macro that fills this from VERSION ... +#define VERSION 0x050A0004 +#define VERSION_STRING "5.10.0d" // Would be great to have a macro that fills this from VERSION ... // Location specific includes #include "sonoff.h" // Enumaration used in user_config.h @@ -986,7 +986,7 @@ void MqttDataCallback(char* topic, byte* data, unsigned int data_len) } snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, (Settings.save_data > 1) ? stemp1 : GetStateText(Settings.save_data)); } - else if ((CMND_SETOPTION == command_code) && ((index >= 0) && (index <= 17)) || ((index > 31) && (index <= P_MAX_PARAM8 +31))) { + else if ((CMND_SETOPTION == command_code) && ((index >= 0) && (index <= 18)) || ((index > 31) && (index <= P_MAX_PARAM8 +31))) { if (index <= 31) { ptype = 0; // SetOption0 .. 31 } else { @@ -1012,6 +1012,7 @@ void MqttDataCallback(char* topic, byte* data, unsigned int data_len) case 14: // interlock case 16: // ws_clock_reverse case 17: // decimal_text + case 18: // light_signal bitWrite(Settings.flag.data, index, payload); } if (12 == index) { // stop_flash_rotate diff --git a/sonoff/user_config.h b/sonoff/user_config.h index dbeb0cca9458..263bbdce627b 100644 --- a/sonoff/user_config.h +++ b/sonoff/user_config.h @@ -163,12 +163,13 @@ // -- Sensor code selection ----------------------- #define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices -//#define USE_PZEM004T // Add support for PZEM004T Energy monitor (+2k code) +#define USE_PZEM004T // Add support for PZEM004T Energy monitor (+2k code) // WARNING: Select none for default one DS18B20 sensor or enable one of the following two options for multiple sensors //#define USE_DS18x20 // Optional for more than one DS18x20 sensors with id sort, single scan and read retry (+1k3 code) //#define USE_DS18x20_LEGACY // Optional for more than one DS18x20 sensors with dynamic scan using library OneWire (+1k5 code) +// -- I2C sensors --------------------------------- #define USE_I2C // I2C using library wire (+10k code, 0k2 mem, 124 iram) #define USE_SHT // Add I2C emulating code for SHT1X sensor (+1k4 code) // #define USE_SHT3X // Add I2C code for SHT3x sensor based on Adafruit (+0k7 code) @@ -184,6 +185,12 @@ // #define USE_ADS1115_I2CDEV // Add I2C code for ADS1115 16 bit A/D converter using library i2cdevlib-Core and i2cdevlib-ADS1115 (+2k code) // #define USE_INA219 // Add I2C code for INA219 Low voltage and current sensor (+1k code) +// -- Carbon dioxide (CO2) sensors ---------------- +#define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k code) +#define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code) + #define CO2_LOW 800 // Below this CO2 value show green light (needs PWM or WS2812 RG(B) led and enable with SetOption18 1) + #define CO2_HIGH 1200 // Above this CO2 value show red light (needs PWM or WS2812 RG(B) led and enable with SetOption18 1) + #define USE_IR_REMOTE // Send IR remote commands using library IRremoteESP8266 and ArduinoJson (+4k code, 0k3 mem, 48 iram) // #define USE_IR_HVAC // Support for HVAC system using IR (+2k code) #define USE_IR_RECEIVE // Support for IR receiver (+5k5 code, 264 iram) @@ -192,9 +199,6 @@ #define USE_WS2812_CTYPE 1 // WS2812 Color type (0 - RGB, 1 - GRB, 2 - RGBW, 3 - GRBW) // #define USE_WS2812_DMA // DMA supports only GPIO03 (= Serial RXD) (+1k mem). When USE_WS2812_DMA is enabled expect Exceptions on Pow -//#define USE_MHZ19 // Add support for MH-Z19 CO2 sensor (+2k code) -//#define USE_SENSEAIR // Add support for SenseAir K30, K70 and S8 CO2 sensor (+2k3 code) - #define USE_ARILUX_RF // Add support for Arilux RF remote controller (+0k8 code) /*********************************************************************************************\ diff --git a/sonoff/xdrv_light.ino b/sonoff/xdrv_light.ino index 3b82f74cf086..9d79eb26cf3f 100644 --- a/sonoff/xdrv_light.ino +++ b/sonoff/xdrv_light.ino @@ -93,6 +93,7 @@ uint8_t light_entry_color[5]; uint8_t light_current_color[5]; uint8_t light_new_color[5]; uint8_t light_last_color[5]; +uint8_t light_signal_color[5]; uint8_t light_wheel = 0; uint8_t light_subtype = 0; @@ -451,7 +452,11 @@ void LightSetDimmer(uint8_t myDimmer) } float dimmer = 100 / (float)myDimmer; for (byte i = 0; i < light_subtype; i++) { - temp = (float)Settings.light_color[i] / dimmer; + if (Settings.flag.light_signal) { + temp = (float)light_signal_color[i] / dimmer; + } else { + temp = (float)Settings.light_color[i] / dimmer; + } light_current_color[i] = (uint8_t)temp; } } @@ -474,6 +479,34 @@ void LightSetColor() } } +void LightSetSignal(uint16_t lo, uint16_t hi, uint16_t value) +{ +/* lo - below lo is green + hi - above hi is red +*/ + if (Settings.flag.light_signal) { + uint16_t signal = 0; + if (value > lo) { + signal = (value - lo) * 10 / ((hi - lo) * 10 / 256); + if (signal > 255) { + signal = 255; + } + } +// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "Light signal %d"), signal); +// AddLog(LOG_LEVEL_DEBUG); + light_signal_color[0] = signal; + light_signal_color[1] = 255 - signal; + light_signal_color[2] = 0; + light_signal_color[3] = 0; + light_signal_color[4] = 0; + + Settings.light_scheme = 0; + if (!Settings.light_dimmer) { + Settings.light_dimmer = 20; + } + } +} + char* LightGetColor(uint8_t type, char* scolor) { LightSetDimmer(Settings.light_dimmer); @@ -969,32 +1002,36 @@ boolean LightCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_le char option = (1 == data_len) ? dataBuf[0] : '\0'; int command_code = GetCommandCode(command, sizeof(command), type, kLightCommands); - if ((CMND_COLOR == command_code) && (light_subtype > LST_SINGLE) && (index > 0) && (index <= 4)) { + if ((CMND_COLOR == command_code) && (light_subtype > LST_SINGLE) && (index > 0) && (index <= 5)) { if (data_len > 0) { valid_entry = LightColorEntry(dataBuf, data_len); if (valid_entry) { - if (1 == index) { // Color(1) + if (index <= 2) { // Color(1), 2 memcpy(light_current_color, light_entry_color, sizeof(light_current_color)); + uint8_t dimmer = Settings.light_dimmer; LightSetColor(); + if (2 == index) { + Settings.light_dimmer = dimmer; + } Settings.light_scheme = 0; coldim = true; - } else { // Color2, 3 and 4 + } else { // Color3, 4 and 5 for (byte i = 0; i < LST_RGB; i++) { - Settings.ws_color[index -2][i] = light_entry_color[i]; + Settings.ws_color[index -3][i] = light_entry_color[i]; } } } } - if (!valid_entry && (1 == index)) { + if (!valid_entry && (index <= 2)) { snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, LightGetColor(0, scolor)); } - if (index > 1) { + if (index >= 3) { scolor[0] = '\0'; for (byte i = 0; i < LST_RGB; i++) { if (Settings.flag.decimal_text) { - snprintf_P(scolor, 25, PSTR("%s%s%d"), scolor, (i > 0) ? "," : "", Settings.ws_color[index -2][i]); + snprintf_P(scolor, 25, PSTR("%s%s%d"), scolor, (i > 0) ? "," : "", Settings.ws_color[index -3][i]); } else { - snprintf_P(scolor, 25, PSTR("%s%02X"), scolor, Settings.ws_color[index -2][i]); + snprintf_P(scolor, 25, PSTR("%s%02X"), scolor, Settings.ws_color[index -3][i]); } } snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, command, index, scolor); diff --git a/sonoff/xdrv_wemohue.ino b/sonoff/xdrv_wemohue.ino index 08236023542d..e441cf5138e9 100755 --- a/sonoff/xdrv_wemohue.ino +++ b/sonoff/xdrv_wemohue.ino @@ -241,43 +241,51 @@ void PollUdp() \*********************************************************************************************/ const char WEMO_EVENTSERVICE_XML[] PROGMEM = - "" - "" - "" - "SetBinaryState" - "" - "" - "" - "BinaryState" - "BinaryState" - "in" - "" - "" - "" - "" - "BinaryState" - "Boolean" - "0" - "" - "" - "level" - "string" - "0" - "" - "" - "" - "\r\n" - "\r\n"; + // XosePerez version 20171108 - v2.3.0 + "" + "" + "10" + "" + "" + "SetBinaryState" + "" + "" + "" + "BinaryState" + "BinaryState" + "in" + "" + "" + "" + "" + "GetBinaryState" + "" + "" + "" + "BinaryState" + "BinaryState" + "out" + "" + "" + "" + "" + "" + "" + "BinaryState" + "Boolean" + "0" + "" + "" + ""; const char WEMO_RESPONSE_STATE_SOAP[] PROGMEM = "" "" - "" + "" "{x1" - "" + "" "" - "\r\n" - "\r\n"; + ""; const char WEMO_SETUP_XML[] PROGMEM = "" @@ -301,8 +309,7 @@ const char WEMO_SETUP_XML[] PROGMEM = "" "" "" - "\r\n" - "\r\n"; + ""; /********************************************************************************************/ @@ -321,7 +328,7 @@ void HandleUpnpEvent() } } else if(request.indexOf(F("GetBinaryState")) > 0){ - state_xml.replace("Set", "Get"); + state_xml.replace(F("SetBinaryState"), F("GetBinaryStateResponse")); } state_xml.replace("{x1", String(bitRead(power, devices_present -1))); WebServer->send(200, FPSTR(HDR_CTYPE_XML), state_xml); diff --git a/sonoff/xsns_15_mhz19.ino b/sonoff/xsns_15_mhz19.ino index 7f5e56aa835f..859f19c56636 100644 --- a/sonoff/xsns_15_mhz19.ino +++ b/sonoff/xsns_15_mhz19.ino @@ -54,11 +54,18 @@ enum MhzFilterOptions {MHZ19_FILTER_OFF, MHZ19_FILTER_OFF_ALLSAMPLES, MHZ19_FILT #include -TasmotaSerial *MhzSerial; +#ifndef CO2_LOW +#define CO2_LOW 800 // Below this CO2 value show green light +#endif +#ifndef CO2_HIGH +#define CO2_HIGH 1200 // Above this CO2 value show red light +#endif #define MHZ19_READ_TIMEOUT 500 // Must be way less than 1000 #define MHZ19_RETRY_COUNT 8 +TasmotaSerial *MhzSerial; + const char kMhzTypes[] PROGMEM = "MHZ19|MHZ19B"; const uint8_t mhz_cmnd_read_ppm[9] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79}; @@ -180,6 +187,7 @@ void Mhz50ms() mhz_type = (s) ? 1 : 2; if (MhzCheckAndApplyFilter(ppm, s)) { mhz_retry = MHZ19_RETRY_COUNT; + LightSetSignal(CO2_LOW, CO2_HIGH, mhz_last_ppm); if (0 == s || 64 == s) { // Reading is stable. if (mhz_abc_must_apply) { diff --git a/sonoff/xsns_17_senseair.ino b/sonoff/xsns_17_senseair.ino index c3457af18b97..6b23a5a694e0 100644 --- a/sonoff/xsns_17_senseair.ino +++ b/sonoff/xsns_17_senseair.ino @@ -26,6 +26,13 @@ #include +#ifndef CO2_LOW +#define CO2_LOW 800 // Below this CO2 value show green light +#endif +#ifndef CO2_HIGH +#define CO2_HIGH 1200 // Above this CO2 value show red light +#endif + TasmotaSerial *SensairSerial; const char kSenseairTypes[] PROGMEM = "Kx0|S8"; @@ -131,6 +138,7 @@ void Senseair50ms() // Every 50 mSec break; case 2: // 0x03 (3) READ_CO2 - fe 04 02 06 2c af 59 senseair_co2 = value; + LightSetSignal(CO2_LOW, CO2_HIGH, senseair_co2); break; case 3: // 0x04 (4) READ_TEMPERATURE - S8: fe 84 02 f2 f1 - Illegal Data Address senseair_temperature = ConvertTemp((float)value / 100);