Final fix for Shelly 2.5

This commit is contained in:
Theo Arends 2021-08-23 18:18:11 +02:00
parent 7d1bcda887
commit 0f3a74bad2

View File

@ -147,12 +147,14 @@ void Ade7953GetData(void)
Ade7953.period = value; // Period Ade7953.period = value; // Period
} else if (10 == i) { } else if (10 == i) {
acc_mode = value; // Accumulation mode acc_mode = value; // Accumulation mode
/*
if (0 == Ade7953.model) { // Shelly 2.5 - Swap channel B values due to hardware connection if (0 == Ade7953.model) { // Shelly 2.5 - Swap channel B values due to hardware connection
// if (acc_mode & APSIGN[0]) { acc_mode &= ~APSIGN[0]; } else { acc_mode |= APSIGN[0]; } // if (acc_mode & APSIGN[0]) { acc_mode &= ~APSIGN[0]; } else { acc_mode |= APSIGN[0]; }
// if (acc_mode & VARSIGN[0]) { acc_mode &= ~VARSIGN[0]; } else { acc_mode |= VARSIGN[0]; } // if (acc_mode & VARSIGN[0]) { acc_mode &= ~VARSIGN[0]; } else { acc_mode |= VARSIGN[0]; }
acc_mode ^= (APSIGN[0] | VARSIGN[0]); acc_mode ^= (APSIGN[0] | VARSIGN[0]);
// acc_mode ^= 0xA00; // acc_mode ^= 0xA00;
} }
*/
} else { } else {
reg[i >> 2][i &3] = value; reg[i >> 2][i &3] = value;
} }
@ -193,14 +195,14 @@ void Ade7953GetData(void)
Energy.data_valid[channel] = 0; Energy.data_valid[channel] = 0;
Energy.active_power[channel] = (float)Ade7953.active_power[channel] / (Settings->energy_power_calibration / 10); Energy.active_power[channel] = (float)Ade7953.active_power[channel] / (Settings->energy_power_calibration / 10);
Energy.reactive_power[channel] = (float)reactive_power[channel] / (Settings->energy_power_calibration / 10); Energy.reactive_power[channel] = (float)reactive_power[channel] / (Settings->energy_power_calibration / 10);
// if (1 == Ade7953.model) { // Shelly EM if (1 == Ade7953.model) { // Shelly EM
if ((acc_mode & APSIGN[channel]) != 0) { if ((acc_mode & APSIGN[channel]) != 0) {
Energy.active_power[channel] = Energy.active_power[channel] * -1; Energy.active_power[channel] = Energy.active_power[channel] * -1;
} }
if ((acc_mode & VARSIGN[channel]) != 0) { if ((acc_mode & VARSIGN[channel]) != 0) {
Energy.reactive_power[channel] = Energy.reactive_power[channel] * -1; Energy.reactive_power[channel] = Energy.reactive_power[channel] * -1;
} }
// } }
Energy.apparent_power[channel] = (float)apparent_power[channel] / (Settings->energy_power_calibration / 10); Energy.apparent_power[channel] = (float)apparent_power[channel] / (Settings->energy_power_calibration / 10);
if (0 == Energy.active_power[channel]) { if (0 == Energy.active_power[channel]) {
Energy.current[channel] = 0; Energy.current[channel] = 0;