Add new HomeWizard Energy Socket to tests (#113406)

pull/114008/head
Duco Sebel 2024-03-22 16:48:27 +01:00 committed by GitHub
parent 7df0d3b140
commit cad3be8213
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 2702 additions and 10358 deletions

View File

@ -0,0 +1,16 @@
{
"wifi_ssid": "My Wi-Fi",
"wifi_strength": 100,
"total_power_import_kwh": 30.511,
"total_power_import_t1_kwh": 30.511,
"total_power_export_kwh": 85.951,
"total_power_export_t1_kwh": 85.951,
"active_power_w": 543.312,
"active_power_l1_w": 543.312,
"active_voltage_v": 231.539,
"active_current_a": 2.346,
"active_reactive_power_var": 123.456,
"active_apparent_power_va": 666.768,
"active_power_factor": 0.81688,
"active_frequency_hz": 50.005
}

View File

@ -0,0 +1,7 @@
{
"product_type": "HWE-SKT",
"product_name": "Energy Socket",
"serial": "3c39e7aabbcc",
"firmware_version": "4.07",
"api_version": "v1"
}

View File

@ -0,0 +1,5 @@
{
"power_on": true,
"switch_lock": false,
"brightness": 255
}

View File

@ -0,0 +1,3 @@
{
"cloud_enabled": true
}

View File

@ -299,7 +299,7 @@
}),
})
# ---
# name: test_diagnostics[HWE-SKT]
# name: test_diagnostics[HWE-SKT-11]
dict({
'data': dict({
'data': dict({
@ -386,6 +386,93 @@
}),
})
# ---
# name: test_diagnostics[HWE-SKT-21]
dict({
'data': dict({
'data': dict({
'active_apparent_power_l1_va': None,
'active_apparent_power_l2_va': None,
'active_apparent_power_l3_va': None,
'active_apparent_power_va': 666.768,
'active_current_a': 2.346,
'active_current_l1_a': None,
'active_current_l2_a': None,
'active_current_l3_a': None,
'active_frequency_hz': 50.005,
'active_liter_lpm': None,
'active_power_average_w': None,
'active_power_factor': 0.81688,
'active_power_factor_l1': None,
'active_power_factor_l2': None,
'active_power_factor_l3': None,
'active_power_l1_w': 543.312,
'active_power_l2_w': None,
'active_power_l3_w': None,
'active_power_w': 543.312,
'active_reactive_power_l1_var': None,
'active_reactive_power_l2_var': None,
'active_reactive_power_l3_var': None,
'active_reactive_power_var': 123.456,
'active_tariff': None,
'active_voltage_l1_v': None,
'active_voltage_l2_v': None,
'active_voltage_l3_v': None,
'active_voltage_v': 231.539,
'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': 85.951,
'total_energy_export_t1_kwh': 85.951,
'total_energy_export_t2_kwh': None,
'total_energy_export_t3_kwh': None,
'total_energy_export_t4_kwh': None,
'total_energy_import_kwh': 30.511,
'total_energy_import_t1_kwh': 30.511,
'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': None,
'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': 100,
}),
'device': dict({
'api_version': 'v1',
'firmware_version': '4.07',
'product_name': 'Energy Socket',
'product_type': 'HWE-SKT',
'serial': '**REDACTED**',
}),
'state': dict({
'brightness': 255,
'power_on': True,
'switch_lock': False,
}),
'system': dict({
'cloud_enabled': True,
}),
}),
'entry': dict({
'ip_address': '**REDACTED**',
'product_name': 'Product name',
'product_type': 'product_type',
'serial': '**REDACTED**',
}),
})
# ---
# name: test_diagnostics[HWE-WTR]
dict({
'data': dict({

View File

@ -1,5 +1,5 @@
# serializer version: 1
# name: test_number_entities[HWE-SKT]
# name: test_number_entities[HWE-SKT-11]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Device Status light brightness',
@ -17,7 +17,7 @@
'state': '100.0',
})
# ---
# name: test_number_entities[HWE-SKT].1
# name: test_number_entities[HWE-SKT-11].1
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -55,7 +55,7 @@
'unit_of_measurement': '%',
})
# ---
# name: test_number_entities[HWE-SKT].2
# name: test_number_entities[HWE-SKT-11].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
@ -89,3 +89,93 @@
'via_device_id': None,
})
# ---
# name: test_number_entities[HWE-SKT-21]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Device Status light brightness',
'max': 100.0,
'min': 0.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0,
'unit_of_measurement': '%',
}),
'context': <ANY>,
'entity_id': 'number.device_status_light_brightness',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '100.0',
})
# ---
# name: test_number_entities[HWE-SKT-21].1
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 100.0,
'min': 0.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'number',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'number.device_status_light_brightness',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Status light brightness',
'platform': 'homewizard',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'status_light_brightness',
'unique_id': 'aabbccddeeff_status_light_brightness',
'unit_of_measurement': '%',
})
# ---
# name: test_number_entities[HWE-SKT-21].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'configuration_url': None,
'connections': set({
tuple(
'mac',
'3c:39:e7:aa:bb:cc',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'homewizard',
'3c39e7aabbcc',
),
}),
'is_new': False,
'labels': set({
}),
'manufacturer': 'HomeWizard',
'model': 'HWE-SKT',
'name': 'Device',
'name_by_user': None,
'serial_number': None,
'suggested_area': None,
'sw_version': '4.07',
'via_device_id': None,
})
# ---

File diff suppressed because it is too large Load Diff

View File

@ -159,7 +159,7 @@
'via_device_id': None,
})
# ---
# name: test_switch_entities[HWE-SKT-switch.device-state_set-power_on]
# name: test_switch_entities[HWE-SKT-11-switch.device-state_set-power_on]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'outlet',
@ -173,7 +173,7 @@
'state': 'on',
})
# ---
# name: test_switch_entities[HWE-SKT-switch.device-state_set-power_on].1
# name: test_switch_entities[HWE-SKT-11-switch.device-state_set-power_on].1
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -206,7 +206,7 @@
'unit_of_measurement': None,
})
# ---
# name: test_switch_entities[HWE-SKT-switch.device-state_set-power_on].2
# name: test_switch_entities[HWE-SKT-11-switch.device-state_set-power_on].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
@ -240,7 +240,7 @@
'via_device_id': None,
})
# ---
# name: test_switch_entities[HWE-SKT-switch.device_cloud_connection-system_set-cloud_enabled]
# name: test_switch_entities[HWE-SKT-11-switch.device_cloud_connection-system_set-cloud_enabled]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Device Cloud connection',
@ -253,7 +253,7 @@
'state': 'on',
})
# ---
# name: test_switch_entities[HWE-SKT-switch.device_cloud_connection-system_set-cloud_enabled].1
# name: test_switch_entities[HWE-SKT-11-switch.device_cloud_connection-system_set-cloud_enabled].1
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -286,7 +286,7 @@
'unit_of_measurement': None,
})
# ---
# name: test_switch_entities[HWE-SKT-switch.device_cloud_connection-system_set-cloud_enabled].2
# name: test_switch_entities[HWE-SKT-11-switch.device_cloud_connection-system_set-cloud_enabled].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
@ -320,7 +320,7 @@
'via_device_id': None,
})
# ---
# name: test_switch_entities[HWE-SKT-switch.device_switch_lock-state_set-switch_lock]
# name: test_switch_entities[HWE-SKT-11-switch.device_switch_lock-state_set-switch_lock]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Device Switch lock',
@ -333,7 +333,7 @@
'state': 'off',
})
# ---
# name: test_switch_entities[HWE-SKT-switch.device_switch_lock-state_set-switch_lock].1
# name: test_switch_entities[HWE-SKT-11-switch.device_switch_lock-state_set-switch_lock].1
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -366,7 +366,7 @@
'unit_of_measurement': None,
})
# ---
# name: test_switch_entities[HWE-SKT-switch.device_switch_lock-state_set-switch_lock].2
# name: test_switch_entities[HWE-SKT-11-switch.device_switch_lock-state_set-switch_lock].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
@ -400,6 +400,247 @@
'via_device_id': None,
})
# ---
# name: test_switch_entities[HWE-SKT-21-switch.device-state_set-power_on]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'outlet',
'friendly_name': 'Device',
}),
'context': <ANY>,
'entity_id': 'switch.device',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_switch_entities[HWE-SKT-21-switch.device-state_set-power_on].1
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.device',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.OUTLET: 'outlet'>,
'original_icon': None,
'original_name': None,
'platform': 'homewizard',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': 'aabbccddeeff_power_on',
'unit_of_measurement': None,
})
# ---
# name: test_switch_entities[HWE-SKT-21-switch.device-state_set-power_on].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'configuration_url': None,
'connections': set({
tuple(
'mac',
'3c:39:e7:aa:bb:cc',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'homewizard',
'3c39e7aabbcc',
),
}),
'is_new': False,
'labels': set({
}),
'manufacturer': 'HomeWizard',
'model': 'HWE-SKT',
'name': 'Device',
'name_by_user': None,
'serial_number': None,
'suggested_area': None,
'sw_version': '4.07',
'via_device_id': None,
})
# ---
# name: test_switch_entities[HWE-SKT-21-switch.device_cloud_connection-system_set-cloud_enabled]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Device Cloud connection',
}),
'context': <ANY>,
'entity_id': 'switch.device_cloud_connection',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_switch_entities[HWE-SKT-21-switch.device_cloud_connection-system_set-cloud_enabled].1
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.device_cloud_connection',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Cloud connection',
'platform': 'homewizard',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'cloud_connection',
'unique_id': 'aabbccddeeff_cloud_connection',
'unit_of_measurement': None,
})
# ---
# name: test_switch_entities[HWE-SKT-21-switch.device_cloud_connection-system_set-cloud_enabled].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'configuration_url': None,
'connections': set({
tuple(
'mac',
'3c:39:e7:aa:bb:cc',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'homewizard',
'3c39e7aabbcc',
),
}),
'is_new': False,
'labels': set({
}),
'manufacturer': 'HomeWizard',
'model': 'HWE-SKT',
'name': 'Device',
'name_by_user': None,
'serial_number': None,
'suggested_area': None,
'sw_version': '4.07',
'via_device_id': None,
})
# ---
# name: test_switch_entities[HWE-SKT-21-switch.device_switch_lock-state_set-switch_lock]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Device Switch lock',
}),
'context': <ANY>,
'entity_id': 'switch.device_switch_lock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_entities[HWE-SKT-21-switch.device_switch_lock-state_set-switch_lock].1
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'switch.device_switch_lock',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Switch lock',
'platform': 'homewizard',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'switch_lock',
'unique_id': 'aabbccddeeff_switch_lock',
'unit_of_measurement': None,
})
# ---
# name: test_switch_entities[HWE-SKT-21-switch.device_switch_lock-state_set-switch_lock].2
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'configuration_url': None,
'connections': set({
tuple(
'mac',
'3c:39:e7:aa:bb:cc',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'homewizard',
'3c39e7aabbcc',
),
}),
'is_new': False,
'labels': set({
}),
'manufacturer': 'HomeWizard',
'model': 'HWE-SKT',
'name': 'Device',
'name_by_user': None,
'serial_number': None,
'suggested_area': None,
'sw_version': '4.07',
'via_device_id': None,
})
# ---
# name: test_switch_entities[SDM230-switch.device_cloud_connection-system_set-cloud_enabled]
StateSnapshot({
'attributes': ReadOnlyDict({

View File

@ -14,7 +14,8 @@ from tests.typing import ClientSessionGenerator
"device_fixture",
[
"HWE-P1",
"HWE-SKT",
"HWE-SKT-11",
"HWE-SKT-21",
"HWE-WTR",
"SDM230",
"SDM630",

View File

@ -126,12 +126,22 @@ async def test_load_handles_homewizardenergy_exception(
("device_fixture", "old_unique_id", "new_unique_id"),
[
(
"HWE-SKT",
"HWE-SKT-11",
"aabbccddeeff_total_power_import_t1_kwh",
"aabbccddeeff_total_power_import_kwh",
),
(
"HWE-SKT",
"HWE-SKT-11",
"aabbccddeeff_total_power_export_t1_kwh",
"aabbccddeeff_total_power_export_kwh",
),
(
"HWE-SKT-21",
"aabbccddeeff_total_power_import_t1_kwh",
"aabbccddeeff_total_power_import_kwh",
),
(
"HWE-SKT-21",
"aabbccddeeff_total_power_export_t1_kwh",
"aabbccddeeff_total_power_export_kwh",
),
@ -170,12 +180,22 @@ async def test_sensor_migration(
("device_fixture", "old_unique_id", "new_unique_id"),
[
(
"HWE-SKT",
"HWE-SKT-11",
"aabbccddeeff_total_power_import_t1_kwh",
"aabbccddeeff_total_power_import_kwh",
),
(
"HWE-SKT",
"HWE-SKT-11",
"aabbccddeeff_total_power_export_t1_kwh",
"aabbccddeeff_total_power_export_kwh",
),
(
"HWE-SKT-21",
"aabbccddeeff_total_power_import_t1_kwh",
"aabbccddeeff_total_power_import_kwh",
),
(
"HWE-SKT-21",
"aabbccddeeff_total_power_export_t1_kwh",
"aabbccddeeff_total_power_export_kwh",
),

View File

@ -22,7 +22,7 @@ pytestmark = [
]
@pytest.mark.parametrize("device_fixture", ["HWE-SKT"])
@pytest.mark.parametrize("device_fixture", ["HWE-SKT-11", "HWE-SKT-21"])
async def test_number_entities(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,

View File

@ -112,7 +112,7 @@ pytestmark = [
],
),
(
"HWE-SKT",
"HWE-SKT-11",
[
"sensor.device_energy_export",
"sensor.device_energy_import",
@ -122,6 +122,23 @@ pytestmark = [
"sensor.device_wi_fi_strength",
],
),
(
"HWE-SKT-21",
[
"sensor.device_apparent_power",
"sensor.device_current",
"sensor.device_energy_export",
"sensor.device_energy_import",
"sensor.device_frequency",
"sensor.device_power_factor",
"sensor.device_power_phase_1",
"sensor.device_power",
"sensor.device_reactive_power",
"sensor.device_voltage",
"sensor.device_wi_fi_ssid",
"sensor.device_wi_fi_strength",
],
),
(
"HWE-WTR",
[
@ -276,7 +293,13 @@ async def test_sensors(
],
),
(
"HWE-SKT",
"HWE-SKT-11",
[
"sensor.device_wi_fi_strength",
],
),
(
"HWE-SKT-21",
[
"sensor.device_wi_fi_strength",
],
@ -413,7 +436,7 @@ async def test_external_sensors_unreachable(
("device_fixture", "entity_ids"),
[
(
"HWE-SKT",
"HWE-SKT-11",
[
"sensor.device_apparent_power_phase_1",
"sensor.device_apparent_power_phase_2",
@ -464,6 +487,52 @@ async def test_external_sensors_unreachable(
"sensor.device_water_usage",
],
),
(
"HWE-SKT-21",
[
"sensor.device_apparent_power_phase_1",
"sensor.device_apparent_power_phase_2",
"sensor.device_apparent_power_phase_3",
"sensor.device_average_demand",
"sensor.device_current_phase_1",
"sensor.device_current_phase_2",
"sensor.device_current_phase_3",
"sensor.device_dsmr_version",
"sensor.device_energy_export_tariff_1",
"sensor.device_energy_export_tariff_2",
"sensor.device_energy_export_tariff_3",
"sensor.device_energy_export_tariff_4",
"sensor.device_energy_import_tariff_1",
"sensor.device_energy_import_tariff_2",
"sensor.device_energy_import_tariff_3",
"sensor.device_energy_import_tariff_4",
"sensor.device_long_power_failures_detected",
"sensor.device_peak_demand_current_month",
"sensor.device_power_factor_phase_1",
"sensor.device_power_factor_phase_2",
"sensor.device_power_factor_phase_3",
"sensor.device_power_failures_detected",
"sensor.device_power_phase_2",
"sensor.device_power_phase_3",
"sensor.device_reactive_power_phase_1",
"sensor.device_reactive_power_phase_2",
"sensor.device_reactive_power_phase_3",
"sensor.device_smart_meter_identifier",
"sensor.device_smart_meter_model",
"sensor.device_tariff",
"sensor.device_total_water_usage",
"sensor.device_voltage_phase_1",
"sensor.device_voltage_phase_2",
"sensor.device_voltage_phase_3",
"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_water_usage",
],
),
(
"HWE-WTR",
[

View File

@ -87,9 +87,12 @@ async def test_entities_not_created_for_device(
@pytest.mark.parametrize(
("device_fixture", "entity_id", "method", "parameter"),
[
("HWE-SKT", "switch.device", "state_set", "power_on"),
("HWE-SKT", "switch.device_switch_lock", "state_set", "switch_lock"),
("HWE-SKT", "switch.device_cloud_connection", "system_set", "cloud_enabled"),
("HWE-SKT-11", "switch.device", "state_set", "power_on"),
("HWE-SKT-11", "switch.device_switch_lock", "state_set", "switch_lock"),
("HWE-SKT-11", "switch.device_cloud_connection", "system_set", "cloud_enabled"),
("HWE-SKT-21", "switch.device", "state_set", "power_on"),
("HWE-SKT-21", "switch.device_switch_lock", "state_set", "switch_lock"),
("HWE-SKT-21", "switch.device_cloud_connection", "system_set", "cloud_enabled"),
("SDM230", "switch.device_cloud_connection", "system_set", "cloud_enabled"),
("SDM630", "switch.device_cloud_connection", "system_set", "cloud_enabled"),
("HWE-KWH1", "switch.device_cloud_connection", "system_set", "cloud_enabled"),
@ -192,7 +195,7 @@ async def test_switch_entities(
)
@pytest.mark.parametrize("device_fixture", ["HWE-SKT"])
@pytest.mark.parametrize("device_fixture", ["HWE-SKT-11", "HWE-SKT-21"])
@pytest.mark.parametrize("exception", [RequestError, UnsupportedError])
@pytest.mark.parametrize(
("entity_id", "method"),