Merge pull request #7937 from pcdiem/device-groups-3

Check GroupTopic index, Fix response to include other groups
This commit is contained in:
Theo Arends 2020-03-17 08:37:07 +01:00 committed by GitHub
commit b5e5e367a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View File

@ -591,12 +591,14 @@ void ProcessDeviceGroupMessage(char * packet, int packet_length)
if (DeviceGroupItemShared(true, item)) { if (DeviceGroupItemShared(true, item)) {
if (item == DGR_ITEM_POWER) { if (item == DGR_ITEM_POWER) {
uint8_t mask_devices = value >> 24; if (device_group->local) {
if (mask_devices > devices_present) mask_devices = devices_present; uint8_t mask_devices = value >> 24;
for (uint32_t i = 0; i < devices_present; i++) { if (mask_devices > devices_present) mask_devices = devices_present;
uint32_t mask = 1 << i; for (uint32_t i = 0; i < devices_present; i++) {
bool on = (value & mask); uint32_t mask = 1 << i;
if (on != (power & mask)) ExecuteCommandPower(i + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE); bool on = (value & mask);
if (on != (power & mask)) ExecuteCommandPower(i + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
}
} }
} }
else { else {

View File

@ -882,7 +882,8 @@ void CmndPublish(void)
void CmndGroupTopic(void) void CmndGroupTopic(void)
{ {
#ifdef USE_DEVICE_GROUPS #ifdef USE_DEVICE_GROUPS
uint32_t settings_text_index = (XdrvMailbox.index <= 1 ? SET_MQTT_GRP_TOPIC : SET_MQTT_GRP_TOPIC2 + XdrvMailbox.index - 2); if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 4)) {
uint32_t settings_text_index = (XdrvMailbox.index <= 1 ? SET_MQTT_GRP_TOPIC : SET_MQTT_GRP_TOPIC2 + XdrvMailbox.index - 2);
#endif // USE_DEVICE_GROUPS #endif // USE_DEVICE_GROUPS
if (XdrvMailbox.data_len > 0) { if (XdrvMailbox.data_len > 0) {
MakeValidMqtt(0, XdrvMailbox.data); MakeValidMqtt(0, XdrvMailbox.data);
@ -894,7 +895,12 @@ void CmndGroupTopic(void)
#endif // USE_DEVICE_GROUPS #endif // USE_DEVICE_GROUPS
restart_flag = 2; restart_flag = 2;
} }
#ifdef USE_DEVICE_GROUPS
ResponseCmndChar(SettingsText(settings_text_index));
}
#else // USE_DEVICE_GROUPS
ResponseCmndChar(SettingsText(SET_MQTT_GRP_TOPIC)); ResponseCmndChar(SettingsText(SET_MQTT_GRP_TOPIC));
#endif // USE_DEVICE_GROUPS
} }
void CmndTopic(void) void CmndTopic(void)