diff --git a/sma/CHANGELOG.md b/sma/CHANGELOG.md index 1c6c5ce..68d11a5 100644 --- a/sma/CHANGELOG.md +++ b/sma/CHANGELOG.md @@ -1,6 +1,6 @@ -## 0.1.2-rc1 +## 0.1.2-rc2 - Extend package to support tripower inverters diff --git a/sma/config.yaml b/sma/config.yaml index edba3bc..58eff89 100644 --- a/sma/config.yaml +++ b/sma/config.yaml @@ -1,6 +1,6 @@ name: "SMA Energy Meter emulator" description: "Simulate one or more SMA energy meters based on mqtt messages." -version: "0.1.2-rc1" +version: "0.1.2-rc2" slug: sma url: "https://github.com/Roeland54/SMA-Energy-Meter-emulator" arch: diff --git a/sma/src/emeter.py b/sma/src/emeter.py index 1bf4dfd..bf88bae 100644 --- a/sma/src/emeter.py +++ b/sma/src/emeter.py @@ -76,6 +76,74 @@ def begin(self, timeStampMs): self.storeU32BE(self._pMeterTime, timeStampMs) self._length = self.INITIAL_PAYLOAD_LENGTH + # Add dummy values for measurements to make sure the package always contains these. Solves tripower inverters not recognizing the data as valid. + # Totals + self.addMeasurementValue(emeterPacket.SMA_POSITIVE_ACTIVE_POWER, 0) + self.addCounterValue(emeterPacket.SMA_POSITIVE_ACTIVE_ENERGY, 0) + self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_ACTIVE_POWER, 0) + self.addCounterValue(emeterPacket.SMA_NEGATIVE_ACTIVE_ENERGY, 0) + self.addMeasurementValue(emeterPacket.SMA_POSITIVE_REACTIVE_POWER, 0) + self.addCounterValue(emeterPacket.SMA_POSITIVE_REACTIVE_ENERGY, 0) + self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_REACTIVE_POWER, 0) + self.addCounterValue(emeterPacket.SMA_NEGATIVE_REACTIVE_ENERGY, 0) + self.addMeasurementValue(emeterPacket.SMA_POSITIVE_APPARENT_POWER, 0) + self.addCounterValue(emeterPacket.SMA_POSITIVE_APPARENT_ENERGY, 0) + self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_APPARENT_POWER, 0) + self.addCounterValue(emeterPacket.SMA_NEGATIVE_APPARENT_ENERGY, 0) + self.addMeasurementValue(emeterPacket.SMA_POWER_FACTOR, 0) + + #L1 + self.addMeasurementValue(emeterPacket.SMA_POSITIVE_ACTIVE_POWER_L1, 0) + self.addCounterValue(emeterPacket.SMA_POSITIVE_ACTIVE_ENERGY_L1, 0) + self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_ACTIVE_POWER_L1, 0) + self.addCounterValue(emeterPacket.SMA_NEGATIVE_ACTIVE_ENERGY_L1, 0) + self.addMeasurementValue(emeterPacket.SMA_POSITIVE_REACTIVE_POWER_L1, 0) + self.addCounterValue(emeterPacket.SMA_POSITIVE_REACTIVE_ENERGY_L1, 0) + self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_REACTIVE_POWER_L1, 0) + self.addCounterValue(emeterPacket.SMA_NEGATIVE_REACTIVE_ENERGY_L1, 0) + self.addMeasurementValue(emeterPacket.SMA_POSITIVE_APPARENT_POWER_L1, 0) + self.addCounterValue(emeterPacket.SMA_POSITIVE_APPARENT_ENERGY_L1, 0) + self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_APPARENT_POWER_L1, 0) + self.addCounterValue(emeterPacket.SMA_NEGATIVE_APPARENT_ENERGY_L1, 0) + self.addMeasurementValue(emeterPacket.SMA_CURRENT_L1, 0) + self.addMeasurementValue(emeterPacket.SMA_VOLTAGE_L1, 0) + self.addMeasurementValue(emeterPacket.SMA_POWER_FACTOR_L1, 0) + + #L2 + self.addMeasurementValue(emeterPacket.SMA_POSITIVE_ACTIVE_POWER_L2, 0) + self.addCounterValue(emeterPacket.SMA_POSITIVE_ACTIVE_ENERGY_L2, 0) + self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_ACTIVE_POWER_L2, 0) + self.addCounterValue(emeterPacket.SMA_NEGATIVE_ACTIVE_ENERGY_L2, 0) + self.addMeasurementValue(emeterPacket.SMA_POSITIVE_REACTIVE_POWER_L2, 0) + self.addCounterValue(emeterPacket.SMA_POSITIVE_REACTIVE_ENERGY_L2, 0) + self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_REACTIVE_POWER_L2, 0) + self.addCounterValue(emeterPacket.SMA_NEGATIVE_REACTIVE_ENERGY_L2, 0) + self.addMeasurementValue(emeterPacket.SMA_POSITIVE_APPARENT_POWER_L2, 0) + self.addCounterValue(emeterPacket.SMA_POSITIVE_APPARENT_ENERGY_L2, 0) + self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_APPARENT_POWER_L2, 0) + self.addCounterValue(emeterPacket.SMA_NEGATIVE_APPARENT_ENERGY_L2, 0) + self.addMeasurementValue(emeterPacket.SMA_CURRENT_L2, 0) + self.addMeasurementValue(emeterPacket.SMA_VOLTAGE_L2, 0) + self.addMeasurementValue(emeterPacket.SMA_POWER_FACTOR_L2, 0) + + #L3 + self.addMeasurementValue(emeterPacket.SMA_POSITIVE_ACTIVE_POWER_L3, 0) + self.addCounterValue(emeterPacket.SMA_POSITIVE_ACTIVE_ENERGY_L3, 0) + self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_ACTIVE_POWER_L3, 0) + self.addCounterValue(emeterPacket.SMA_NEGATIVE_ACTIVE_ENERGY_L3, 0) + self.addMeasurementValue(emeterPacket.SMA_POSITIVE_REACTIVE_POWER_L3, 0) + self.addCounterValue(emeterPacket.SMA_POSITIVE_REACTIVE_ENERGY_L3, 0) + self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_REACTIVE_POWER_L3, 0) + self.addCounterValue(emeterPacket.SMA_NEGATIVE_REACTIVE_ENERGY_L3, 0) + self.addMeasurementValue(emeterPacket.SMA_POSITIVE_APPARENT_POWER_L3, 0) + self.addCounterValue(emeterPacket.SMA_POSITIVE_APPARENT_ENERGY_L3, 0) + self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_APPARENT_POWER_L3, 0) + self.addCounterValue(emeterPacket.SMA_NEGATIVE_APPARENT_ENERGY_L3, 0) + self.addMeasurementValue(emeterPacket.SMA_CURRENT_L3, 0) + self.addMeasurementValue(emeterPacket.SMA_VOLTAGE_L3, 0) + self.addMeasurementValue(emeterPacket.SMA_POWER_FACTOR_L3, 0) + + def addMeasurementValue(self, id, value): self._pPacketPos = self.storeU32BE(self._pPacketPos, id) self._pPacketPos = self.storeU32BE(self._pPacketPos, value) @@ -144,70 +212,3 @@ def initEmeterPacket(self, serNo): pSerNo = self.offsetOf(self.meterPacket, DSRC, self._headerLength) self.storeU32BE(pSerNo, serNo) - - # Add dummy values for measurements to make sure the package always contains these. Solves tripower inverters not recognizing the data as valid. - # Totals - self.addMeasurementValue(emeterPacket.SMA_POSITIVE_ACTIVE_POWER, 0) - self.addCounterValue(emeterPacket.SMA_POSITIVE_ACTIVE_ENERGY, 0) - self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_ACTIVE_POWER, 0) - self.addCounterValue(emeterPacket.SMA_NEGATIVE_ACTIVE_ENERGY, 0) - self.addMeasurementValue(emeterPacket.SMA_POSITIVE_REACTIVE_POWER, 0) - self.addCounterValue(emeterPacket.SMA_POSITIVE_REACTIVE_ENERGY, 0) - self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_REACTIVE_POWER, 0) - self.addCounterValue(emeterPacket.SMA_NEGATIVE_REACTIVE_ENERGY, 0) - self.addMeasurementValue(emeterPacket.SMA_POSITIVE_APPARENT_POWER, 0) - self.addCounterValue(emeterPacket.SMA_POSITIVE_APPARENT_ENERGY, 0) - self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_APPARENT_POWER, 0) - self.addCounterValue(emeterPacket.SMA_NEGATIVE_APPARENT_ENERGY, 0) - self.addMeasurementValue(emeterPacket.SMA_POWER_FACTOR, 0) - - #L1 - self.addMeasurementValue(emeterPacket.SMA_POSITIVE_ACTIVE_POWER_L1, 0) - self.addCounterValue(emeterPacket.SMA_POSITIVE_ACTIVE_ENERGY_L1, 0) - self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_ACTIVE_POWER_L1, 0) - self.addCounterValue(emeterPacket.SMA_NEGATIVE_ACTIVE_ENERGY_L1, 0) - self.addMeasurementValue(emeterPacket.SMA_POSITIVE_REACTIVE_POWER_L1, 0) - self.addCounterValue(emeterPacket.SMA_POSITIVE_REACTIVE_ENERGY_L1, 0) - self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_REACTIVE_POWER_L1, 0) - self.addCounterValue(emeterPacket.SMA_NEGATIVE_REACTIVE_ENERGY_L1, 0) - self.addMeasurementValue(emeterPacket.SMA_POSITIVE_APPARENT_POWER_L1, 0) - self.addCounterValue(emeterPacket.SMA_POSITIVE_APPARENT_ENERGY_L1, 0) - self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_APPARENT_POWER_L1, 0) - self.addCounterValue(emeterPacket.SMA_NEGATIVE_APPARENT_ENERGY_L1, 0) - self.addMeasurementValue(emeterPacket.SMA_CURRENT_L1, 0) - self.addMeasurementValue(emeterPacket.SMA_VOLTAGE_L1, 0) - self.addMeasurementValue(emeterPacket.SMA_POWER_FACTOR_L1, 0) - - #L2 - self.addMeasurementValue(emeterPacket.SMA_POSITIVE_ACTIVE_POWER_L2, 0) - self.addCounterValue(emeterPacket.SMA_POSITIVE_ACTIVE_ENERGY_L2, 0) - self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_ACTIVE_POWER_L2, 0) - self.addCounterValue(emeterPacket.SMA_NEGATIVE_ACTIVE_ENERGY_L2, 0) - self.addMeasurementValue(emeterPacket.SMA_POSITIVE_REACTIVE_POWER_L2, 0) - self.addCounterValue(emeterPacket.SMA_POSITIVE_REACTIVE_ENERGY_L2, 0) - self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_REACTIVE_POWER_L2, 0) - self.addCounterValue(emeterPacket.SMA_NEGATIVE_REACTIVE_ENERGY_L2, 0) - self.addMeasurementValue(emeterPacket.SMA_POSITIVE_APPARENT_POWER_L2, 0) - self.addCounterValue(emeterPacket.SMA_POSITIVE_APPARENT_ENERGY_L2, 0) - self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_APPARENT_POWER_L2, 0) - self.addCounterValue(emeterPacket.SMA_NEGATIVE_APPARENT_ENERGY_L2, 0) - self.addMeasurementValue(emeterPacket.SMA_CURRENT_L2, 0) - self.addMeasurementValue(emeterPacket.SMA_VOLTAGE_L2, 0) - self.addMeasurementValue(emeterPacket.SMA_POWER_FACTOR_L2, 0) - - #L3 - self.addMeasurementValue(emeterPacket.SMA_POSITIVE_ACTIVE_POWER_L3, 0) - self.addCounterValue(emeterPacket.SMA_POSITIVE_ACTIVE_ENERGY_L3, 0) - self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_ACTIVE_POWER_L3, 0) - self.addCounterValue(emeterPacket.SMA_NEGATIVE_ACTIVE_ENERGY_L3, 0) - self.addMeasurementValue(emeterPacket.SMA_POSITIVE_REACTIVE_POWER_L3, 0) - self.addCounterValue(emeterPacket.SMA_POSITIVE_REACTIVE_ENERGY_L3, 0) - self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_REACTIVE_POWER_L3, 0) - self.addCounterValue(emeterPacket.SMA_NEGATIVE_REACTIVE_ENERGY_L3, 0) - self.addMeasurementValue(emeterPacket.SMA_POSITIVE_APPARENT_POWER_L3, 0) - self.addCounterValue(emeterPacket.SMA_POSITIVE_APPARENT_ENERGY_L3, 0) - self.addMeasurementValue(emeterPacket.SMA_NEGATIVE_APPARENT_POWER_L3, 0) - self.addCounterValue(emeterPacket.SMA_NEGATIVE_APPARENT_ENERGY_L3, 0) - self.addMeasurementValue(emeterPacket.SMA_CURRENT_L3, 0) - self.addMeasurementValue(emeterPacket.SMA_VOLTAGE_L3, 0) - self.addMeasurementValue(emeterPacket.SMA_POWER_FACTOR_L3, 0)