Skip to content

Commit 77da1df

Browse files
committed
v5.0.3
5.0.3 20170504 * Add command SensorRetain on|off to enable retaining of mqtt message tele/sonoff/SENSOR (#74) * Change WifiConfig timeout from 60 seconds to 180 seconds (#212) * Change Sonoff Touch command Ledstate functionality by turning led on if power is off (#214) * Add 4 seconds delay after power on before enabling button to workaround Wemos D1 mini RTS circuit (#380)
1 parent b5b117e commit 77da1df

File tree

6 files changed

+38
-11
lines changed

6 files changed

+38
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Sonoff-Tasmota
22
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.
33

4-
Current version is **5.0.2** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
4+
Current version is **5.0.3** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
55

66
### **** ATTENTION Version 5.0.x specific information ****
77

api/arduino/sonoff.ino.bin

240 Bytes
Binary file not shown.

sonoff/_releasenotes.ino

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
/* 5.0.2 20170503
1+
/* 5.0.3 20170504
2+
* Add command SensorRetain on|off to enable retaining of mqtt message tele/sonoff/SENSOR (#74)
3+
* Change WifiConfig timeout from 60 seconds to 180 seconds (#212)
4+
* Change Sonoff Touch command Ledstate functionality by turning led on if power is off (#214)
5+
* Add 4 seconds delay after power on before enabling button to workaround Wemos D1 mini RTS circuit (#380)
6+
*
7+
* 5.0.2 20170503
28
* Reset SaveData, SaveState and MqttResponse to default values due to rearranging settings
39
* Moved some settings to flag area
410
* Add command TempUnit Celsius|Fahrenheit for selecting Celsius or Fahrenheit (#347)

sonoff/settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ typedef struct {
1212
uint32_t mqtt_button_retain : 1;
1313
uint32_t mqtt_switch_retain : 1;
1414
uint32_t temperature_conversion : 1;
15-
uint32_t spare23 : 1;
15+
uint32_t mqtt_sensor_retain : 1;
1616
uint32_t spare22 : 1;
1717
uint32_t spare21 : 1;
1818
uint32_t spare20 : 1;

sonoff/sonoff.ino

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* ====================================================
1111
*/
1212

13-
#define VERSION 0x05000200 // 5.0.2
13+
#define VERSION 0x05000300 // 5.0.3
1414

1515
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
1616
enum week_t {Last, First, Second, Third, Fourth};
@@ -258,6 +258,7 @@ uint8_t holdcount = 0; // Timer recording button hold
258258
uint8_t multiwindow = 0; // Max time between button presses to record press count
259259
uint8_t multipress = 0; // Number of button presses within multiwindow
260260
uint8_t lastwallswitch[4]; // Last wall switch states
261+
uint8_t blockgpio0 = 4; // Block GPIO0 for 4 seconds after poweron to workaround Wemos D1 RTS circuit
261262

262263
mytmplt my_module; // Active copy of GPIOs
263264
uint8_t pin[GPIO_MAX]; // Possible pin configurations
@@ -460,15 +461,20 @@ void mqtt_publish(const char* topic, const char* data)
460461
mqtt_publish(topic, data, false);
461462
}
462463

463-
void mqtt_publish_topic_P(uint8_t prefix, const char* subtopic, const char* data)
464+
void mqtt_publish_topic_P(uint8_t prefix, const char* subtopic, const char* data, boolean retained)
464465
{
465466
char romram[16];
466467
char stopic[TOPSZ];
467468

468469
snprintf_P(romram, sizeof(romram), ((prefix > 3) && !sysCfg.flag.mqtt_response) ? PSTR("RESULT") : subtopic);
469470
prefix &= 1;
470471
snprintf_P(stopic, sizeof(stopic), PSTR("%s/%s/%s"), sysCfg.mqtt_prefix[prefix +1], sysCfg.mqtt_topic, romram);
471-
mqtt_publish(stopic, data);
472+
mqtt_publish(stopic, data, retained);
473+
}
474+
475+
void mqtt_publish_topic_P(uint8_t prefix, const char* subtopic, const char* data)
476+
{
477+
mqtt_publish_topic_P(prefix, subtopic, data, false);
472478
}
473479

474480
void mqtt_publishPowerState(byte device)
@@ -793,6 +799,17 @@ boolean mqtt_command(boolean grpflg, char *type, uint16_t index, char *dataBuf,
793799
}
794800
snprintf_P(svalue, ssvalue, PSTR("{\"PowerRetain\":\"%s\"}"), getStateText(sysCfg.flag.mqtt_power_retain));
795801
}
802+
else if (!strcmp_P(type,PSTR("SENSORRETAIN"))) {
803+
if ((data_len > 0) && (payload >= 0) && (payload <= 1)) {
804+
if (!payload) {
805+
svalue[0] = '\0';
806+
mqtt_publish_topic_P(1, PSTR("SENSOR"), svalue, sysCfg.flag.mqtt_sensor_retain);
807+
}
808+
sysCfg.flag.mqtt_sensor_retain = payload;
809+
}
810+
snprintf_P(svalue, ssvalue, PSTR("{\"SensorRetain\":\"%s\"}"), getStateText(sysCfg.flag.mqtt_sensor_retain));
811+
}
812+
796813
#ifdef USE_DOMOTICZ
797814
else if (domoticz_command(type, index, dataBuf, data_len, payload, svalue, ssvalue)) {
798815
// Serviced
@@ -1765,6 +1782,10 @@ void every_second()
17651782
{
17661783
char svalue[MESSZ];
17671784

1785+
if (blockgpio0) {
1786+
blockgpio0--;
1787+
}
1788+
17681789
for (byte i = 0; i < MAX_PULSETIMERS; i++) {
17691790
if (pulse_timer[i] > 111) {
17701791
pulse_timer[i]--;
@@ -1849,7 +1870,7 @@ void every_second()
18491870
svalue[0] = '\0';
18501871
sensors_mqttPresent(svalue, sizeof(svalue), &djson);
18511872
if (djson) {
1852-
mqtt_publish_topic_P(1, PSTR("SENSOR"), svalue);
1873+
mqtt_publish_topic_P(1, PSTR("SENSOR"), svalue, sysCfg.flag.mqtt_sensor_retain);
18531874
}
18541875

18551876
if (hlw_flg) {
@@ -1947,7 +1968,7 @@ void stateloop()
19471968
button = NOT_PRESSED;
19481969
}
19491970
} else {
1950-
if (pin[GPIO_KEY1] < 99) {
1971+
if ((pin[GPIO_KEY1] < 99) && !blockgpio0) {
19511972
button = digitalRead(pin[GPIO_KEY1]);
19521973
}
19531974
}
@@ -2067,7 +2088,7 @@ void stateloop()
20672088
}
20682089
} else {
20692090
if (sysCfg.ledstate &0x01) {
2070-
setLed(power);
2091+
setLed((SONOFF_TOUCH == sysCfg.module) ? (power ^1) : power);
20712092
}
20722093
}
20732094
}

sonoff/support.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ boolean parseIP(uint32_t* addr, const char* str)
176176
* Wifi
177177
\*********************************************************************************************/
178178

179-
#define WIFI_CONFIG_SEC 60 // seconds before restart
180-
#define WIFI_MANAGER_SEC 120 // seconds before restart
179+
#define WIFI_CONFIG_SEC 180 // seconds before restart
180+
#define WIFI_MANAGER_SEC 180 // seconds before restart
181181
#define WIFI_CHECK_SEC 20 // seconds
182182
#define WIFI_RETRY_SEC 30 // seconds
183183

0 commit comments

Comments
 (0)