-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix and adapt the format of discovergy to the other modules (#881)
- Loading branch information
Showing
5 changed files
with
35 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,11 +1,20 @@ | ||
from modules.common.store import get_counter_value_store | ||
from requests import Session | ||
|
||
from modules.common.component_type import ComponentDescriptor | ||
from modules.common.fault_state import ComponentInfo | ||
from modules.common.store import get_counter_value_store | ||
from modules.devices.discovergy import api | ||
from modules.devices.discovergy.config import DiscovergyCounterSetup | ||
from modules.devices.discovergy.utils import DiscovergyComponent | ||
|
||
|
||
def create_component(component_config: DiscovergyCounterSetup): | ||
return DiscovergyComponent(component_config, get_counter_value_store(component_config.id).set) | ||
class DiscovergyCounter: | ||
def __init__(self, component_config: DiscovergyCounterSetup) -> None: | ||
self.component_config = component_config | ||
self.store = get_counter_value_store(self.component_config.id) | ||
self.component_info = ComponentInfo.from_component_config(self.component_config) | ||
|
||
def update(self, session: Session): | ||
self.store.set(api.get_last_reading(session, self.component_config.configuration.meter_id)) | ||
|
||
|
||
component_descriptor = ComponentDescriptor(configuration_factory=DiscovergyCounterSetup) |
This file contains 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 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 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 |
---|---|---|
@@ -1,21 +1,26 @@ | ||
from modules.common.component_state import InverterState, CounterState | ||
from requests import Session | ||
|
||
from modules.common.component_state import InverterState | ||
from modules.common.component_type import ComponentDescriptor | ||
from modules.common.fault_state import ComponentInfo | ||
from modules.common.store import get_inverter_value_store | ||
from modules.devices.discovergy.utils import DiscovergyComponent | ||
from modules.devices.discovergy import api | ||
from modules.devices.discovergy.config import DiscovergyInverterSetup | ||
|
||
|
||
def create_component(component_config: DiscovergyInverterSetup): | ||
store = get_inverter_value_store(component_config.id) | ||
class DiscovergInverter: | ||
def __init__(self, component_config: DiscovergyInverterSetup) -> None: | ||
self.component_config = component_config | ||
self.store = get_inverter_value_store(self.component_config.id) | ||
self.component_info = ComponentInfo.from_component_config(self.component_config) | ||
|
||
def persister(reading: CounterState): | ||
store.set(InverterState( | ||
def update(self, session: Session): | ||
reading = api.get_last_reading(session, self.component_config.configuration.meter_id) | ||
self.store.set(InverterState( | ||
exported=reading.exported, | ||
power=reading.power, | ||
currents=reading.currents | ||
)) | ||
|
||
return DiscovergyComponent(component_config, persister) | ||
|
||
|
||
component_descriptor = ComponentDescriptor(configuration_factory=DiscovergyInverterSetup) |
This file was deleted.
Oops, something went wrong.