Skip to content

Commit

Permalink
Merge pull request arendst#7937 from pcdiem/device-groups-3
Browse files Browse the repository at this point in the history
Check GroupTopic index, Fix response to include other groups
  • Loading branch information
arendst authored Mar 17, 2020
2 parents fa7c87e + 6b632ef commit b5e5e36
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
14 changes: 8 additions & 6 deletions tasmota/support_device_groups.ino
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,14 @@ void ProcessDeviceGroupMessage(char * packet, int packet_length)

if (DeviceGroupItemShared(true, item)) {
if (item == DGR_ITEM_POWER) {
uint8_t mask_devices = value >> 24;
if (mask_devices > devices_present) mask_devices = devices_present;
for (uint32_t i = 0; i < devices_present; i++) {
uint32_t mask = 1 << i;
bool on = (value & mask);
if (on != (power & mask)) ExecuteCommandPower(i + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
if (device_group->local) {
uint8_t mask_devices = value >> 24;
if (mask_devices > devices_present) mask_devices = devices_present;
for (uint32_t i = 0; i < devices_present; i++) {
uint32_t mask = 1 << i;
bool on = (value & mask);
if (on != (power & mask)) ExecuteCommandPower(i + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
}
}
}
else {
Expand Down
8 changes: 7 additions & 1 deletion tasmota/xdrv_02_mqtt.ino
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,8 @@ void CmndPublish(void)
void CmndGroupTopic(void)
{
#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
if (XdrvMailbox.data_len > 0) {
MakeValidMqtt(0, XdrvMailbox.data);
Expand All @@ -894,7 +895,12 @@ void CmndGroupTopic(void)
#endif // USE_DEVICE_GROUPS
restart_flag = 2;
}
#ifdef USE_DEVICE_GROUPS
ResponseCmndChar(SettingsText(settings_text_index));
}
#else // USE_DEVICE_GROUPS
ResponseCmndChar(SettingsText(SET_MQTT_GRP_TOPIC));
#endif // USE_DEVICE_GROUPS
}

void CmndTopic(void)
Expand Down

0 comments on commit b5e5e36

Please sign in to comment.