Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/samples/sample_consumer/sample_consumer/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from modules.common.abstract_device import DeviceDescriptor
from modules.common.component_state import ConsumerState
from modules.common.component_type import ComponentType
from modules.common.configurable_consumer import ConfigurableConsumer
from modules.common.configurable_consumer import ConfigurableConsumer, SetLimitData
from modules.common.modbus import ModbusDataType, ModbusTcpClient_
from modules.common.simcount._simcounter import SimCounterConsumer
from modules.consumers.sample.sample.config import SampleConsumer
Expand Down Expand Up @@ -55,7 +55,7 @@ def update() -> ConsumerState:
)

# ConsumerUsage.SUSPENDABLE_TUNABLE
def set_limit(power_limit: float) -> None:
def set_power_limit(power_limit: float, data: SetLimitData) -> None:
nonlocal client
client.write_registers(1000, power_limit, unit=config.configuration.modbus_id)

Expand All @@ -80,7 +80,7 @@ def send_values(values: CurrentValues) -> None:
error_handler=error_handler,
update=update,
send_values=send_values,
set_power_limit=set_limit,
set_power_limit=set_power_limit,
switch_on=switch_on,
switch_off=switch_off)

Expand Down
6 changes: 3 additions & 3 deletions packages/modules/consumers/askoma/askoheat/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from modules.common.abstract_device import DeviceDescriptor
from modules.common.component_state import ConsumerState
from modules.common.component_type import ComponentType
from modules.common.configurable_consumer import ConfigurableConsumer
from modules.common.configurable_consumer import ConfigurableConsumer, SetLimitData
from modules.common.modbus import ModbusDataType, ModbusTcpClient_
from modules.common.simcount._simcounter import SimCounterConsumer
from modules.consumers.askoma.askoheat.config import Askoheat
Expand Down Expand Up @@ -33,14 +33,14 @@ def update() -> ConsumerState:
temperatures=[client.read_input_registers(638, ModbusDataType.INT_16, unit=config.configuration.modbus_id)]
)

def set_limit(power_limit: float) -> None:
def set_power_limit(power_limit: float, data: SetLimitData) -> None:
client.write_register(201, power_limit, unit=config.configuration.modbus_id)

return ConfigurableConsumer(consumer_config=config,
initializer=initializer,
error_handler=error_handler,
update=update,
set_power_limit=set_limit,)
set_power_limit=set_power_limit,)


device_descriptor = DeviceDescriptor(configuration_factory=Askoheat)
43 changes: 19 additions & 24 deletions packages/modules/consumers/generic/dac/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import logging
from modules.common.abstract_device import DeviceDescriptor
from modules.common.component_type import ComponentType
from modules.common.configurable_consumer import ConfigurableConsumer
from modules.common.modbus import ModbusTcpClient_
from modules.common.configurable_consumer import ConfigurableConsumer, SetLimitData
from modules.common.modbus import ModbusDataType, ModbusTcpClient_
from modules.common.simcount._simcounter import SimCounterConsumer
from modules.consumers.generic.dac.config import Dac
from modules.consumers.generic.dac.model import Model
Expand All @@ -12,7 +12,7 @@


def create_consumer(config: Dac):
client = None
client: ModbusTcpClient_ = None
sim_counter = None

def initializer():
Expand All @@ -23,31 +23,26 @@ def initializer():
def error_handler() -> None:
initializer()

def set_limit(power_limit: float) -> None:
if config.configuration.model == Model.N4Dac02 or config.configuration.model == Model.M120T:
# pwoer_limit -= power
pass

# power_limit = max(power_limit, 0)
# if config.configuration.model == Model.N4Dac02:
# client.write_register(1, power_limit * 1000 / max_power, ModbusDataType.INT_16,
# unit=config.configuration.modbus_id)
# elif config.configuration.model == Model.DA02:
# client.write_register(0x01f4, power_limit * 4000 / max_power,
# ModbusDataType.INT_16, unit=config.configuration.modbus_id)
# elif config.configuration.model == Model.M120T:
# # ausgabe nicht kleiner 0,9V sonst Leistungsregelung der WP aus
# power_limit = max(power_limit * 4095 / max_power, 370)
# client.write_register(0x01f4, power_limit, ModbusDataType.INT_16, unit=config.configuration.modbus_id)
# elif config.configuration.model == Model.AA02B:
# power_limit = max((power_limit * (4095-820) / max_power)+820, 820)
# # ausgabe nicht kleiner 4ma sonst Leistungsregelung der WP aus
# client.write_register(0x01f4, power_limit, ModbusDataType.INT_16, unit=config.configuration.modbus_id)
def set_power_limit(power_limit: float, data: SetLimitData) -> None:
power_limit = max(power_limit, 0)
modbus_id = config.configuration.modbus_id
if config.configuration.model == Model.N4Dac02:
client.write_register(1, power_limit * 1000 / data.max_power, ModbusDataType.INT_16, unit=modbus_id)
elif config.configuration.model == Model.DA02:
client.write_register(0x01f4, power_limit * 4000 / data.max_power, ModbusDataType.INT_16, unit=modbus_id)
elif config.configuration.model == Model.M120T:
# ausgabe nicht kleiner 0,9V sonst Leistungsregelung der WP aus
power_limit = max(power_limit * 4095 / data.max_power, 370)
client.write_register(0x01f4, power_limit, ModbusDataType.INT_16, unit=modbus_id)
elif config.configuration.model == Model.AA02B:
power_limit = max((power_limit * (4095-820) / data.max_power)+820, 820)
# ausgabe nicht kleiner 4ma sonst Leistungsregelung der WP aus
client.write_register(0x01f4, power_limit, ModbusDataType.INT_16, unit=modbus_id)

return ConfigurableConsumer(consumer_config=config,
initializer=initializer,
error_handler=error_handler,
set_power_limit=set_limit,)
set_power_limit=set_power_limit,)


device_descriptor = DeviceDescriptor(configuration_factory=Dac)
4 changes: 2 additions & 2 deletions packages/modules/consumers/generic/http/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from modules.common.abstract_device import DeviceDescriptor
from modules.common.component_state import ConsumerState
from modules.common.component_type import ComponentType
from modules.common.configurable_consumer import ConfigurableConsumer
from modules.common.configurable_consumer import ConfigurableConsumer, SetLimitData
from modules.common.simcount._simcounter import SimCounterConsumer
from modules.consumers.generic.http.config import Http
from modules.devices.generic.http.api import (create_post_function, create_request_function,
Expand Down Expand Up @@ -71,7 +71,7 @@ def switch_off():
# Authorization?
post_switch_off(session, params={"state": False})

def set_power_limit(power_limit: int):
def set_power_limit(power_limit: float, data: SetLimitData) -> None:
# Authorization?
post_set_power_limit(session, params={"power_limit": power_limit})

Expand Down
4 changes: 2 additions & 2 deletions packages/modules/consumers/generic/json/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from modules.common.abstract_device import DeviceDescriptor
from modules.common.component_state import ConsumerState
from modules.common.component_type import ComponentType
from modules.common.configurable_consumer import ConfigurableConsumer
from modules.common.configurable_consumer import ConfigurableConsumer, SetLimitData
from modules.common.simcount._simcounter import SimCounterConsumer
from modules.consumers.generic.json.config import Json

Expand Down Expand Up @@ -84,7 +84,7 @@ def switch_off():
# Authorization?
jq_switch_off({"state": False})

def set_power_limit(power_limit: int):
def set_power_limit(power_limit: float, data: SetLimitData) -> None:
# Authorization?
jq_set_power_limit({"power_limit": power_limit})

Expand Down
6 changes: 3 additions & 3 deletions packages/modules/consumers/idm/idm/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from modules.common.abstract_device import DeviceDescriptor
from modules.common.component_state import ConsumerState
from modules.common.component_type import ComponentType
from modules.common.configurable_consumer import ConfigurableConsumer
from modules.common.configurable_consumer import ConfigurableConsumer, SetLimitData
from modules.common.modbus import ModbusDataType, ModbusTcpClient_
from modules.common.simcount._simcounter import SimCounterConsumer
from modules.consumers.idm.idm.config import Idm
Expand Down Expand Up @@ -71,7 +71,7 @@ def update() -> ConsumerState:
exported=exported
)

def set_limit(power_limit: float) -> None:
def set_power_limit(power_limit: float, data: SetLimitData) -> None:
# Schreibt den von openWB berechneten Überschuss in Register 74 (PV-Überschuss [kW]).
# Keine echte Leistungsvorgabe - die IDM-Regelung berechnet ihre Strategie selbst anhand dieses Wertes.
# Hinweis: Dies überschreibt den intern berechneten PV-Überschuss der IDM-Regelung und kann
Expand All @@ -84,7 +84,7 @@ def set_limit(power_limit: float) -> None:
error_handler=error_handler,
update=update,
send_values=send_values,
set_power_limit=set_limit)
set_power_limit=set_power_limit)


device_descriptor = DeviceDescriptor(configuration_factory=Idm)
6 changes: 3 additions & 3 deletions packages/modules/consumers/lambda_/lambda_/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from modules.common.abstract_device import DeviceDescriptor
from modules.common.component_state import ConsumerState
from modules.common.component_type import ComponentType
from modules.common.configurable_consumer import ConfigurableConsumer
from modules.common.configurable_consumer import ConfigurableConsumer, SetLimitData
from modules.common.modbus import ModbusDataType, ModbusTcpClient_
from modules.common.simcount._simcounter import SimCounterConsumer
from modules.consumers.lambda_.lambda_.config import Lambda
Expand Down Expand Up @@ -45,7 +45,7 @@ def update() -> ConsumerState:
exported=exported
)

def set_limit(power_limit: float) -> None:
def set_power_limit(power_limit: float, data: SetLimitData) -> None:
# Schreibt den von openWB berechneten Überschuss in Register 102 (E-Manager Bezug/Einspeisung).
# Keine echte Leistungsvorgabe - die Wärmepumpe regelt weiterhin selbst anhand dieses Wertes.
client.write_register(102,
Expand All @@ -58,7 +58,7 @@ def set_limit(power_limit: float) -> None:
error_handler=error_handler,
update=update,
send_values=send_values,
set_power_limit=set_limit,)
set_power_limit=set_power_limit,)


device_descriptor = DeviceDescriptor(configuration_factory=Lambda)
6 changes: 3 additions & 3 deletions packages/modules/consumers/my_pv/acthor/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from modules.common.abstract_device import DeviceDescriptor
from modules.common.component_state import ConsumerState
from modules.common.component_type import ComponentType
from modules.common.configurable_consumer import ConfigurableConsumer
from modules.common.configurable_consumer import ConfigurableConsumer, SetLimitData
from modules.common.modbus import ModbusDataType, ModbusTcpClient_
from modules.common.simcount._simcounter import SimCounterConsumer
from modules.consumers.my_pv.acthor.config import Acthor
Expand Down Expand Up @@ -61,14 +61,14 @@ def update() -> ConsumerState:
temperatures=[resp[Register.TEMP0]/10, resp[Register.TEMP1]/10, resp[Register.TEMP2]/10]
)

def set_limit(power_limit: float) -> None:
def set_power_limit(power_limit: float, data: SetLimitData) -> None:
power_limit = power_limit * FACTORS.get(config.configuration.model, 9000)/config.configuration.max_power
client.write_registers(1000, power_limit, unit=config.configuration.modbus_id)
return ConfigurableConsumer(consumer_config=config,
initializer=initializer,
error_handler=error_handler,
update=update,
set_power_limit=set_limit,)
set_power_limit=set_power_limit,)


device_descriptor = DeviceDescriptor(configuration_factory=Acthor)
6 changes: 3 additions & 3 deletions packages/modules/consumers/my_pv/elwa_e/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from modules.common.abstract_device import DeviceDescriptor
from modules.common.component_state import ConsumerState
from modules.common.component_type import ComponentType
from modules.common.configurable_consumer import ConfigurableConsumer
from modules.common.configurable_consumer import ConfigurableConsumer, SetLimitData
from modules.common.modbus import ModbusDataType, ModbusTcpClient_
from modules.common.simcount._simcounter import SimCounterConsumer
from modules.consumers.my_pv.elwa_e.config import Elwa
Expand Down Expand Up @@ -70,7 +70,7 @@ def update() -> ConsumerState:
temperatures=[resp[Register.TEMP0]/10]
)

def set_limit(power_limit: float) -> None:
def set_power_limit(power_limit: float, data: SetLimitData) -> None:
if status == 4:
log.debug("Elwa-E im Boost-Heat Modus, keine Leistungsvorgabe möglich")
return
Expand All @@ -84,7 +84,7 @@ def set_limit(power_limit: float) -> None:
initializer=initializer,
error_handler=error_handler,
update=update,
set_power_limit=set_limit,)
set_power_limit=set_power_limit,)


device_descriptor = DeviceDescriptor(configuration_factory=Elwa)
6 changes: 3 additions & 3 deletions packages/modules/consumers/ovum/ovum/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from modules.common.abstract_device import DeviceDescriptor
from modules.common.component_state import ConsumerState
from modules.common.component_type import ComponentType
from modules.common.configurable_consumer import ConfigurableConsumer
from modules.common.configurable_consumer import ConfigurableConsumer, SetLimitData
from modules.common.modbus import ModbusDataType, ModbusTcpClient_
from modules.common.simcount._simcounter import SimCounterConsumer
from modules.consumers.ovum.ovum.config import Ovum
Expand Down Expand Up @@ -54,7 +54,7 @@ def update() -> ConsumerState:
exported=exported
)

def set_limit(power_limit: Optional[float]) -> None:
def set_power_limit(power_limit: Optional[float], data: SetLimitData) -> None:
# ConsumerUsage.SUSPENDABLE_TUNABLE: externe Leistungsvorgabe. Ist-Modus wird vor dem
# Schreiben gelesen, um unnötige Moduswechsel-Befehle zu vermeiden.
unit = config.configuration.modbus_id
Expand Down Expand Up @@ -119,7 +119,7 @@ def switch_off() -> None:
error_handler=error_handler,
update=update,
send_values=send_values,
set_power_limit=set_limit,
set_power_limit=set_power_limit,
switch_on=switch_on,
switch_off=switch_off)

Expand Down
10 changes: 5 additions & 5 deletions packages/modules/consumers/ratiotherm/ratiotherm/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
from modules.common.abstract_device import DeviceDescriptor
from modules.common.component_type import ComponentType
from modules.common.configurable_consumer import ConfigurableConsumer
from modules.common.configurable_consumer import ConfigurableConsumer, SetLimitData
from modules.common.modbus import ModbusDataType, ModbusTcpClient_
from modules.common.simcount._simcounter import SimCounterConsumer
from modules.consumers.ratiotherm.ratiotherm.config import Ratiotherm
Expand All @@ -22,14 +22,14 @@ def initializer():
def error_handler() -> None:
initializer()

def set_limit(power_limit: float) -> None:
def set_power_limit(power_limit: float, data: SetLimitData) -> None:
# Absturz bei negativen Zahlen
client.write_register(100, max(power_limit, 0), ModbusDataType.INT_16, unit=config.configuration.modbus_id)

raw_value = int(round(max(power_limit, 0)))
client.write_register(100, raw_value, ModbusDataType.INT_16, unit=config.configuration.modbus_id)
return ConfigurableConsumer(consumer_config=config,
initializer=initializer,
error_handler=error_handler,
set_power_limit=set_limit,)
set_power_limit=set_power_limit,)


device_descriptor = DeviceDescriptor(configuration_factory=Ratiotherm)
4 changes: 2 additions & 2 deletions packages/modules/consumers/solarfocus/vampair/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from modules.common.abstract_device import DeviceDescriptor
from modules.common.component_state import ConsumerState
from modules.common.component_type import ComponentType
from modules.common.configurable_consumer import ConfigurableConsumer
from modules.common.configurable_consumer import ConfigurableConsumer, SetLimitData
from modules.common.modbus import ModbusDataType, ModbusTcpClient_
from modules.common.simcount._simcounter import SimCounterConsumer
from modules.consumers.solarfocus.vampair.config import Vampair
Expand All @@ -30,7 +30,7 @@ def update() -> ConsumerState:
exported=exported
)

def set_power_limit(power_limit: float) -> None:
def set_power_limit(power_limit: float, data: SetLimitData) -> None:
# Elektrische Sollleistung HEMS (PV)
client.write_register(33415, power_limit, unit=config.configuration.modbus_id)
client.write_register(33409, power_limit * -1, unit=config.configuration.modbus_id)
Expand Down