Fix SO88 incoming power state check

This commit is contained in:
Paul C Diem 2020-05-29 18:55:33 -05:00
parent 9f0966bf3c
commit 3d42fae8bd
2 changed files with 2 additions and 3 deletions

View File

@ -387,7 +387,7 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de
case DGR_ITEM_POWER:
if (Settings.flag4.remote_device_mode) { // SetOption88 - Enable relays in separate device groups
bool on = (value & 1);
if (on != (power & 1)) ExecuteCommandPower(device_group_index + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
if (on != (power & (1 << device_group_index))) ExecuteCommandPower(device_group_index + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
}
else if (device_group->local) {
uint8_t mask_devices = value >> 24;
@ -396,7 +396,6 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de
uint32_t mask = 1 << i;
bool on = (value & mask);
if (on != (power & mask)) ExecuteCommandPower(i + 1, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
if (Settings.flag4.remote_device_mode) break; // SetOption88 - Enable relays in separate device groups
}
}
break;

View File

@ -573,7 +573,7 @@ void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source)
#ifdef USE_DEVICE_GROUPS
if (SRC_REMOTE != source && SRC_RETRY != source) {
if (Settings.flag4.remote_device_mode) // SetOption88 - Enable relays in separate device groups
SendDeviceGroupMessage(device - 1, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, (power >> device - 1) & 1 | 0x01000000); // Explicitly set number of relays to one
SendDeviceGroupMessage(device - 1, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, (power >> (device - 1)) & 1 | 0x01000000); // Explicitly set number of relays to one
else
SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, power);
}