def __init__(self, device_config: Union[Dict, AlphaEss]) -> None: self.components = {} # type: Dict[str, alpha_ess_component_classes] try: self.device_config = dataclass_from_dict(AlphaEss, device_config) if self.device_config.configuration.source == 0: self.client = modbus.ModbusTcpClient_("192.168.193.125", 8899) else: self.client = modbus.ModbusTcpClient_( self.device_config.configuration.ip_address, 502) except Exception: log.exception("Fehler im Modul " + self.device_config.name)
def __init__(self, device_config: Union[Dict, Solarmax]) -> None: self.components = {} try: self.device_config = dataclass_from_dict(Solarmax, device_config) self.client = modbus.ModbusTcpClient_(self.device_config.configuration.ip_address, 502) except Exception: log.exception("Fehler im Modul "+self.device_config.name)
def create_modbus_inverter(address: str): config = SmaSunnyBoyInverterSetup( id=num, configuration=SmaSunnyBoyInverterConfiguration( hybrid=bool(hybrid), version=SmaInverterVersion(version))) return inverter.SmaSunnyBoyInverter( 0, config, modbus.ModbusTcpClient_(address, 502))
def __init__(self, device_config: Union[Dict, SmaSunnyIsland]) -> None: self.components = {} # type: Dict[str, bat.SunnyIslandBat] try: self.device_config = dataclass_from_dict(SmaSunnyIsland, device_config) self.client = modbus.ModbusTcpClient_(self.device_config.configuration.ip_address, 502) except Exception: log.exception("Fehler im Modul "+self.device_config.name)
def __init__(self, device_config: Union[Dict, Solax]) -> None: self.components = {} # type: Dict[str, counter.SolaxCounter] try: self.device_config = dataclass_from_dict(Solax, device_config) ip_address = self.device_config.configuration.ip_address self.client = modbus.ModbusTcpClient_(ip_address, 502) except Exception: log.exception("Fehler im Modul " + self.device_config.name)
def __init__(self, device_config: Union[Dict, Siemens]) -> None: self.components = {} # type: Dict[str, siemens_component_classes] try: self.device_config = dataclass_from_dict(Siemens, device_config) self.client = modbus.ModbusTcpClient_( self.device_config.configuration.ip_address, 502) except Exception: log.exception("Fehler im Modul " + self.device_config.name)
def __init__(self, device_config: Union[Dict, Studer]) -> None: self.components = {} # type: Dict[str, Union[bat.StuderBat, inverter.StuderInverter]] try: self.device_config = dataclass_from_dict(Studer, device_config) ip_address = self.device_config.configuration.ip_address self.client = modbus.ModbusTcpClient_(ip_address, 502) except Exception: log.exception("Fehler im Modul "+self.device_config.name)
def read_inverter(ip1: str, webbox: int, ip2: str, ip3: str, ip4: str, version: int, hybrid: int, num: int, sunny_boy_smart_energy: int): def create_webbox_inverter(address: str): return SmaWebboxInverter(address, SmaWebboxInverterSetup(id=num)) def create_modbus_inverter(address: str): config = SmaSunnyBoyInverterSetup( id=num, configuration=SmaSunnyBoyInverterConfiguration( hybrid=bool(hybrid), version=SmaInverterVersion(version))) return inverter.SmaSunnyBoyInverter( 0, config, modbus.ModbusTcpClient_(address, 502)) inverter1 = (create_webbox_inverter if webbox else create_modbus_inverter)(ip1) inverters_additional = (create_modbus_inverter(address) for address in [ip2, ip3, ip4] if address != "none") # In legacy we were able to configure multiple IP-Addresses for a single SMA-component, effectively creating a # virtual component that represents the sum of its subcomponents. This was probably done in order to circumvent # the limitation to have a maximum of two inverters configured in legacy. # Since openWB 2 does not have a limitation on the number of inverters we do not implement this there. However # we still need to implement this for the read_legacy-bridge. # Here we act like we only update the first inverter, while we actually query all inverters and sum them up: with SingleComponentUpdateContext(inverter1.component_info): total_power = 0 total_energy = 0 for inv in itertools.chain((inverter1, ), inverters_additional): state = inv.read() total_power += state.power total_energy += state.exported if hybrid == 1: if sunny_boy_smart_energy == 0: bat_comp = bat.SunnyBoyBat(0, SmaSunnyBoyBatSetup(), modbus.ModbusTcpClient_(ip1, 502)) else: bat_comp = bat_smart_energy.SunnyBoySmartEnergyBat( 0, SmaSunnyBoySmartEnergyBatSetup(), modbus.ModbusTcpClient_(ip1, 502)) bat_state = bat_comp.read() total_power -= bat_state.power total_energy = total_energy + bat_state.imported - bat_state.exported get_inverter_value_store(num).set( InverterState(exported=total_energy, power=total_power))
def __init__(self, device_config: Union[Dict, Flex]) -> None: self.components = {} # type: Dict[str, Union[counter.EvuKitFlex, inverter.PvKitFlex]] try: self.device_config = dataclass_from_dict(Flex, device_config) ip_address = self.device_config.configuration.ip_address port = self.device_config.configuration.port self.client = modbus.ModbusTcpClient_(ip_address, port) except Exception: log.exception("Fehler im Modul " + self.device_config.name)
def __init__(self, device_config: Union[Dict, Solaredge]) -> None: self.components = {} # type: Dict[str, solaredge_component_classes] try: self.device_config = dataclass_from_dict(Solaredge, device_config) self.client = modbus.ModbusTcpClient_( self.device_config.configuration.ip_address, self.device_config.configuration.port) self.inverter_counter = 0 except Exception: log.exception("Fehler im Modul " + self.device_config.name)
def __init__(self, device_config: Union[Dict, Huawei]) -> None: self.components = {} # type: Dict[str, huawei_component_classes] try: self.device_config = dataclass_from_dict(Huawei, device_config) ip_address = self.device_config.configuration.ip_address self.client = modbus.ModbusTcpClient_(ip_address, 502) self.client.delegate.connect() time.sleep(7) except Exception: log.exception("Fehler im Modul " + self.device_config.name)
def __init__(self, device_config: Union[Dict, SmaSunnyBoy]) -> None: self.components = { } # type: Dict[str, sma_modbus_tcp_component_classes] try: self.device_config = dataclass_from_dict(SmaSunnyBoy, device_config) ip_address = self.device_config.configuration.ip_address self.client = modbus.ModbusTcpClient_(ip_address, 502) except Exception: log.exception("Fehler im Modul " + self.device_config.name)
def __init__(self, device_config: Union[Dict, BatKit]) -> None: self.device_config = dataclass_from_dict(BatKit, device_config) self.components = {} # type: Dict[str, bat.BatKit] self.client = modbus.ModbusTcpClient_("192.168.193.19", 8899)
def __init__(self, device_config: Union[Dict, EvuKit]) -> None: self.device_config = dataclass_from_dict(EvuKit, device_config) self.components = { } # type: Dict[str, Union[BatKit, counter.EvuKit, PvKit]] self.client = modbus.ModbusTcpClient_("192.168.193.15", 8899)