mirror of https://github.com/arendst/Tasmota.git
parent
18a1f5e5df
commit
5e4157ebe4
|
@ -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.5** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
|
||||
Current version is **4.0.4** - 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,9 +1,4 @@
|
|||
/* 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
|
||||
/* 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,8 +201,3 @@ 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
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
//#define ALLOW_MIGRATE_TO_V3
|
||||
#ifdef ALLOW_MIGRATE_TO_V3
|
||||
#define VERSION 0x03091C00 // 3.9.28
|
||||
#define VERSION 0x03091B00 // 3.9.27
|
||||
#else
|
||||
#define VERSION 0x04000500 // 4.0.5
|
||||
#define VERSION 0x04000400 // 4.0.4
|
||||
#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 11 // Max number of status lines
|
||||
#define MAX_STATUS 10 // Max number of status lines
|
||||
|
||||
enum butt_t {PRESSED, NOT_PRESSED};
|
||||
|
||||
|
@ -584,9 +584,8 @@ void mqtt_reconnect()
|
|||
mqtt_publish(stopic, svalue, true);
|
||||
mqtt_connected();
|
||||
} else {
|
||||
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);
|
||||
snprintf_P(log, sizeof(log), PSTR("MQTT: CONNECT FAILED, rc %d. Retry in %d seconds"), mqttClient.state(), mqttcounter);
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1474,47 +1473,12 @@ 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]) {
|
||||
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);
|
||||
|
@ -1620,8 +1584,17 @@ void every_second()
|
|||
if (tele_period >= sysCfg.tele_period) {
|
||||
tele_period = 0;
|
||||
|
||||
svalue[0] = '\0';
|
||||
state_mqttPresent(svalue, sizeof(svalue));
|
||||
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()));
|
||||
mqtt_publish_topic_P(1, PSTR("STATE"), svalue);
|
||||
|
||||
uint8_t djson = 0;
|
||||
|
|
|
@ -88,7 +88,6 @@ 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 };
|
||||
|
||||
|
@ -118,7 +117,7 @@ enum module_t {
|
|||
|
||||
/********************************************************************************************/
|
||||
|
||||
#define MAX_GPIO_PIN 18 // Number of supported GPIO
|
||||
#define MAX_GPIO_PIN 17 // Number of supported GPIO
|
||||
|
||||
typedef struct MYIO {
|
||||
uint8_t io[MAX_GPIO_PIN];
|
||||
|
@ -148,8 +147,7 @@ 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 // ADC or Vcc
|
||||
0 // GPIO16
|
||||
},
|
||||
{ "Sonoff RF", // Sonoff RF (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -162,8 +160,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 // ADC or Vcc
|
||||
0, 0
|
||||
},
|
||||
{ "Sonoff SV", // Sonoff SV (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -176,8 +173,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,
|
||||
GPIO_ADC0 // ADC or Vcc
|
||||
0, 0
|
||||
},
|
||||
{ "Sonoff TH", // Sonoff TH10/16 (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -190,8 +186,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 // ADC or Vcc
|
||||
0, 0
|
||||
},
|
||||
{ "Sonoff Dual", // Sonoff Dual (ESP8266)
|
||||
0,
|
||||
|
@ -203,8 +198,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 // ADC or Vcc
|
||||
0, 0, 0
|
||||
},
|
||||
{ "Sonoff Pow", // Sonoff Pow (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -215,8 +209,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 // ADC or Vcc
|
||||
0
|
||||
},
|
||||
{ "Sonoff 4CH", // Sonoff 4CH (ESP8285)
|
||||
GPIO_KEY1, // GPIO00 Button 1
|
||||
|
@ -233,8 +226,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 // ADC or Vcc
|
||||
0
|
||||
},
|
||||
{ "S20 Socket", // S20 Smart Socket (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -242,8 +234,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 // ADC or Vcc
|
||||
0, 0, 0
|
||||
},
|
||||
{ "Slampher", // Slampher (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -251,8 +242,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 // ADC or Vcc
|
||||
0, 0, 0
|
||||
},
|
||||
{ "Sonoff Touch", // Sonoff Touch (ESP8285)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -261,8 +251,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 // ADC or Vcc
|
||||
0, 0, 0
|
||||
},
|
||||
{ "Sonoff LED", // Sonoff LED (ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -274,8 +263,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 // ADC or Vcc
|
||||
0
|
||||
},
|
||||
{ "1 Channel", // 1 Channel Inching/Latching Relay using (PSA-B01 - ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -283,8 +271,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 // ADC or Vcc
|
||||
0, 0, 0
|
||||
},
|
||||
{ "4 Channel", // 4 Channel Inching/Latching Relays
|
||||
0,
|
||||
|
@ -295,8 +282,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 // ADC or Vcc
|
||||
0, 0, 0
|
||||
},
|
||||
{ "Motor C/AC", // Motor Clockwise / Anti clockwise (PSA-B01 - ESP8266)
|
||||
GPIO_KEY1, // GPIO00 Button
|
||||
|
@ -304,8 +290,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 // ADC or Vcc
|
||||
0, 0, 0
|
||||
},
|
||||
{ "ElectroDragon", // ElectroDragon IoT Relay Board (ESP8266)
|
||||
GPIO_KEY2, // GPIO00 Button 2
|
||||
|
@ -319,8 +304,7 @@ 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)
|
||||
0 // ADC or Vcc
|
||||
GPIO_LED1 // GPIO16 Green/Blue Led (1 = On, 0 = Off)
|
||||
},
|
||||
{ "EXS Relay", // Latching relay https://ex-store.de/ESP8266-WiFi-Relay-V31 (ESP8266)
|
||||
// Module Pin 1 VCC 3V3, Module Pin 6 GND
|
||||
|
@ -335,8 +319,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_REL2, // GPIO13 Relay1 ( 1 = On)
|
||||
GPIO_USER, // GPIO14 Module Pin 5
|
||||
0,
|
||||
GPIO_USER, // GPIO16 Module Pin 4
|
||||
0 // ADC or Vcc
|
||||
GPIO_USER // GPIO16 Module Pin 4
|
||||
},
|
||||
{ "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)
|
||||
|
@ -348,8 +331,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_KEY1, // GPIO13 Button
|
||||
0,
|
||||
GPIO_REL1, // GPIO15 Relay (0 = Off, 1 = On)
|
||||
0,
|
||||
0 // ADC or Vcc
|
||||
0
|
||||
},
|
||||
{ "WeMos D1 mini", // WeMos and NodeMCU hardware (ESP8266)
|
||||
GPIO_USER, // GPIO00 D3 Wemos Button Shield
|
||||
|
@ -363,8 +345,7 @@ const mytmplt modules[MAXMODULE] PROGMEM = {
|
|||
GPIO_USER, // GPIO13 D7
|
||||
GPIO_USER, // GPIO14 D5
|
||||
GPIO_USER, // GPIO15 D8
|
||||
GPIO_USER, // GPIO16 D0 Wemos Wake
|
||||
GPIO_ADC0 // ADC or Vcc
|
||||
GPIO_USER // GPIO16 D0 Wemos Wake
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -126,8 +126,6 @@
|
|||
#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 ADC input use 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