From 34eed717fae5c6528ef3fae45ab92380c4b3217a Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Tue, 3 Sep 2019 23:04:49 +0200 Subject: [PATCH] Add command Power0 0/1/2/Off/On/Toggle to control all power outputs at once Add command Power0 0/1/2/Off/On/Toggle to control all power outputs at once (#6340) --- sonoff/_changelog.ino | 1 + sonoff/support_command.ino | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sonoff/_changelog.ino b/sonoff/_changelog.ino index 06bd9d956e1f..1575147663df 100644 --- a/sonoff/_changelog.ino +++ b/sonoff/_changelog.ino @@ -6,6 +6,7 @@ * Add 'sonoff-ir' pre-packaged IR-dedicated firmware and 'sonoff-ircustom' to customize firmware with IR Full protocol support * Add Zigbee support phase 2 - cc2530 initialization and basic ZCL decoding * Add driver USE_SDM120_2 with Domoticz P1 Smart Meter functionality as future replacement for USE_SDM120 - Pls test and report + * Add command Power0 0/1/2/Off/On/Toggle to control all power outputs at once (#6340) * * 6.6.0.8 20190827 * Add Tuya Energy monitoring by Shantur Rathore diff --git a/sonoff/support_command.ino b/sonoff/support_command.ino index 6c2dc78a8d73..688ba0c7131a 100644 --- a/sonoff/support_command.ino +++ b/sonoff/support_command.ino @@ -258,10 +258,19 @@ void CmndPower(void) { if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= devices_present)) { if ((XdrvMailbox.payload < 0) || (XdrvMailbox.payload > 4)) { XdrvMailbox.payload = 9; } -// Settings.flag.device_index_enable = user_index; +// Settings.flag.device_index_enable = XdrvMailbox.usridx; ExecuteCommandPower(XdrvMailbox.index, XdrvMailbox.payload, SRC_IGNORE); mqtt_data[0] = '\0'; } + else if (0 == XdrvMailbox.index) { + if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 2)) { + if (2 == XdrvMailbox.payload) { + XdrvMailbox.payload = (power) ? 0 : 1; + } + SetAllPower(XdrvMailbox.payload, SRC_IGNORE); + mqtt_data[0] = '\0'; + } + } } void CmndStatus(void)