Repository navigation
Fix: Solakon One: power values #4316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
seaspotter
wants to merge
4
commits into
openWB:master
Choose a base branch
from
seaspotter:fix-solakon-one-battery-register
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
74434be
Solakon One: read the real battery power register, not an undocumente…
seaspotter d017620
Solakon One: add grid counter, revert inverter to PV-only registers
seaspotter ff6cff0
Solakon One: simulate inverter's own AC import instead of defaulting …
seaspotter fe7d80f
Solakon One: remove comment
seaspotter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #!/usr/bin/env python3 | ||
| from typing import TypedDict, Any | ||
|
|
||
| from modules.common.abstract_device import AbstractCounter | ||
| from modules.common.component_state import CounterState | ||
| from modules.common.component_type import ComponentDescriptor | ||
| from modules.common.fault_state import ComponentInfo, FaultState | ||
| from modules.common.modbus import ModbusDataType, ModbusTcpClient_ | ||
| from modules.common.store import get_component_value_store | ||
| from modules.devices.solakon.solakon_one.config import SolakonOneCounterSetup | ||
| from modules.common.utils.peak_filter import PeakFilter | ||
| from modules.common.component_type import ComponentType | ||
|
|
||
|
|
||
| class KwargsDict(TypedDict): | ||
| client: ModbusTcpClient_ | ||
|
|
||
|
|
||
| class SolakonOneCounter(AbstractCounter): | ||
| def __init__(self, component_config: SolakonOneCounterSetup, **kwargs: Any) -> None: | ||
| self.component_config = component_config | ||
| self.kwargs: KwargsDict = kwargs | ||
|
|
||
| def initialize(self) -> None: | ||
| self.client: ModbusTcpClient_ = self.kwargs['client'] | ||
| self.store = get_component_value_store(self.component_config.type, self.component_config.id) | ||
| self.fault_state = FaultState(ComponentInfo.from_component_config(self.component_config)) | ||
| self.peak_filter = PeakFilter(ComponentType.COUNTER, self.component_config.id, self.fault_state) | ||
|
|
||
| def update(self) -> None: | ||
| unit = self.component_config.configuration.modbus_id | ||
|
|
||
| # Reg 39134 AC Leistung am Stecker (Grid Information laut Hersteller-Doku), Bezug hat positive Werte, | ||
| # Einspeisung hat negative Werte | ||
| power = self.client.read_holding_registers(39134, ModbusDataType.INT_32, unit=unit) * -1 | ||
|
seaspotter marked this conversation as resolved.
Resolved
|
||
|
|
||
| # Gesamte Netzeinspeisung/-bezug in Wh | ||
| exported = self.client.read_holding_registers(39621, ModbusDataType.UINT_32, unit=unit) * 10 | ||
| imported = self.client.read_holding_registers(39625, ModbusDataType.UINT_32, unit=unit) * 10 | ||
|
|
||
| imported, exported = self.peak_filter.check_values(power, imported, exported) | ||
| counter_state = CounterState( | ||
| power=power, | ||
| imported=imported, | ||
| exported=exported | ||
| ) | ||
| self.store.set(counter_state) | ||
|
|
||
|
|
||
| component_descriptor = ComponentDescriptor(configuration_factory=SolakonOneCounterSetup) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.