diff --git a/CHANGELOG.md b/CHANGELOG.md index 6743e7de7..fe214244f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. ### Added - Matter support simple Relay on Apple Homekit by Stephan Hadinger (#18239) - VSC Pio menu bar extensions by @Jason2866 (#18233) +- Command ``SwitchMode0`` to show or set all SwitchModes ### Breaking Changed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index d26fc42d8..065a2dbed 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -112,6 +112,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ## Changelog v12.4.0.4 ### Added +- Command ``SwitchMode0`` to show or set all SwitchModes - Support for multiple MCP23008/MCP23017/MCP23S17 as switch/button/relay - Support for multiple PCF8574 as switch/button/relay - NTP time request from gateway [#17984](https://github.com/arendst/Tasmota/issues/17984) diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index 8215ab71c..34d6b4611 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -2139,14 +2139,31 @@ void CmndSwitchText(void) { } } -void CmndSwitchMode(void) -{ +void CmndSwitchMode(void) { if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_SWITCHES_SET)) { + // SwitchMode1 - Show SwitchMode1 + // SwitchMode1 2 - Set SwitchMode tot 2 if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < MAX_SWITCH_OPTION)) { Settings->switchmode[XdrvMailbox.index -1] = XdrvMailbox.payload; } ResponseCmndIdxNumber(Settings->switchmode[XdrvMailbox.index-1]); } + else if (0 == XdrvMailbox.index) { + // SwitchMode0 - Show all SwitchMode like {"SwitchMode":[2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]} + // SwitchMode0 2 - Set all SwitchMode to 2 + if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload < MAX_SWITCH_OPTION)) { + for (uint32_t i = 0; i < MAX_SWITCHES_SET; i++) { + Settings->switchmode[i] = XdrvMailbox.payload; + } + } + char stemp[MAX_SWITCHES_SET * 3]; + stemp[0] = '\0'; + for (uint32_t i = 0; i < MAX_SWITCHES_SET; i++) { + snprintf_P(stemp, sizeof(stemp), PSTR("%s%s%d" ), stemp, (i > 0 ? "," : "["), Settings->switchmode[i]); + } + strcat(stemp, "]"); + Response_P(S_JSON_COMMAND_XVALUE, XdrvMailbox.command, stemp); + } } void CmndInterlock(void)