예제 #1
0
def test_update_external_var2(monkeypatch, requests_mock: requests_mock.Mocker,
                              mock_ramdisk):
    component_config = counter_sm.get_default_config()
    component_config["configuration"]["variant"] = 2
    device_config = device.get_default_config()["configuration"]
    device_config["ip_address"] = SAMPLE_IP
    device_config["meter_id"] = 1
    counter = counter_sm.FroniusSmCounter(0, component_config, device_config)

    monkeypatch.setattr(SimCountLegacy, "sim_count", Mock(return_value=[0, 0]))
    requests_mock.get("http://" + SAMPLE_IP +
                      "/solar_api/v1/GetMeterRealtimeData.cgi",
                      json=json_ext_var2)

    counter_state, meter_location = counter.update()

    assert counter_state.exported == 0
    assert counter_state.imported == 0
    assert counter_state.currents == [
        -5.373121093182142, -5.664436188811191, -5.585225225225224
    ]
    assert counter_state.frequency == 49.9
    assert counter_state.power == 3809.4
    assert counter_state.powers == [
        -1232.0566666666653, -1296.0230000000006, -1281.2506666666663
    ]
    assert counter_state.power_factors == [0.643, 0.68, 0.667]
    assert counter_state.voltages == [229.3, 228.8, 229.4]

    assert meter_location == MeterLocation.external
예제 #2
0
def test_update_grid_var2(monkeypatch, requests_mock: requests_mock.Mocker,
                          mock_ramdisk):
    component_config = counter_sm.get_default_config()
    component_config["configuration"]["variant"] = 2
    device_config = device.get_default_config()["configuration"]
    device_config["ip_address"] = SAMPLE_IP
    assert device_config["meter_id"] == 0
    counter = counter_sm.FroniusSmCounter(0, component_config, device_config)

    monkeypatch.setattr(SimCountLegacy, "sim_count", Mock(return_value=[0, 0]))
    requests_mock.get("http://" + SAMPLE_IP +
                      "/solar_api/v1/GetMeterRealtimeData.cgi",
                      json=json_grid_var2)

    counter_state, meter_location = counter.update()

    assert counter_state.exported == 0
    assert counter_state.imported == 0
    assert counter_state.currents == [
        -2.777267315214871, -6.06216401684521, -5.903017198144055
    ]
    assert counter_state.frequency == 50
    assert counter_state.power == -4496.6
    assert counter_state.powers == [
        -645.1591973244145, -1403.390969899666, -1377.7642140468224
    ]
    assert counter_state.power_factors == [-0.998, -0.998, -0.999]
    assert counter_state.voltages == [232.3, 231.5, 233.4]

    assert meter_location == MeterLocation.grid
예제 #3
0
def test_update_grid(monkeypatch, requests_mock: requests_mock.Mocker,
                     mock_ramdisk):
    component_config = counter_sm.get_default_config()
    assert component_config["configuration"]["variant"] == 0
    device_config = device.get_default_config()["configuration"]
    device_config["ip_address"] = SAMPLE_IP
    assert device_config["meter_id"] == 0
    counter = counter_sm.FroniusSmCounter(0, component_config, device_config)

    monkeypatch.setattr(SimCountLegacy, "sim_count", Mock(return_value=[0, 0]))
    requests_mock.get("http://" + SAMPLE_IP +
                      "/solar_api/v1/GetMeterRealtimeData.cgi",
                      json=json_grid)

    counter_state, meter_location = counter.update()

    assert counter_state.exported == 0
    assert counter_state.imported == 0
    assert counter_state.currents == [
        0.4339647008179079, 1.3994802944997833, 0.5339012669287898
    ]
    assert counter_state.frequency == 50
    assert counter_state.power == 546.16
    assert counter_state.powers == [100.81, 323.14, 122.21]
    assert counter_state.power_factors == [0.57, 0.74, 0.47]
    assert counter_state.voltages == [232.3, 230.9, 228.9]

    assert meter_location == MeterLocation.grid
예제 #4
0
def test_update_load(monkeypatch, requests_mock: requests_mock.Mocker,
                     mock_ramdisk):
    component_config = counter_sm.get_default_config()
    assert component_config["configuration"]["variant"] == 0
    device_config = device.get_default_config()["configuration"]
    device_config["ip_address"] = SAMPLE_IP
    device_config["meter_id"] = 2
    counter = counter_sm.FroniusSmCounter(0, component_config, device_config)

    monkeypatch.setattr(SimCountLegacy, "sim_count", Mock(return_value=[0, 0]))
    requests_mock.get("http://" + SAMPLE_IP +
                      "/solar_api/v1/GetMeterRealtimeData.cgi",
                      json=json_load_meter)

    requests_mock.get("http://" + SAMPLE_IP +
                      "/solar_api/v1/GetPowerFlowRealtimeData.fcgi",
                      json=json_load_power)

    counter_state, meter_location = counter.update()

    assert counter_state.exported == 0
    assert counter_state.imported == 0
    assert counter_state.currents == [
        -0.5803465765004227, -0.059532908704883224, -0.6287537218205019
    ]
    assert counter_state.frequency == 50
    assert counter_state.power == -1059.03
    assert counter_state.powers == [-137.31, -14.02, -147.82]
    assert counter_state.power_factors == [0.79, 0.42, 0.84]
    assert counter_state.voltages == [236.6, 235.5, 235.1]

    assert meter_location == MeterLocation.load
예제 #5
0
def test_update(monkeypatch, requests_mock: requests_mock.Mocker,
                mock_ramdisk):
    component_config = inverter.get_default_config()
    assert component_config["configuration"]["ip_address2"] == "none"
    device_config = device.get_default_config()["configuration"]
    device_config["ip_address"] = SAMPLE_IP
    wr = inverter.FroniusInverter(0, component_config, device_config)

    monkeypatch.setattr(SimCountLegacy, "sim_count", Mock(return_value=[0, 0]))
    requests_mock.get("http://" + SAMPLE_IP +
                      "/solar_api/v1/GetPowerFlowRealtimeData.fcgi",
                      json=json_wr1)

    inverter_state = wr.update()

    assert inverter_state.counter == 0
    assert inverter_state.currents == [0, 0, 0]
    assert inverter_state.power == -196.08712768554688
예제 #6
0
파일: bat_test.py 프로젝트: okaegi/openWB
def test_update(monkeypatch, requests_mock: requests_mock.Mocker,
                mock_ramdisk):
    component_config = bat.get_default_config()
    device_config = device.get_default_config()["configuration"]
    device_config["ip_address"] = SAMPLE_IP
    assert device_config["meter_id"] == 0
    battery = bat.FroniusBat(0, component_config, device_config)

    monkeypatch.setattr(SimCountLegacy, "sim_count", Mock(return_value=[0, 0]))
    requests_mock.get("http://" + SAMPLE_IP +
                      "/solar_api/v1/GetPowerFlowRealtimeData.fcgi",
                      json=json)

    battery_state = battery.update()

    assert battery_state.exported == 0
    assert battery_state.imported == 0
    assert battery_state.power == -2288
    assert battery_state.soc == 60.8
예제 #7
0
def test_update(monkeypatch, requests_mock: requests_mock.Mocker, mock_ramdisk):
    component_config = counter_s0.get_default_config()
    device_config = device.get_default_config()["configuration"]
    device_config["ip_address"] = SAMPLE_IP
    assert device_config["meter_id"] == 0
    counter = counter_s0.FroniusS0Counter(0, component_config, device_config)

    monkeypatch.setattr(SimCountLegacy, "sim_count", Mock(return_value=[0, 0]))
    requests_mock.get(
        "http://" + SAMPLE_IP + "/solar_api/v1/GetPowerFlowRealtimeData.fcgi",
        json=json)

    counter_state = counter.update()

    assert counter_state.exported == 0
    assert counter_state.imported == 0
    assert counter_state.currents == [0.0, 0.0, 0.0]
    assert counter_state.frequency == 50
    assert counter_state.power == 330.7664210983294
    assert counter_state.powers == [0, 0, 0]
    assert counter_state.power_factors == [0, 0, 0]
    assert counter_state.voltages == [230, 230, 230]