1
0
mirror of https://github.com/home-assistant/core.git synced 2026-05-08 17:49:37 +01:00

Enable HomeWizard Battery group mode by default when device controls batteries (#159493)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Duco Sebel
2025-12-23 18:54:28 +01:00
committed by GitHub
parent 5933c09a1d
commit bcc5985c8b
6 changed files with 108 additions and 8 deletions
@@ -44,11 +44,16 @@ class HomeWizardBatteryModeSelectEntity(HomeWizardEntity, SelectEntity):
"""Initialize the switch."""
super().__init__(coordinator)
batteries = coordinator.data.batteries
battery_count = batteries.battery_count if batteries is not None else None
entity_registry_enabled_default = (
battery_count is not None and battery_count > 0
)
description = SelectEntityDescription(
key="battery_group_mode",
translation_key="battery_group_mode",
entity_category=EntityCategory.CONFIG,
entity_registry_enabled_default=False,
entity_registry_enabled_default=entity_registry_enabled_default,
options=[
str(mode)
for mode in (coordinator.data.device.supported_battery_modes() or [])
@@ -0,0 +1,9 @@
{
"mode": "zero",
"permissions": ["charge_allowed", "discharge_allowed"],
"battery_count": 0,
"power_w": 0,
"target_power_w": 0,
"max_consumption_w": 0,
"max_production_w": 0
}
@@ -0,0 +1,82 @@
{
"wifi_ssid": "My Wi-Fi",
"wifi_strength": 100,
"smr_version": 50,
"meter_model": "ISKRA 2M550T-101",
"unique_id": "00112233445566778899AABBCCDDEEFF",
"active_tariff": 2,
"total_power_import_kwh": 13779.338,
"total_power_import_t1_kwh": 10830.511,
"total_power_import_t2_kwh": 2948.827,
"total_power_import_t3_kwh": 2948.827,
"total_power_import_t4_kwh": 2948.827,
"total_power_export_kwh": 13086.777,
"total_power_export_t1_kwh": 4321.333,
"total_power_export_t2_kwh": 8765.444,
"total_power_export_t3_kwh": 8765.444,
"total_power_export_t4_kwh": 8765.444,
"active_power_w": -123,
"active_power_l1_w": -123,
"active_power_l2_w": 456,
"active_power_l3_w": 123.456,
"active_voltage_l1_v": 230.111,
"active_voltage_l2_v": 230.222,
"active_voltage_l3_v": 230.333,
"active_current_l1_a": -4,
"active_current_l2_a": 2,
"active_current_l3_a": 0,
"active_frequency_hz": 50,
"voltage_sag_l1_count": 1,
"voltage_sag_l2_count": 2,
"voltage_sag_l3_count": 3,
"voltage_swell_l1_count": 4,
"voltage_swell_l2_count": 5,
"voltage_swell_l3_count": 6,
"any_power_fail_count": 4,
"long_power_fail_count": 5,
"total_gas_m3": 1122.333,
"gas_timestamp": 210314112233,
"gas_unique_id": "01FFEEDDCCBBAA99887766554433221100",
"active_power_average_w": 123.0,
"montly_power_peak_w": 1111.0,
"montly_power_peak_timestamp": 230101080010,
"active_liter_lpm": 12.345,
"total_liter_m3": 1234.567,
"external": [
{
"unique_id": "47303031",
"type": "gas_meter",
"timestamp": 230125220957,
"value": 111.111,
"unit": "m3"
},
{
"unique_id": "57303031",
"type": "water_meter",
"timestamp": 230125220957,
"value": 222.222,
"unit": "m3"
},
{
"unique_id": "5757303031",
"type": "warm_water_meter",
"timestamp": 230125220957,
"value": 333.333,
"unit": "m3"
},
{
"unique_id": "48303031",
"type": "heat_meter",
"timestamp": 230125220957,
"value": 444.444,
"unit": "GJ"
},
{
"unique_id": "4948303031",
"type": "inlet_heat_meter",
"timestamp": 230125220957,
"value": 555.555,
"unit": "m3"
}
]
}
@@ -0,0 +1,7 @@
{
"product_type": "HWE-P1",
"product_name": "P1 meter",
"serial": "5c2fafabcdef",
"firmware_version": "4.19",
"api_version": "v1"
}
@@ -0,0 +1,3 @@
{
"cloud_enabled": true
}
+1 -7
View File
@@ -77,7 +77,6 @@ async def test_entities_not_created_for_device(
("HWE-P1", "select.device_battery_group_mode"),
],
)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_select_entity_snapshots(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
@@ -115,7 +114,6 @@ async def test_select_entity_snapshots(
("HWE-P1", "select.device_battery_group_mode", "zero", Batteries.Mode.ZERO),
],
)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_select_set_option(
hass: HomeAssistant,
mock_homewizardenergy: MagicMock,
@@ -144,7 +142,6 @@ async def test_select_set_option(
("HWE-P1", "select.device_battery_group_mode", "to_full"),
],
)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_select_request_error(
hass: HomeAssistant,
mock_homewizardenergy: MagicMock,
@@ -174,7 +171,6 @@ async def test_select_request_error(
("HWE-P1", "select.device_battery_group_mode", "to_full"),
],
)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_select_unauthorized_error(
hass: HomeAssistant,
mock_homewizardenergy: MagicMock,
@@ -206,7 +202,6 @@ async def test_select_unauthorized_error(
("select.device_battery_group_mode", "combined"),
],
)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_select_unreachable(
hass: HomeAssistant,
mock_homewizardenergy: MagicMock,
@@ -230,7 +225,6 @@ async def test_select_unreachable(
("HWE-P1", "select.device_battery_group_mode"),
],
)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_select_multiple_state_changes(
hass: HomeAssistant,
mock_homewizardenergy: MagicMock,
@@ -275,7 +269,7 @@ async def test_select_multiple_state_changes(
("device_fixture", "entity_ids"),
[
(
"HWE-P1",
"HWE-P1-no-batteries",
[
"select.device_battery_group_mode",
],