mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Add device fixtures and tests for HomeWizard Energy Watersensor (#103383)
Co-authored-by: Duco Sebel <74970928+DCSBL@users.noreply.github.com>
This commit is contained in:
parent
ad22a11485
commit
08b43c4477
46
tests/components/homewizard/fixtures/HWE-WTR/data.json
Normal file
46
tests/components/homewizard/fixtures/HWE-WTR/data.json
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"wifi_ssid": "My Wi-Fi",
|
||||
"wifi_strength": 84,
|
||||
"smr_version": null,
|
||||
"meter_model": null,
|
||||
"unique_meter_id": null,
|
||||
"active_tariff": null,
|
||||
"total_power_import_kwh": null,
|
||||
"total_power_import_t1_kwh": null,
|
||||
"total_power_import_t2_kwh": null,
|
||||
"total_power_import_t3_kwh": null,
|
||||
"total_power_import_t4_kwh": null,
|
||||
"total_power_export_kwh": null,
|
||||
"total_power_export_t1_kwh": null,
|
||||
"total_power_export_t2_kwh": null,
|
||||
"total_power_export_t3_kwh": null,
|
||||
"total_power_export_t4_kwh": null,
|
||||
"active_power_w": null,
|
||||
"active_power_l1_w": null,
|
||||
"active_power_l2_w": null,
|
||||
"active_power_l3_w": null,
|
||||
"active_voltage_l1_v": null,
|
||||
"active_voltage_l2_v": null,
|
||||
"active_voltage_l3_v": null,
|
||||
"active_current_l1_a": null,
|
||||
"active_current_l2_a": null,
|
||||
"active_current_l3_a": null,
|
||||
"active_frequency_hz": null,
|
||||
"voltage_sag_l1_count": null,
|
||||
"voltage_sag_l2_count": null,
|
||||
"voltage_sag_l3_count": null,
|
||||
"voltage_swell_l1_count": null,
|
||||
"voltage_swell_l2_count": null,
|
||||
"voltage_swell_l3_count": null,
|
||||
"any_power_fail_count": null,
|
||||
"long_power_fail_count": null,
|
||||
"active_power_average_w": null,
|
||||
"monthly_power_peak_w": null,
|
||||
"monthly_power_peak_timestamp": null,
|
||||
"total_gas_m3": null,
|
||||
"gas_timestamp": null,
|
||||
"gas_unique_id": null,
|
||||
"active_liter_lpm": 0,
|
||||
"total_liter_m3": 17.014,
|
||||
"external_devices": null
|
||||
}
|
7
tests/components/homewizard/fixtures/HWE-WTR/device.json
Normal file
7
tests/components/homewizard/fixtures/HWE-WTR/device.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"product_type": "HWE-WTR",
|
||||
"product_name": "Watermeter",
|
||||
"serial": "3c39e7aabbcc",
|
||||
"firmware_version": "2.03",
|
||||
"api_version": "v1"
|
||||
}
|
@ -141,6 +141,73 @@
|
||||
}),
|
||||
})
|
||||
# ---
|
||||
# name: test_diagnostics[HWE-WTR]
|
||||
dict({
|
||||
'data': dict({
|
||||
'data': dict({
|
||||
'active_current_l1_a': None,
|
||||
'active_current_l2_a': None,
|
||||
'active_current_l3_a': None,
|
||||
'active_frequency_hz': None,
|
||||
'active_liter_lpm': 0,
|
||||
'active_power_average_w': None,
|
||||
'active_power_l1_w': None,
|
||||
'active_power_l2_w': None,
|
||||
'active_power_l3_w': None,
|
||||
'active_power_w': None,
|
||||
'active_tariff': None,
|
||||
'active_voltage_l1_v': None,
|
||||
'active_voltage_l2_v': None,
|
||||
'active_voltage_l3_v': None,
|
||||
'any_power_fail_count': None,
|
||||
'external_devices': None,
|
||||
'gas_timestamp': None,
|
||||
'gas_unique_id': None,
|
||||
'long_power_fail_count': None,
|
||||
'meter_model': None,
|
||||
'monthly_power_peak_timestamp': None,
|
||||
'monthly_power_peak_w': None,
|
||||
'smr_version': None,
|
||||
'total_energy_export_kwh': None,
|
||||
'total_energy_export_t1_kwh': None,
|
||||
'total_energy_export_t2_kwh': None,
|
||||
'total_energy_export_t3_kwh': None,
|
||||
'total_energy_export_t4_kwh': None,
|
||||
'total_energy_import_kwh': None,
|
||||
'total_energy_import_t1_kwh': None,
|
||||
'total_energy_import_t2_kwh': None,
|
||||
'total_energy_import_t3_kwh': None,
|
||||
'total_energy_import_t4_kwh': None,
|
||||
'total_gas_m3': None,
|
||||
'total_liter_m3': 17.014,
|
||||
'unique_meter_id': None,
|
||||
'voltage_sag_l1_count': None,
|
||||
'voltage_sag_l2_count': None,
|
||||
'voltage_sag_l3_count': None,
|
||||
'voltage_swell_l1_count': None,
|
||||
'voltage_swell_l2_count': None,
|
||||
'voltage_swell_l3_count': None,
|
||||
'wifi_ssid': '**REDACTED**',
|
||||
'wifi_strength': 84,
|
||||
}),
|
||||
'device': dict({
|
||||
'api_version': 'v1',
|
||||
'firmware_version': '2.03',
|
||||
'product_name': 'Watermeter',
|
||||
'product_type': 'HWE-WTR',
|
||||
'serial': '**REDACTED**',
|
||||
}),
|
||||
'state': None,
|
||||
'system': None,
|
||||
}),
|
||||
'entry': dict({
|
||||
'ip_address': '**REDACTED**',
|
||||
'product_name': 'Product name',
|
||||
'product_type': 'product_type',
|
||||
'serial': '**REDACTED**',
|
||||
}),
|
||||
})
|
||||
# ---
|
||||
# name: test_diagnostics[SDM230]
|
||||
dict({
|
||||
'data': dict({
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -17,7 +17,7 @@ pytestmark = [
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["SDM230"])
|
||||
@pytest.mark.parametrize("device_fixture", ["HWE-WTR", "SDM230"])
|
||||
async def test_identify_button_entity_not_loaded_when_not_available(
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
|
@ -10,7 +10,15 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry
|
||||
from tests.typing import ClientSessionGenerator
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["HWE-P1", "HWE-SKT", "SDM230"])
|
||||
@pytest.mark.parametrize(
|
||||
"device_fixture",
|
||||
[
|
||||
"HWE-P1",
|
||||
"HWE-SKT",
|
||||
"HWE-WTR",
|
||||
"SDM230",
|
||||
],
|
||||
)
|
||||
async def test_diagnostics(
|
||||
hass: HomeAssistant,
|
||||
hass_client: ClientSessionGenerator,
|
||||
|
@ -16,8 +16,11 @@ import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
|
||||
pytestmark = [
|
||||
pytest.mark.usefixtures("init_integration"),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_integration")
|
||||
@pytest.mark.parametrize("device_fixture", ["HWE-SKT"])
|
||||
async def test_number_entities(
|
||||
hass: HomeAssistant,
|
||||
@ -86,3 +89,9 @@ async def test_number_entities(
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["HWE-WTR"])
|
||||
async def test_entities_not_created_for_device(hass: HomeAssistant) -> None:
|
||||
"""Does not load button when device has no support for it."""
|
||||
assert not hass.states.get("number.device_status_light_brightness")
|
||||
|
@ -68,10 +68,19 @@ pytestmark = [
|
||||
"sensor.device_active_water_usage",
|
||||
"sensor.device_total_water_usage",
|
||||
],
|
||||
)
|
||||
),
|
||||
(
|
||||
"HWE-WTR",
|
||||
[
|
||||
"sensor.device_wi_fi_ssid",
|
||||
"sensor.device_wi_fi_strength",
|
||||
"sensor.device_active_water_usage",
|
||||
"sensor.device_total_water_usage",
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_sensors_p1_meter(
|
||||
async def test_sensors(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
@ -92,27 +101,39 @@ async def test_sensors_p1_meter(
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"entity_id",
|
||||
("device_fixture", "entity_ids"),
|
||||
[
|
||||
"sensor.device_wi_fi_strength",
|
||||
"sensor.device_active_voltage_phase_1",
|
||||
"sensor.device_active_voltage_phase_2",
|
||||
"sensor.device_active_voltage_phase_3",
|
||||
"sensor.device_active_current_phase_1",
|
||||
"sensor.device_active_current_phase_2",
|
||||
"sensor.device_active_current_phase_3",
|
||||
"sensor.device_active_frequency",
|
||||
(
|
||||
"HWE-P1",
|
||||
[
|
||||
"sensor.device_wi_fi_strength",
|
||||
"sensor.device_active_voltage_phase_1",
|
||||
"sensor.device_active_voltage_phase_2",
|
||||
"sensor.device_active_voltage_phase_3",
|
||||
"sensor.device_active_current_phase_1",
|
||||
"sensor.device_active_current_phase_2",
|
||||
"sensor.device_active_current_phase_3",
|
||||
"sensor.device_active_frequency",
|
||||
],
|
||||
),
|
||||
(
|
||||
"HWE-WTR",
|
||||
[
|
||||
"sensor.device_wi_fi_strength",
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_disabled_by_default_sensors(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, entity_id: str
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, entity_ids: list[str]
|
||||
) -> None:
|
||||
"""Test the disabled by default sensors."""
|
||||
assert not hass.states.get(entity_id)
|
||||
for entity_id in entity_ids:
|
||||
assert not hass.states.get(entity_id)
|
||||
|
||||
assert (entry := entity_registry.async_get(entity_id))
|
||||
assert entry.disabled
|
||||
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
||||
assert (entry := entity_registry.async_get(entity_id))
|
||||
assert entry.disabled
|
||||
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["HWE-P1-unused-exports"])
|
||||
@ -155,3 +176,59 @@ async def test_sensors_unreachable(
|
||||
|
||||
assert (state := hass.states.get(state.entity_id))
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("device_fixture", "entity_ids"),
|
||||
[
|
||||
(
|
||||
"HWE-WTR",
|
||||
[
|
||||
"sensor.device_dsmr_version",
|
||||
"sensor.device_smart_meter_model",
|
||||
"sensor.device_smart_meter_identifier",
|
||||
"sensor.device_active_tariff",
|
||||
"sensor.device_total_energy_import",
|
||||
"sensor.device_total_energy_import_tariff_1",
|
||||
"sensor.device_total_energy_import_tariff_2",
|
||||
"sensor.device_total_energy_import_tariff_3",
|
||||
"sensor.device_total_energy_import_tariff_4",
|
||||
"sensor.device_total_energy_export",
|
||||
"sensor.device_total_energy_export_tariff_1",
|
||||
"sensor.device_total_energy_export_tariff_2",
|
||||
"sensor.device_total_energy_export_tariff_3",
|
||||
"sensor.device_total_energy_export_tariff_4",
|
||||
"sensor.device_active_power",
|
||||
"sensor.device_active_power_phase_1",
|
||||
"sensor.device_active_power_phase_2",
|
||||
"sensor.device_active_power_phase_3",
|
||||
"sensor.device_active_voltage_phase_1",
|
||||
"sensor.device_active_voltage_phase_2",
|
||||
"sensor.device_active_voltage_phase_3",
|
||||
"sensor.device_active_current_phase_1",
|
||||
"sensor.device_active_current_phase_2",
|
||||
"sensor.device_active_current_phase_3",
|
||||
"sensor.device_active_frequency",
|
||||
"sensor.device_voltage_sags_detected_phase_1",
|
||||
"sensor.device_voltage_sags_detected_phase_2",
|
||||
"sensor.device_voltage_sags_detected_phase_3",
|
||||
"sensor.device_voltage_swells_detected_phase_1",
|
||||
"sensor.device_voltage_swells_detected_phase_2",
|
||||
"sensor.device_voltage_swells_detected_phase_3",
|
||||
"sensor.device_power_failures_detected",
|
||||
"sensor.device_long_power_failures_detected",
|
||||
"sensor.device_active_average_demand",
|
||||
"sensor.device_peak_demand_current_month",
|
||||
"sensor.device_total_gas",
|
||||
"sensor.device_gas_meter_identifier",
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_entities_not_created_for_device(
|
||||
hass: HomeAssistant,
|
||||
entity_ids: list[str],
|
||||
) -> None:
|
||||
"""Ensures entities for a specific device are not created."""
|
||||
for entity_id in entity_ids:
|
||||
assert not hass.states.get(entity_id)
|
||||
|
@ -26,6 +26,28 @@ pytestmark = [
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("device_fixture", "entity_ids"),
|
||||
[
|
||||
(
|
||||
"HWE-WTR",
|
||||
[
|
||||
"switch.device",
|
||||
"switch.device_switch_lock",
|
||||
"switch.device_cloud_connection",
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_entities_not_created_for_device(
|
||||
hass: HomeAssistant,
|
||||
entity_ids: list[str],
|
||||
) -> None:
|
||||
"""Ensures entities for a specific device are not created."""
|
||||
for entity_id in entity_ids:
|
||||
assert not hass.states.get(entity_id)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("device_fixture", ["HWE-SKT"])
|
||||
@pytest.mark.parametrize(
|
||||
("entity_id", "method", "parameter"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user