Skip to content
Closed
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
21 changes: 21 additions & 0 deletions packages/modules/devices/sma/sma_sunny_boy/bat_smart_energy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
from typing import Dict, Union
import logging

from dataclass_utils import dataclass_from_dict
from modules.common.abstract_device import AbstractBat
Expand All @@ -10,6 +11,9 @@
from modules.common.simcount import SimCounter
from modules.common.store import get_bat_value_store
from modules.devices.sma.sma_sunny_boy.config import SmaSunnyBoySmartEnergyBatSetup
from typing import Optional

log = logging.getLogger(__name__)


class SunnyBoySmartEnergyBat(AbstractBat):
Expand Down Expand Up @@ -52,5 +56,22 @@
exported=exported
)

def set_power_limit(self, power_limit: Optional[int]) -> None:
POWER_LIMIT_REGISTER = 40799
unit = self.component_config.configuration.modbus_id

if power_limit is None:
power_limit = -1
log.debug("Kein Entladelimit für den Speicher vorgegeben, Entladung wird durch den Speicher geregelt.")
else:
log.debug(f'Entladelimit {power_limit} W vorgegeben.')

Check warning on line 67 in packages/modules/devices/sma/sma_sunny_boy/bat_smart_energy.py

View workflow job for this annotation

GitHub Actions / build

trailing whitespace

current_limit = self.__tcp_client.read_holding_registers(POWER_LIMIT_REGISTER, ModbusDataType.INT_32, unit=unit)

if current_limit != power_limit:
log.debug(f'Aktives Entladelimit {current_limit} W weicht vom Sollwert {power_limit} W ab.')

Check warning on line 72 in packages/modules/devices/sma/sma_sunny_boy/bat_smart_energy.py

View workflow job for this annotation

GitHub Actions / build

trailing whitespace
log.debug(f'Setze neuen Wert {power_limit} in Register {POWER_LIMIT_REGISTER}.')
self.__tcp_client.write_registers(POWER_LIMIT_REGISTER, power_limit, unit=unit)


component_descriptor = ComponentDescriptor(configuration_factory=SmaSunnyBoySmartEnergyBatSetup)
Loading