Skip to content

Commit

Permalink
Merge pull request arendst#7 from arendst/development
Browse files Browse the repository at this point in the history
Revisit Timers off/on
  • Loading branch information
andrethomas committed Jul 20, 2018
2 parents 1bee80f + a1c2d0e commit 159ed8d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you like **Sonoff-Tasmota**, give it a star, or fork it and contribute!
### Development
[![Build Status](https://img.shields.io/travis/arendst/Sonoff-Tasmota.svg)](https://travis-ci.org/arendst/Sonoff-Tasmota)

Current version is **6.1.1b** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for release information and [sonoff/_changelog.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_changelog.ino) for change information.
Current version is **6.1.1c** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for release information and [sonoff/_changelog.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_changelog.ino) for change information.

### Disclaimer
:warning: **DANGER OF ELECTROCUTION** :warning:
Expand Down
5 changes: 4 additions & 1 deletion sonoff/_changelog.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* 6.1.1b
/* 6.1.1c
* Add command Timers 0/1 to globally disable or enable armed timers (#3270)
*
* 6.1.1b
* Add support for MPR121 controller in input mode for touch buttons (#3142)
* Add support for MCP230xx for general purpose input expansion and command Sensor29 (#3188)
* Fix command Scale buffer overflow (#3236)
Expand Down
2 changes: 1 addition & 1 deletion sonoff/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
typedef union { // Restricted by MISRA-C Rule 18.4 but so usefull...
uint32_t data; // Allow bit manipulation using SetOption
struct { // SetOption50 .. SetOption81
uint32_t spare00 : 1;
uint32_t timers_enable : 1; // bit 0 (v6.1.1b)
uint32_t spare01 : 1;
uint32_t spare02 : 1;
uint32_t spare03 : 1;
Expand Down
3 changes: 3 additions & 0 deletions sonoff/settings.ino
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,9 @@ void SettingsDelta()
Settings.flag.rules_once = 0;
Settings.flag3.data = 0;
}
if (Settings.version < 0x06010103) {
Settings.flag3.timers_enable = 1;
}

Settings.version = VERSION;
SettingsSave(1);
Expand Down
2 changes: 1 addition & 1 deletion sonoff/sonoff.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
====================================================*/

#define VERSION 0x06010102 // 6.1.1b
#define VERSION 0x06010103 // 6.1.1c

// Location specific includes
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)
Expand Down
12 changes: 8 additions & 4 deletions sonoff/xdrv_09_timers.ino
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void TimerEverySecond()
{
if (RtcTime.valid) {
if (!RtcTime.hour && !RtcTime.minute && !RtcTime.second) { TimerSetRandomWindows(); } // Midnight
if ((uptime > 60) && (RtcTime.minute != timer_last_minute)) { // Execute from one minute after restart every minute only once
if (Settings.flag3.timers_enable && (uptime > 60) && (RtcTime.minute != timer_last_minute)) { // Execute from one minute after restart every minute only once
timer_last_minute = RtcTime.minute;
int16_t time = (RtcTime.hour *60) + RtcTime.minute;
uint8_t days = 1 << (RtcTime.day_of_week -1);
Expand Down Expand Up @@ -451,11 +451,15 @@ boolean TimerCommand()
}
}
else if (CMND_TIMERS == command_code) {
if (XdrvMailbox.data_len && (XdrvMailbox.payload == 0)) {
for (byte i = 0; i < MAX_TIMERS; i++) {
Settings.timer[i].arm = 0; // Disable all timers
if (XdrvMailbox.data_len) {
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) {
Settings.flag3.timers_enable = XdrvMailbox.payload;
}
}

snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, GetStateText(Settings.flag3.timers_enable));
MqttPublishPrefixTopic_P(RESULT_OR_STAT, command);

byte jsflg = 0;
byte lines = 1;
for (byte i = 0; i < MAX_TIMERS; i++) {
Expand Down

0 comments on commit 159ed8d

Please sign in to comment.