Merge pull request #11275 from pcdiem/dgr4

Add device_group_tie in SettingsDefaultSet2 and show all groups
This commit is contained in:
Theo Arends 2021-03-11 08:22:58 +01:00 committed by GitHub
commit 5294b9e5ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 4 deletions

View File

@ -330,7 +330,7 @@
#define D_CMND_DEVGROUP_SEND "DevGroupSend"
#define D_CMND_DEVGROUP_SHARE "DevGroupShare"
#define D_CMND_DEVGROUPSTATUS "DevGroupStatus"
#define D_CMND_DEVGROUP_DEVICE "DevGroupTie"
#define D_CMND_DEVGROUP_TIE "DevGroupTie"
#define D_CMND_SERIALSEND "SerialSend"
#define D_CMND_SERIALDELIMITER "SerialDelimiter"
#define D_CMND_BAUDRATE "Baudrate"

View File

@ -999,6 +999,9 @@ void SettingsDefaultSet2(void) {
Settings.dimmer_step = DEFAULT_DIMMER_STEP;
// Device Groups
*(uint32_t *)&Settings.device_group_tie = 0x04030201;
// Display
// Settings.display_model = 0;
Settings.display_mode = 1;

View File

@ -36,7 +36,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
#ifdef USE_DEVICE_GROUPS_SEND
D_CMND_DEVGROUP_SEND "|"
#endif // USE_DEVICE_GROUPS_SEND
D_CMND_DEVGROUP_SHARE "|" D_CMND_DEVGROUPSTATUS "|" D_CMND_DEVGROUP_DEVICE "|"
D_CMND_DEVGROUP_SHARE "|" D_CMND_DEVGROUPSTATUS "|" D_CMND_DEVGROUP_TIE "|"
#endif // USE_DEVICE_GROUPS
D_CMND_SENSOR "|" D_CMND_DRIVER
#ifdef ESP32
@ -2143,7 +2143,13 @@ void CmndDevGroupTie(void)
if (XdrvMailbox.data_len > 0) {
Settings.device_group_tie[XdrvMailbox.index - 1] = XdrvMailbox.payload;
}
ResponseCmndIdxNumber(Settings.device_group_tie[XdrvMailbox.index - 1]);
char * ptr = TasmotaGlobal.mqtt_data;
*ptr++ = '{';
for (uint32_t i = 0; i < MAX_DEV_GROUP_NAMES; i++) {
ptr += sprintf(ptr, PSTR("\"%s%u\":%u,"), D_CMND_DEVGROUP_TIE, i + 1, Settings.device_group_tie[i]);
}
*(ptr - 1) = '}';
*ptr = 0;
}
}
#endif // USE_DEVICE_GROUPS

View File

@ -2210,7 +2210,7 @@ void LightHandleDevGroupItem(void)
static bool send_state = false;
static bool restore_power = false;
if (Settings.device_group_tie[*XdrvMailbox.topic] != Light.device) return;
if (Settings.flag4.multiple_device_groups ? Settings.device_group_tie[*XdrvMailbox.topic] != Light.device : !(XdrvMailbox.index & DGR_FLAG_LOCAL)) return;
bool more_to_come;
uint32_t value = XdrvMailbox.payload;
switch (XdrvMailbox.command_code) {