mirror of https://github.com/arendst/Tasmota.git
v4.0.5
4.0.5 20170314 * Add command Status 11 to show power status with Vcc if define USE_ADC_VCC is enabled (default) * Add ADC input to Sonoff SV and Wemos D1 mini - Needs recompile with define USE_ADC_VCC disabled (#137) * Add MQTT host:port to timeout message (#199)
This commit is contained in:
parent
5e4157ebe4
commit
67fe118dfe
|
@ -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 **4.0.4** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
|
||||
Current version is **4.0.5** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
|
||||
|
||||
- This version provides all (Sonoff) modules in one file and starts up with Sonoff Basic.
|
||||
- Once uploaded select module using the configuration webpage or the commands ```Modules``` and ```Module```.
|
||||
|
|
Binary file not shown.
|
@ -1,4 +1,9 @@
|
|||
/* 4.0.4 20170312
|
||||
/* 4.0.5 20170314
|
||||
* Add command Status 11 to show power status with Vcc if define USE_ADC_VCC is enabled (default)
|
||||
* Add ADC input to Sonoff SV and Wemos D1 mini - Needs recompile with define USE_ADC_VCC disabled (#137)
|
||||
* Add MQTT host:port to timeout message (#199)
|
||||
*
|
||||
* 4.0.4 20170312
|
||||
* Add pulse timers for up to 4 relays (#106)
|
||||
* Fix Sonoff Led power state when dimmer or color is 0 (#176)
|
||||
* Add command NtpServer<x> to configure up to three NTP servers (#177)
|
||||
|
|
|
@ -201,3 +201,8 @@ struct RTCMEM {
|
|||
unsigned long hlw_kWhtoday;
|
||||
} rtcMem;
|
||||
|
||||
// See issue https://github.com/esp8266/Arduino/issues/2913
|
||||
#ifdef USE_ADC_VCC
|
||||
ADC_MODE(ADC_VCC); // Set ADC input for Power Supply Voltage usage
|
||||
#endif
|
||||
|
||||
|
|
|
@ -734,6 +734,10 @@ void CFG_Delta()
|
|||
if (sysCfg.version < 0x04000400) {
|
||||
CFG_DefaultSet_4_0_4();
|
||||
}
|
||||
if (sysCfg.version < 0x04000500) {
|
||||
memmove(sysCfg.my_module.gp.io, sysCfg.my_module.gp.io +1, MAX_GPIO_PIN -1); // move myio 1 byte to front
|
||||
sysCfg.my_module.gp.io[MAX_GPIO_PIN -1] = 0; // Clear ADC0
|
||||
}
|
||||
sysCfg.version = VERSION;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
//#define ALLOW_MIGRATE_TO_V3
|
||||
#ifdef ALLOW_MIGRATE_TO_V3
|
||||
#define VERSION 0x03091B00 // 3.9.27
|
||||
#define VERSION 0x03091C00 // 3.9.28
|
||||
#else
|
||||
#define VERSION 0x04000400 // 4.0.4
|
||||
#define VERSION 0x04000500 // 4.0.5
|
||||
#endif // ALLOW_MIGRATE_TO_V3
|
||||
|
||||
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
|
||||
|
@ -136,7 +136,7 @@ enum emul_t {EMUL_NONE, EMUL_WEMO, EMUL_HUE, EMUL_MAX};
|
|||
#endif
|
||||
|
||||
#define APP_BAUDRATE 115200 // Default serial baudrate
|
||||
#define MAX_STATUS 10 // Max number of status lines
|
||||
#define MAX_STATUS 11 // Max number of status lines
|
||||
|
||||
enum butt_t {PRESSED, NOT_PRESSED};
|
||||
|
||||
|
@ -584,8 +584,9 @@ void mqtt_reconnect()
|
|||
mqtt_publish(stopic, svalue, true);
|
||||
mqtt_connected();
|
||||
} else {
|
||||
snprintf_P(log, sizeof(log), PSTR("MQTT: CONNECT FAILED, rc %d. Retry in %d seconds"), mqttClient.state(), mqttcounter);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
snprintf_P(log, sizeof(log), PSTR("MQTT: Connect FAILED to %s:%d, rc %d. Retry in %d seconds"),
|
||||
sysCfg.mqtt_host, sysCfg.mqtt_port, mqttClient.state(), mqttcounter); //status codes are documented here http://pubsubclient.knolleary.net/api.html#state
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1473,12 +1474,47 @@ void publish_status(uint8_t payload)
|
|||
snprintf_P(svalue, sizeof(svalue), PSTR("%s}"), svalue);
|
||||
mqtt_publish_topic_P(option, PSTR("STATUS10"), svalue);
|
||||
}
|
||||
|
||||
if ((payload == 0) || (payload == 11)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"StatusPWR\":"));
|
||||
state_mqttPresent(svalue, sizeof(svalue));
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%s}"), svalue);
|
||||
mqtt_publish_topic_P(option, PSTR("STATUS11"), svalue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void state_mqttPresent(char* svalue, uint16_t ssvalue)
|
||||
{
|
||||
char stemp1[8];
|
||||
|
||||
snprintf_P(svalue, ssvalue, PSTR("%s{\"Time\":\"%s\", \"Uptime\":%d"), svalue, getDateTime().c_str(), uptime);
|
||||
#ifdef USE_ADC_VCC
|
||||
dtostrf((double)ESP.getVcc()/1000, 1, 3, stemp1);
|
||||
snprintf_P(svalue, ssvalue, PSTR("%s, \"Vcc\":%s"), svalue, stemp1);
|
||||
#endif
|
||||
for (byte i = 0; i < Maxdevice; i++) {
|
||||
if (Maxdevice == 1) { // Legacy
|
||||
snprintf_P(svalue, ssvalue, PSTR("%s, \"%s\":"), svalue, sysCfg.mqtt_subtopic);
|
||||
} else {
|
||||
snprintf_P(svalue, ssvalue, PSTR("%s, \"%s%d\":"), svalue, sysCfg.mqtt_subtopic, i +1);
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("%s\"%s\""), svalue, (power & (0x01 << i)) ? MQTT_STATUS_ON : MQTT_STATUS_OFF);
|
||||
}
|
||||
snprintf_P(svalue, ssvalue, PSTR("%s, \"Wifi\":{\"AP\":%d, \"SSID\":\"%s\", \"RSSI\":%d}}"),
|
||||
svalue, sysCfg.sta_active +1, sysCfg.sta_ssid[sysCfg.sta_active], WIFI_getRSSIasQuality(WiFi.RSSI()));
|
||||
}
|
||||
|
||||
void sensors_mqttPresent(char* svalue, uint16_t ssvalue, uint8_t* djson)
|
||||
{
|
||||
snprintf_P(svalue, ssvalue, PSTR("%s{\"Time\":\"%s\""), svalue, getDateTime().c_str());
|
||||
|
||||
|
||||
#ifndef USE_ADC_VCC
|
||||
if (pin[GPIO_ADC0] < 99) {
|
||||
snprintf_P(svalue, ssvalue, PSTR("%s, \"AnalogInput0\":%d"), svalue, analogRead(A0));
|
||||
*djson = 1;
|
||||
}
|
||||
#endif
|
||||
if (pin[GPIO_DSB] < 99) {
|
||||
#ifdef USE_DS18B20
|
||||
dsb_mqttPresent(svalue, ssvalue, djson);
|
||||
|
@ -1584,17 +1620,8 @@ void every_second()
|
|||
if (tele_period >= sysCfg.tele_period) {
|
||||
tele_period = 0;
|
||||
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Time\":\"%s\", \"Uptime\":%d"), getDateTime().c_str(), uptime);
|
||||
for (byte i = 0; i < Maxdevice; i++) {
|
||||
if (Maxdevice == 1) { // Legacy
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%s, \"%s\":"), svalue, sysCfg.mqtt_subtopic);
|
||||
} else {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%s, \"%s%d\":"), svalue, sysCfg.mqtt_subtopic, i +1);
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%s\"%s\""), svalue, (power & (0x01 << i)) ? MQTT_STATUS_ON : MQTT_STATUS_OFF);
|
||||
}
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%s, \"Wifi\":{\"AP\":%d, \"SSID\":\"%s\", \"RSSI\":%d}}"),
|
||||
svalue, sysCfg.sta_active +1, sysCfg.sta_ssid[sysCfg.sta_active], WIFI_getRSSIasQuality(WiFi.RSSI()));
|
||||
svalue[0] = '\0';
|
||||
state_mqttPresent(svalue, sizeof(svalue));
|
||||
mqtt_publish_topic_P(1, PSTR("STATE"), svalue);
|
||||
|
||||
uint8_t djson = 0;
|
||||
|
|
|
@ -88,6 +88,7 @@ enum fpins_t {
|
|||
GPIO_HLW_SEL, // HLW8012 Sel output (Sonoff Pow)
|
||||
GPIO_HLW_CF1, // HLW8012 CF1 voltage / current (Sonoff Pow)
|
||||
GPIO_HLW_CF, // HLW8012 CF power (Sonoff Pow)
|
||||
GPIO_ADC0, // ADC
|
||||
GPIO_USER, // User configurable
|
||||
GPIO_MAX };
|
||||
|
||||
|
@ -117,14 +118,14 @@ enum module_t {
|
|||
|
||||
/********************************************************************************************/
|
||||
|
||||
#define MAX_GPIO_PIN 17 // Number of supported GPIO
|
||||
#define MAX_GPIO_PIN 18 // Number of supported GPIO
|
||||
|
||||
typedef struct MYIO {
|
||||
uint8_t io[MAX_GPIO_PIN];
|
||||
} myio;
|
||||
|
||||
typedef struct MYTMPLT {
|
||||
char name[16];
|
||||
char name[15];
|
||||
myio gp;
|
||||
} mytmplt;
|
||||
|
||||
|
@ -147,7 +148,8 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_LED1_INV, // GPIO13 Green Led (0 = On, 1 = Off)
|
||||
GPIO_USER, // GPIO14 Optional sensor
|
||||
0, // GPIO15
|
||||
0 // GPIO16
|
||||
0, // GPIO16
|
||||
0 // ADC0 Analog input
|
||||
},
|
||||
{ "Sonoff RF", // Sonoff RF (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -160,7 +162,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
|
||||
GPIO_LED1_INV, // GPIO13 Green Led (0 = On, 1 = Off)
|
||||
GPIO_USER, // GPIO14 Optional sensor
|
||||
0, 0
|
||||
0, 0, 0
|
||||
},
|
||||
{ "Sonoff SV", // Sonoff SV (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -173,7 +175,8 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
|
||||
GPIO_LED1_INV, // GPIO13 Green Led (0 = On, 1 = Off)
|
||||
GPIO_USER, // GPIO14 Optional sensor
|
||||
0, 0
|
||||
0, 0,
|
||||
GPIO_ADC0 // ADC0 Analog input
|
||||
},
|
||||
{ "Sonoff TH", // Sonoff TH10/16 (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -186,7 +189,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
|
||||
GPIO_LED1_INV, // GPIO13 Green Led (0 = On, 1 = Off)
|
||||
GPIO_USER, // GPIO14 Optional sensor
|
||||
0, 0
|
||||
0, 0, 0
|
||||
},
|
||||
{ "Sonoff Dual", // Sonoff Dual (ESP8266)
|
||||
0,
|
||||
|
@ -198,7 +201,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
0,
|
||||
GPIO_LED1_INV, // GPIO13 Blue Led (0 = On, 1 = Off)
|
||||
0, 0, 0
|
||||
0, 0, 0, 0
|
||||
},
|
||||
{ "Sonoff Pow", // Sonoff Pow (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -209,7 +212,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_HLW_CF1, // GPIO13 HLW8012 CF1 voltage / current
|
||||
GPIO_HLW_CF, // GPIO14 HLW8012 CF power
|
||||
GPIO_LED1, // GPIO15 Green Led (0 = On, 1 = Off)
|
||||
0
|
||||
0, 0
|
||||
},
|
||||
{ "Sonoff 4CH", // Sonoff 4CH (ESP8285)
|
||||
GPIO_KEY1, // GPIO00 Button 1
|
||||
|
@ -226,7 +229,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_LED1_INV, // GPIO13 Blue Led (0 = On, 1 = Off)
|
||||
GPIO_KEY4, // GPIO14 Button 4
|
||||
GPIO_REL4, // GPIO15 Red Led and Relay 4 (0 = Off, 1 = On)
|
||||
0
|
||||
0, 0
|
||||
},
|
||||
{ "S20 Socket", // S20 Smart Socket (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -234,7 +237,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
|
||||
GPIO_LED1_INV, // GPIO13 Green Led (0 = On, 1 = Off)
|
||||
0, 0, 0
|
||||
0, 0, 0, 0
|
||||
},
|
||||
{ "Slampher", // Slampher (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -242,7 +245,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
|
||||
GPIO_LED1_INV, // GPIO13 Blue Led (0 = On, 1 = Off)
|
||||
0, 0, 0
|
||||
0, 0, 0, 0
|
||||
},
|
||||
{ "Sonoff Touch", // Sonoff Touch (ESP8285)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -251,7 +254,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
0, 0, 0,
|
||||
GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
|
||||
GPIO_LED1_INV, // GPIO13 Blue Led (0 = On, 1 = Off)
|
||||
0, 0, 0
|
||||
0, 0, 0, 0
|
||||
},
|
||||
{ "Sonoff LED", // Sonoff LED (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -263,7 +266,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_LED1_INV, // GPIO13 Blue Led (0 = On, 1 = Off)
|
||||
GPIO_PWM1, // GPIO14 Warm light
|
||||
GPIO_USER, // GPIO15 Optional sensor (PWM4 Blue)
|
||||
0
|
||||
0, 0
|
||||
},
|
||||
{ "1 Channel", // 1 Channel Inching/Latching Relay using (PSA-B01 - ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -271,7 +274,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
|
||||
GPIO_LED1_INV, // GPIO13 Green Led (0 = On, 1 = Off)
|
||||
0, 0, 0
|
||||
0, 0, 0, 0
|
||||
},
|
||||
{ "4 Channel", // 4 Channel Inching/Latching Relays
|
||||
0,
|
||||
|
@ -282,7 +285,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
0,
|
||||
GPIO_LED1_INV, // GPIO13 Blue Led (0 = On, 1 = Off)
|
||||
0, 0, 0
|
||||
0, 0, 0, 0
|
||||
},
|
||||
{ "Motor C/AC", // Motor Clockwise / Anti clockwise (PSA-B01 - ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -290,7 +293,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
GPIO_REL1, // GPIO12 Red Led and Relay (0 = Off, 1 = On)
|
||||
GPIO_LED1_INV, // GPIO13 Green Led (0 = On, 1 = Off)
|
||||
0, 0, 0
|
||||
0, 0, 0, 0
|
||||
},
|
||||
{ "ElectroDragon", // ElectroDragon IoT Relay Board (ESP8266)
|
||||
GPIO_KEY2, // GPIO00 Button 2
|
||||
|
@ -304,7 +307,8 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_REL1, // GPIO13 Red Led and Relay 1 (0 = Off, 1 = On)
|
||||
GPIO_USER, // GPIO14 Optional sensor
|
||||
GPIO_USER, // GPIO15 Optional sensor
|
||||
GPIO_LED1 // GPIO16 Green/Blue Led (1 = On, 0 = Off)
|
||||
GPIO_LED1, // GPIO16 Green/Blue Led (1 = On, 0 = Off)
|
||||
0
|
||||
},
|
||||
{ "EXS Relay", // Latching relay https://ex-store.de/ESP8266-WiFi-Relay-V31 (ESP8266)
|
||||
// Module Pin 1 VCC 3V3, Module Pin 6 GND
|
||||
|
@ -319,7 +323,8 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_REL2, // GPIO13 Relay1 ( 1 = On)
|
||||
GPIO_USER, // GPIO14 Module Pin 5
|
||||
0,
|
||||
GPIO_USER // GPIO16 Module Pin 4
|
||||
GPIO_USER, // GPIO16 Module Pin 4
|
||||
0
|
||||
},
|
||||
{ "WiOn", // Indoor Tap https://www.amazon.com/gp/product/B00ZYLUBJU/ref=s9_acsd_al_bw_c_x_3_w (ESP8266)
|
||||
GPIO_USER, // GPIO00 Optional sensor (pm clock)
|
||||
|
@ -331,7 +336,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_KEY1, // GPIO13 Button
|
||||
0,
|
||||
GPIO_REL1, // GPIO15 Relay (0 = Off, 1 = On)
|
||||
0
|
||||
0, 0
|
||||
},
|
||||
{ "WeMos D1 mini", // WeMos and NodeMCU hardware (ESP8266)
|
||||
GPIO_USER, // GPIO00 D3 Wemos Button Shield
|
||||
|
@ -345,7 +350,8 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_USER, // GPIO13 D7
|
||||
GPIO_USER, // GPIO14 D5
|
||||
GPIO_USER, // GPIO15 D8
|
||||
GPIO_USER // GPIO16 D0 Wemos Wake
|
||||
GPIO_USER, // GPIO16 D0 Wemos Wake
|
||||
GPIO_ADC0 // ADC0 A0 Analog input
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -126,6 +126,8 @@
|
|||
#define ENERGY_RESOLUTION 3 // Maximum number of decimals (0 - 5) showing energy usage in kWh
|
||||
|
||||
// -- Sensor code selection -----------------------
|
||||
#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices
|
||||
|
||||
//#define USE_DS18x20 // Optional using OneWire library for multiple DS18B20 and/or DS18S20 (+2k code)
|
||||
|
||||
#define USE_I2C // I2C using library wire (+10k code, 0.2k mem) - Disable by //
|
||||
|
|
Loading…
Reference in New Issue