Use device map for received power item

This commit is contained in:
Paul C Diem 2021-02-09 15:42:14 -06:00
parent 60252a9043
commit 133826c331
2 changed files with 4 additions and 3 deletions

View File

@ -401,9 +401,10 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de
switch (item) {
case DGR_ITEM_POWER:
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
if (device_group_index < TasmotaGlobal.devices_present) {
uint32_t device = Settings.device_group_device[device_group_index];
if (device) {
bool on = (value & 1);
if (on != (TasmotaGlobal.power & (1 << device_group_index))) ExecuteCommandPower(device_group_index + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
if (on != ((TasmotaGlobal.power >> (device - 1)) & 1)) ExecuteCommandPower(device, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
}
}
else if (XdrvMailbox.index & DGR_FLAG_LOCAL) {

View File

@ -590,7 +590,7 @@ void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source)
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
dgr_power = (dgr_power >> (device - 1)) & 1;
}
SendDeviceGroupMessage(device, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, TasmotaGlobal.power);
SendDeviceGroupMessage(device, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, dgr_power);
}
#endif // USE_DEVICE_GROUPS
SetDevicePower(TasmotaGlobal.power, source);