diff --git a/README.md b/README.md index 88755b9e3..c2e18f479 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.8.0d** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information. +Current version is **5.8.0e** - 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 fa0ce80fd..b7710deab 100644 --- a/sonoff/_releasenotes.ino +++ b/sonoff/_releasenotes.ino @@ -1,4 +1,8 @@ -/* 5.8.0d +/* 5.8.0e + * Add Domoticz counter sensor to Sonoff Bridge representing Received RF code (#943) + * Add support for Luani HVIO board (https://luani.de/projekte/esp8266-hvio/) (#953) + * + * 5.8.0d * Remove previous GPIO configuration when another module is selected * Fix inverted relay power on state (#909) * Change default PWM assignments for H801 RGB(CW) led controller to support optional Color/Dimmer control diff --git a/sonoff/sonoff.ino b/sonoff/sonoff.ino index c67c00db4..628cb1f27 100644 --- a/sonoff/sonoff.ino +++ b/sonoff/sonoff.ino @@ -25,7 +25,7 @@ - Select IDE Tools - Flash Size: "1M (no SPIFFS)" ====================================================*/ -#define VERSION 0x05080004 // 5.8.0d +#define VERSION 0x05080005 // 5.8.0e enum week_t {Last, First, Second, Third, Fourth}; enum dow_t {Sun=1, Mon, Tue, Wed, Thu, Fri, Sat}; diff --git a/sonoff/sonoff_template.h b/sonoff/sonoff_template.h index 940b45071..ef9e870fd 100644 --- a/sonoff/sonoff_template.h +++ b/sonoff/sonoff_template.h @@ -160,6 +160,7 @@ enum module_t { WITTY, YUNSHAN, MAGICHOME, + LUANIHVIO, MAXMODULE }; /********************************************************************************************/ @@ -202,6 +203,7 @@ const uint8_t nicelist[MAXMODULE] PROGMEM = { ELECTRODRAGON, EXS_RELAY, SUPLA1, + LUANIHVIO, YUNSHAN, WION, H801, @@ -664,6 +666,21 @@ const mytmplt modules[MAXMODULE] PROGMEM = { GPIO_USER, // GPIO13 RGBW LED White (optional - set to PWM4 for Cold White or Warm White) GPIO_PWM1, // GPIO14 RGB LED Red 0, 0, 0 + }, + { "Luani HVIO", // ESP8266_HVIO - https://luani.de/projekte/esp8266-hvio/ + 0, // GPIO00 Flash jumper + GPIO_USER, // GPIO01 Serial RXD and Optional sensor + GPIO_USER, // GPIO02 Optional sensor / I2C SDA pad + GPIO_USER, // GPIO03 Serial TXD and Optional sensor + GPIO_REL1, // GPIO04 Relay 1 (0 = Off, 1 = On) + GPIO_REL2, // GPIO05 Relay 2 (0 = Off, 1 = On) + 0, 0, 0, 0, 0, 0, // Flash connection + GPIO_SWT1, // GPIO12 External input 1 (0 = On, 1 = Off) + GPIO_SWT2, // GPIO13 External input 2 (0 = On, 1 = Off) + GPIO_USER, // GPIO14 Optional sensor / I2C SCL pad + GPIO_LED1, // GPIO15 Led (1 = On, 0 = Off) + 0, + GPIO_ADC0 // ADC0 A0 Analog input } }; diff --git a/sonoff/xdrv_domoticz.ino b/sonoff/xdrv_domoticz.ino index fcd514673..98a64f0eb 100644 --- a/sonoff/xdrv_domoticz.ino +++ b/sonoff/xdrv_domoticz.ino @@ -19,8 +19,6 @@ #ifdef USE_DOMOTICZ -#define DOMOTICZ_MAX_SENSORS 8 - #ifdef USE_WEBSERVER const char HTTP_FORM_DOMOTICZ[] PROGMEM = "
 " D_DOMOTICZ_PARAMETERS " 
" @@ -37,8 +35,26 @@ const char HTTP_FORM_DOMOTICZ_TIMER[] PROGMEM = "" D_DOMOTICZ_UPDATE_TIMER " (" STR(DOMOTICZ_UPDATE_TIMER) ")"; #endif // USE_WEBSERVER -const char domoticz_sensors[DOMOTICZ_MAX_SENSORS][DOMOTICZ_SENSORS_MAX_STRING_LENGTH] PROGMEM = - { D_DOMOTICZ_TEMP, D_DOMOTICZ_TEMP_HUM, D_DOMOTICZ_TEMP_HUM_BARO, D_DOMOTICZ_POWER_ENERGY, D_DOMOTICZ_ILLUMINANCE, D_DOMOTICZ_COUNT, D_DOMOTICZ_VOLTAGE, D_DOMOTICZ_CURRENT }; +enum domoticz_sensors_t { + DZ_TEMP, + DZ_TEMP_HUM, + DZ_TEMP_HUM_BARO, + DZ_POWER_ENERGY, + DZ_ILLUMINANCE, + DZ_COUNT, + DZ_VOLTAGE, + DZ_CURRENT, + DZ_MAX_SENSORS }; + +const char domoticz_sensors[DZ_MAX_SENSORS][DOMOTICZ_SENSORS_MAX_STRING_LENGTH] PROGMEM = { + D_DOMOTICZ_TEMP, + D_DOMOTICZ_TEMP_HUM, + D_DOMOTICZ_TEMP_HUM_BARO, + D_DOMOTICZ_POWER_ENERGY, + D_DOMOTICZ_ILLUMINANCE, + D_DOMOTICZ_COUNT, + D_DOMOTICZ_VOLTAGE, + D_DOMOTICZ_CURRENT }; char domoticz_in_topic[] = DOMOTICZ_IN_TOPIC; char domoticz_out_topic[] = DOMOTICZ_OUT_TOPIC; @@ -49,10 +65,10 @@ byte domoticz_update_flag = 1; void mqtt_publishDomoticzPowerState(byte device) { + if ((device < 1) || (device > Maxdevice)) { + device = 1; + } if (sysCfg.flag.mqtt_enabled && sysCfg.domoticz_relay_idx[device -1]) { - if ((device < 1) || (device > Maxdevice)) { - device = 1; - } if (sfl_flg) { snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"idx\":%d,\"nvalue\":2,\"svalue\":\"%d\"}"), sysCfg.domoticz_relay_idx[device -1], sysCfg.led_dimmer[device -1]); @@ -135,7 +151,7 @@ boolean domoticz_mqttData(char *topicBuf, uint16_t stopicBuf, char *dataBuf, uin int16_t found = 0; domoticz_update_flag = 1; - if (!strncmp(topicBuf, domoticz_out_topic, strlen(domoticz_out_topic)) != 0) { + if (!strncmp(topicBuf, domoticz_out_topic, strlen(domoticz_out_topic))) { if (sdataBuf < 20) { return 1; } @@ -153,12 +169,13 @@ boolean domoticz_mqttData(char *topicBuf, uint16_t stopicBuf, char *dataBuf, uin snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DOMOTICZ "idx %d, nvalue %d"), idx, nvalue); addLog(LOG_LEVEL_DEBUG_MORE); - if (nvalue >= 0 && nvalue <= 2) { + if ((idx > 0) && (nvalue >= 0) && (nvalue <= 2)) { for (byte i = 0; i < Maxdevice; i++) { - if ((idx > 0) && (idx == sysCfg.domoticz_relay_idx[i])) { + if (idx == sysCfg.domoticz_relay_idx[i]) { snprintf_P(stemp1, sizeof(stemp1), PSTR("%d"), i +1); if (2 == nvalue) { nvalue = domoticz["svalue1"]; +// if (sfl_flg && (sysCfg.led_dimmer[i] == nvalue) && ((power >> i) &1)) { // Unable to power off using webpage due to Domoticz re-sends dimmer state if (sfl_flg && (sysCfg.led_dimmer[i] == nvalue)) { return 1; } @@ -218,7 +235,7 @@ boolean domoticz_command(const char *type, uint16_t index, char *dataBuf, uint16 } snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_CMND_DOMOTICZ D_CMND_SWITCHIDX "%d\":%d}"), index, sysCfg.domoticz_key_idx[index -1]); } - else if (!strcasecmp_P(type +dmtcz_len, PSTR(D_CMND_SENSORIDX)) && (index > 0) && (index <= DOMOTICZ_MAX_SENSORS)) { + else if (!strcasecmp_P(type +dmtcz_len, PSTR(D_CMND_SENSORIDX)) && (index > 0) && (index <= DZ_MAX_SENSORS)) { if (payload >= 0) { sysCfg.domoticz_sensor_idx[index -1] = payload; } @@ -271,46 +288,34 @@ void domoticz_sensor(byte idx, char *data) } } -// domoticz_sensor(0, temp); +void domoticz_sensor(byte idx, uint32_t value) +{ + char data[16]; + snprintf_P(data, sizeof(data), PSTR("%d"), value); + domoticz_sensor(idx, data); +} void domoticz_sensor2(char *temp, char *hum) { char data[16]; snprintf_P(data, sizeof(data), PSTR("%s;%s;%d"), temp, hum, dom_hum_stat(hum)); - domoticz_sensor(1, data); + domoticz_sensor(DZ_TEMP_HUM, data); } void domoticz_sensor3(char *temp, char *hum, char *baro) { char data[32]; snprintf_P(data, sizeof(data), PSTR("%s;%s;%d;%s;5"), temp, hum, dom_hum_stat(hum), baro); - domoticz_sensor(2, data); + domoticz_sensor(DZ_TEMP_HUM_BARO, data); } void domoticz_sensor4(uint16_t power, char *energy) { char data[16]; snprintf_P(data, sizeof(data), PSTR("%d;%s"), power, energy); - domoticz_sensor(3, data); + domoticz_sensor(DZ_POWER_ENERGY, data); } -void domoticz_sensor5(uint16_t lux) -{ - char data[8]; - snprintf_P(data, sizeof(data), PSTR("%d"), lux); - domoticz_sensor(4, data); -} - -void domoticz_sensor6(uint32_t count) -{ - char data[16]; - snprintf_P(data, sizeof(data), PSTR("%d"), count); - domoticz_sensor(5, data); -} - -// domoticz_sensor(6, voltage); -// domoticz_sensor(7, current); - /*********************************************************************************************\ * Presentation \*********************************************************************************************/ @@ -343,7 +348,7 @@ void handleDomoticz() } page.replace("{1", String(i +1)); } - for (int i = 0; i < DOMOTICZ_MAX_SENSORS; i++) { + for (int i = 0; i < DZ_MAX_SENSORS; i++) { page += FPSTR(HTTP_FORM_DOMOTICZ_SENSOR); page.replace("{1", String(i +1)); snprintf_P(stemp, sizeof(stemp), domoticz_sensors[i]); @@ -370,7 +375,7 @@ void domoticz_saveSettings() snprintf_P(stemp, sizeof(stemp), PSTR("s%d"), i +1); sysCfg.domoticz_switch_idx[i] = (!strlen(webServer->arg(stemp).c_str())) ? 0 : atoi(webServer->arg(stemp).c_str()); } - for (byte i = 0; i < DOMOTICZ_MAX_SENSORS; i++) { + for (byte i = 0; i < DZ_MAX_SENSORS; i++) { snprintf_P(stemp, sizeof(stemp), PSTR("l%d"), i +1); sysCfg.domoticz_sensor_idx[i] = (!strlen(webServer->arg(stemp).c_str())) ? 0 : atoi(webServer->arg(stemp).c_str()); } diff --git a/sonoff/xdrv_snfbridge.ino b/sonoff/xdrv_snfbridge.ino index 4d366eb76..fcdbd13f8 100644 --- a/sonoff/xdrv_snfbridge.ino +++ b/sonoff/xdrv_snfbridge.ino @@ -89,6 +89,9 @@ void sb_received() snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_RFRECEIVED "\":{\"" D_SYNC "\":%d, \"" D_LOW "\":%d, \"" D_HIGH "\":%d, \"" D_DATA "\":\"%06X\", \"" D_CMND_RFKEY "\":%s}}"), rsy, rlo, rhi, rid, rfkey); mqtt_publish_topic_P(6, PSTR(D_RFRECEIVED)); +#ifdef USE_DOMOTICZ + domoticz_sensor(DZ_COUNT, rid); // Send rid as Domoticz Counter value + #endif // USE_DOMOTICZ } } } @@ -139,6 +142,10 @@ void sb_send(uint8_t idx, uint8_t key) Serial.write(code); Serial.write(0x55); // End of Text Serial.flush(); +#ifdef USE_DOMOTICZ +// uint32_t rid = sysCfg.sfb_code[idx][6] << 16 | sysCfg.sfb_code[idx][7] << 8 | code; +// domoticz_sensor(DZ_COUNT, rid); // Send rid as Domoticz Counter value +#endif // USE_DOMOTICZ } void sb_learn(uint8_t key) diff --git a/sonoff/xdrv_snfsc.ino b/sonoff/xdrv_snfsc.ino index c6ed4c767..5fb43951d 100644 --- a/sonoff/xdrv_snfsc.ino +++ b/sonoff/xdrv_snfsc.ino @@ -120,7 +120,7 @@ void sc_mqttPresent(uint8_t* djson) *djson = 1; #ifdef USE_DOMOTICZ domoticz_sensor2(stemp1, stemp2); - domoticz_sensor5(sc_value[2]); + domoticz_sensor(DZ_ILLUMINANCE, sc_value[2]); #endif // USE_DOMOTICZ } } diff --git a/sonoff/xsns_bh1750.ino b/sonoff/xsns_bh1750.ino index 310302bdb..95d783fb4 100644 --- a/sonoff/xsns_bh1750.ino +++ b/sonoff/xsns_bh1750.ino @@ -88,7 +88,7 @@ void bh1750_mqttPresent(uint8_t* djson) snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"%s\":{\"" D_ILLUMINANCE "\":%d}"), mqtt_data, bh1750stype, l); *djson = 1; #ifdef USE_DOMOTICZ - domoticz_sensor5(l); + domoticz_sensor(DZ_ILLUMINANCE, l); #endif // USE_DOMOTICZ } diff --git a/sonoff/xsns_counter.ino b/sonoff/xsns_counter.ino index 54e51c917..5df3f924d 100644 --- a/sonoff/xsns_counter.ino +++ b/sonoff/xsns_counter.ino @@ -102,7 +102,7 @@ void counter_mqttPresent(uint8_t* djson) *djson = 1; #ifdef USE_DOMOTICZ if (1 == dsxflg) { - domoticz_sensor6(rtcMem.pCounter[i]); + domoticz_sensor(DZ_COUNT, rtcMem.pCounter[i]); dsxflg++; } #endif // USE_DOMOTICZ diff --git a/sonoff/xsns_ds18b20.ino b/sonoff/xsns_ds18b20.ino index d8f41b205..f859ce743 100644 --- a/sonoff/xsns_ds18b20.ino +++ b/sonoff/xsns_ds18b20.ino @@ -195,7 +195,7 @@ void dsb_mqttPresent(uint8_t* djson) snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s, \"DS18B20\":{\"" D_TEMPERATURE "\":%s}"), mqtt_data, stemp1); *djson = 1; #ifdef USE_DOMOTICZ - domoticz_sensor(0, stemp1); + domoticz_sensor(DZ_TEMP, stemp1); #endif // USE_DOMOTICZ } } diff --git a/sonoff/xsns_ds18x20.ino b/sonoff/xsns_ds18x20.ino index 4c50359e7..ef0db3a2f 100644 --- a/sonoff/xsns_ds18x20.ino +++ b/sonoff/xsns_ds18x20.ino @@ -202,7 +202,7 @@ void ds18x20_mqttPresent(uint8_t* djson) strcpy(stemp1, ", "); #ifdef USE_DOMOTICZ if (1 == dsxflg) { - domoticz_sensor(0, stemp2); + domoticz_sensor(DZ_TEMP, stemp2); } #endif // USE_DOMOTICZ } diff --git a/sonoff/xsns_hlw8012.ino b/sonoff/xsns_hlw8012.ino index 604dcf483..ea9a222b1 100644 --- a/sonoff/xsns_hlw8012.ino +++ b/sonoff/xsns_hlw8012.ino @@ -654,8 +654,8 @@ void hlw_mqttStat(byte option) if (option) { // Only send if telemetry dtostrfd(pet * 1000, 1, spet); domoticz_sensor4((uint16_t)pw, spet); // PowerUsage, EnergyToday - domoticz_sensor(6, spu); // Voltage - domoticz_sensor(7, spi); // Current + domoticz_sensor(DZ_VOLTAGE, spu); // Voltage + domoticz_sensor(DZ_CURRENT, spi); // Current } #endif // USE_DOMOTICZ }