diff --git a/homeassistant/components/fronius/sensor.py b/homeassistant/components/fronius/sensor.py index ad3831f36914..1d096cd13fbb 100644 --- a/homeassistant/components/fronius/sensor.py +++ b/homeassistant/components/fronius/sensor.py @@ -336,10 +336,11 @@ def _modbus_mppt_descriptions( MODBUS_INVERTER_ENTITY_DESCRIPTIONS: list[FroniusSensorEntityDescription] = [ - # SunSpec model 160 supports up to 4 MPPT modules (GEN24 hybrid, Tauro) + # Verto Plus exposes 5 modules (3 PV trackers plus storage charge/discharge), + # one more leaves headroom for a hybrid with 4 PV trackers *( description - for mppt_no in range(1, 5) + for mppt_no in range(1, 7) for description in _modbus_mppt_descriptions(mppt_no) ), FroniusSensorEntityDescription( diff --git a/tests/components/fronius/test_modbus.py b/tests/components/fronius/test_modbus.py index 9806d2101281..ae1bca2f58e9 100644 --- a/tests/components/fronius/test_modbus.py +++ b/tests/components/fronius/test_modbus.py @@ -92,6 +92,54 @@ async def test_gen24_storage_mppt( assert len(solar_net.modbus_inverter_coordinators) == 1 +@pytest.mark.usefixtures("entity_registry_enabled_by_default") +async def test_verto_plus_five_modules( + hass: HomeAssistant, + aioclient_mock: AiohttpClientMocker, + mock_fronius_modbus: MockModbusConnection, +) -> None: + """Test a Verto Plus exposing 3 PV trackers plus storage charge/discharge.""" + mock_fronius_modbus.for_unit(1).holding.update( + build_sunspec_map( + [ + MpptModuleSpec( + id_str="MPPT 1", current=82, voltage=4021, power=3300, energy=1_000 + ), + MpptModuleSpec( + id_str="MPPT 2", current=41, voltage=4022, power=1650, energy=2_000 + ), + MpptModuleSpec( + id_str="MPPT 3", current=20, voltage=4023, power=800, energy=3_000 + ), + MpptModuleSpec( + id_str="StCha 4", current=0, voltage=0, power=0, energy=4_000 + ), + MpptModuleSpec( + id_str="StDisCha 5", + current=12, + voltage=3990, + power=480, + energy=5_000, + ), + ], + storage_wcha_max=5000, + ) + ) + mock_responses(aioclient_mock, fixture_set="gen24_storage") + with patch("homeassistant.components.fronius.PLATFORMS", [Platform.SENSOR]): + await setup_fronius_integration(hass, is_logger=False, unique_id="12345678") + + assert_state(hass, "sensor.gen24_storage_mppt_3_dc_power", 800) + assert_state(hass, "sensor.gen24_storage_mppt_4_dc_power", 0) + assert_state(hass, "sensor.gen24_storage_mppt_5_dc_current", 1.2) + assert_state(hass, "sensor.gen24_storage_mppt_5_dc_voltage", 399.0) + assert_state(hass, "sensor.gen24_storage_mppt_5_dc_power", 480) + assert_state(hass, "sensor.gen24_storage_mppt_5_energy", 5000) + assert_state(hass, "sensor.gen24_storage_pv_energy_total", 6000) + assert_state(hass, "sensor.gen24_storage_battery_charging_energy_total", 4000) + assert_state(hass, "sensor.gen24_storage_battery_discharging_energy_total", 5000) + + @pytest.mark.usefixtures("entity_registry_enabled_by_default") @pytest.mark.parametrize( ("storage_id_str", "expected_pv_energy_total"),