예제 #1
0
파일: counter.py 프로젝트: yankee42/openWB
 def __init__(self, device_id: int, component_config: dict) -> None:
     self.__device_id = device_id
     self.component_config = component_config
     self.__sim_count = simcount.SimCountFactory().get_sim_counter()()
     self.simulation = {}
     self.__store = get_counter_value_store(component_config["id"])
     self.component_info = ComponentInfo.from_component_config(component_config)
예제 #2
0
파일: bat.py 프로젝트: benderl/openWB
 def __init__(self, device_id: int, component_config: Union[Dict, LgBatSetup]) -> None:
     self.__device_id = device_id
     self.component_config = dataclass_from_dict(LgBatSetup, component_config)
     self.__sim_count = simcount.SimCountFactory().get_sim_counter()()
     self.__simulation = {}
     self.__store = get_bat_value_store(self.component_config.id)
     self.component_info = ComponentInfo.from_component_config(self.component_config)
예제 #3
0
파일: bat.py 프로젝트: yankee42/openWB
 def __init__(self, device_id: int, component_config: dict) -> None:
     self.__device_id = device_id
     self.component_config = component_config
     ip_address = component_config["configuration"]["ip_address"]
     self.__tcp_client = modbus.ModbusClient(ip_address, 502)
     self.__sim_count = simcount.SimCountFactory().get_sim_counter()()
     self.__simulation = {}
     self.__store = get_bat_value_store(component_config["id"])
     self.component_info = ComponentInfo.from_component_config(component_config)
예제 #4
0
파일: bat.py 프로젝트: okaegi/openWB
 def __init__(self, device_id: int, component_config: dict,
              tcp_client: modbus.ModbusClient, device_config: Dict) -> None:
     self.__device_id = device_id
     self.component_config = component_config
     self.__tcp_client = tcp_client
     self.__sim_count = simcount.SimCountFactory().get_sim_counter()()
     self.__simulation = {}
     self.__store = get_bat_value_store(component_config["id"])
     self.component_info = ComponentInfo.from_component_config(
         component_config)
예제 #5
0
def read_legacy(component_type: str,
                address: str,
                bat_module: str,
                bat_ip: str,
                bat_username: str,
                bat_password: str,
                num: Optional[int] = None) -> None:
    dev = Device(
        KostalPiko(configuration=KostalPikoConfiguration(ip_address=address)))
    if component_type in COMPONENT_TYPE_TO_MODULE:
        component_config = COMPONENT_TYPE_TO_MODULE[
            component_type].component_descriptor.configuration_factory()
    else:
        raise Exception("illegal component type " + component_type +
                        ". Allowed values: " +
                        ','.join(COMPONENT_TYPE_TO_MODULE.keys()))
    component_config.id = num
    dev.add_component(component_config)

    log.debug('KostalPiko IP-Adresse: ' + address)
    log.debug('KostalPiko Speicher: ' + bat_module)

    if component_type == "inverter":
        with SingleComponentUpdateContext(
                dev.components["component" + str(num)].component_info):
            power, exported = dev.components["component" +
                                             str(num)].get_values()
            if bat_module == "speicher_bydhv":
                bat_power = _get_byd_bat_power(bat_ip, bat_username,
                                               bat_password, num)
                power -= bat_power
            get_inverter_value_store(num).set(
                InverterState(power=power, exported=exported))
    elif component_type == "counter":
        with SingleComponentUpdateContext(
                dev.components["componentNone"].component_info):
            home_consumption, powers = dev.components[
                "componentNone"].get_values()
            if bat_module == "speicher_bydhv":
                bat_power = _get_byd_bat_power(bat_ip, bat_username,
                                               bat_password, num)
                home_consumption += bat_power

            dev.add_component(KostalPikoInverterSetup(id=num))
            inverter_power, _ = dev.components["component" +
                                               str(num)].get_values()

            power = home_consumption + inverter_power
            imported, exported = simcount.SimCountFactory().get_sim_counter()(
            ).sim_count(power, topic="topic_str", data={}, prefix="bezug")
            counter_state = CounterState(imported=imported,
                                         exported=exported,
                                         power=power,
                                         powers=powers)
            get_counter_value_store(None).set(counter_state)
예제 #6
0
 def __init__(self,
              device_id: int,
              component_config: Union[Dict, SungrowCounterSetup],
              tcp_client: modbus.ModbusTcpClient_) -> None:
     self.__device_id = device_id
     self.component_config = dataclass_from_dict(SungrowCounterSetup, component_config)
     self.__tcp_client = tcp_client
     self.__sim_count = simcount.SimCountFactory().get_sim_counter()()
     self.simulation = {}
     self.__store = get_counter_value_store(self.component_config.id)
     self.component_info = ComponentInfo.from_component_config(self.component_config)
예제 #7
0
파일: inverter.py 프로젝트: okaegi/openWB
 def __init__(self, device_id: int, component_config: dict, tcp_client: modbus.ModbusClient) -> None:
     self.__device_id = device_id
     self.component_config = component_config
     factory = kit_counter_inverter_version_factory(
         component_config["configuration"]["version"])
     self.__client = factory(component_config["configuration"]["id"], tcp_client)
     self.__tcp_client = tcp_client
     self.__sim_count = simcount.SimCountFactory().get_sim_counter()()
     self.__simulation = {}
     self.__store = get_inverter_value_store(component_config["id"])
     self.component_info = ComponentInfo.from_component_config(component_config)
예제 #8
0
파일: counter.py 프로젝트: benderl/openWB
 def __init__(self, device_id: int,
              component_config: Union[Dict, KostalPikoCounterSetup],
              ip_address: str) -> None:
     self.__device_id = device_id
     self.component_config = dataclass_from_dict(KostalPikoCounterSetup,
                                                 component_config)
     self.ip_address = ip_address
     self.__sim_count = simcount.SimCountFactory().get_sim_counter()()
     self.simulation = {}
     self.__store = get_counter_value_store(self.component_config.id)
     self.component_info = ComponentInfo.from_component_config(
         self.component_config)
예제 #9
0
 def __init__(self, device_id: int,
              component_config: Union[Dict, FroniusInverterSetup],
              device_config: FroniusConfiguration) -> None:
     self.__device_id = device_id
     self.component_config = dataclass_from_dict(FroniusInverterSetup,
                                                 component_config)
     self.device_config = device_config
     self.__sim_count = simcount.SimCountFactory().get_sim_counter()()
     self.simulation = {}
     self.__store = get_inverter_value_store(self.component_config.id)
     self.component_info = ComponentInfo.from_component_config(
         self.component_config)
예제 #10
0
 def __init__(
         self, device_id: int, device_address: str, device_variant: int,
         component_config: Union[Dict, SonnenbatterieBatSetup]) -> None:
     self.__device_id = device_id
     self.__device_address = device_address
     self.__device_variant = device_variant
     self.component_config = dataclass_from_dict(SonnenbatterieBatSetup,
                                                 component_config)
     self.__sim_count = simcount.SimCountFactory().get_sim_counter()()
     self.simulation = {}
     self.__store = get_bat_value_store(self.component_config.id)
     self.component_info = ComponentInfo.from_component_config(
         self.component_config)
예제 #11
0
파일: inverter.py 프로젝트: benderl/openWB
 def __init__(self, device_id: int,
              component_config: Union[Dict,
                                      HttpInverterSetup], url: str) -> None:
     self.__device_id = device_id
     self.component_config = dataclass_from_dict(HttpInverterSetup,
                                                 component_config)
     self.__sim_count = simcount.SimCountFactory().get_sim_counter()()
     self.simulation = {}
     self.__store = get_inverter_value_store(self.component_config.id)
     self.component_info = ComponentInfo.from_component_config(
         self.component_config)
     self.__get_power = create_request_function(
         url, self.component_config.configuration.power_path)
     self.__get_exported = create_request_function(
         url, self.component_config.configuration.exported_path)
예제 #12
0
파일: bat.py 프로젝트: benderl/openWB
 def __init__(self, device_id: int,
              component_config: Union[Dict, BatKitFlexSetup],
              tcp_client: modbus.ModbusTcpClient_) -> None:
     self.__device_id = device_id
     self.component_config = dataclass_from_dict(BatKitFlexSetup,
                                                 component_config)
     factory = kit_bat_version_factory(
         self.component_config.configuration.version)
     self.__client = factory(self.component_config.configuration.id,
                             tcp_client)
     self.__tcp_client = tcp_client
     self.__sim_count = simcount.SimCountFactory().get_sim_counter()()
     self.simulation = {}
     self.__store = get_bat_value_store(self.component_config.id)
     self.component_info = ComponentInfo.from_component_config(
         self.component_config)