Add command ``SwitchMode0``

Add command ``SwitchMode0`` to show or set all SwitchModes
This commit is contained in:
Theo Arends 2023-03-25 11:29:49 +01:00
parent b456b97dda
commit 5bb624ad09
3 changed files with 21 additions and 2 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)