Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Roeland authored and Roeland committed Oct 3, 2024
1 parent cf36762 commit 7b1038c
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 68 deletions.
2 changes: 1 addition & 1 deletion sma/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- https://developers.home-assistant.io/docs/add-ons/presentation#keeping-a-changelog -->

## 0.1.2
## 0.1.3

- Extend package to support tripower inverters

Expand Down
2 changes: 1 addition & 1 deletion sma/config.yaml
Original file line number Diff line number Diff line change
@@ -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"
version: "0.1.3"
slug: sma
url: "https://github.com/Roeland54/SMA-Energy-Meter-emulator"
arch:
Expand Down
133 changes: 67 additions & 66 deletions sma/src/emeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,73 @@ 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)
Expand Down Expand Up @@ -145,69 +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)

0 comments on commit 7b1038c

Please sign in to comment.