Add Computer Name to device in Libre Hardware Monitor (#159342)

This commit is contained in:
Sab44
2025-12-23 19:54:35 +01:00
committed by GitHub
parent aa20a74a76
commit a3dec29c72
12 changed files with 246 additions and 239 deletions
@@ -8,7 +8,7 @@
"Children": [
{
"id": 1,
"Text": "GAMING",
"Text": "GAMING-PC",
"Min": "",
"Value": "",
"Max": "",
File diff suppressed because it is too large Load Diff
@@ -42,7 +42,7 @@ async def test_create_entry(
mock_config_entry = result["result"]
assert (
mock_config_entry.title
== f"{VALID_CONFIG[CONF_HOST]}:{VALID_CONFIG[CONF_PORT]}"
== f"GAMING-PC ({VALID_CONFIG[CONF_HOST]}:{VALID_CONFIG[CONF_PORT]})"
)
assert mock_config_entry.data == VALID_CONFIG
@@ -88,3 +88,8 @@ async def test_migration_to_unique_ids(
assert (
entity_registry.async_get_entity_id("sensor", DOMAIN, legacy_entity_id) is None
)
updated_config_entry = hass.config_entries.async_get_entry(
legacy_config_entry_v1.entry_id
)
assert updated_config_entry.version == 2
@@ -92,7 +92,7 @@ async def test_sensors_are_updated(
"""Test sensors are updated with properly formatted values."""
await init_integration(hass, mock_config_entry)
entity_id = "sensor.amd_ryzen_7_7800x3d_package_temperature"
entity_id = "sensor.gaming_pc_amd_ryzen_7_7800x3d_package_temperature"
state = hass.states.get(entity_id)
assert state
@@ -128,7 +128,7 @@ async def test_sensor_state_is_unknown_when_no_sensor_data_is_provided(
"""Test sensor state is unknown when sensor data is missing."""
await init_integration(hass, mock_config_entry)
entity_id = "sensor.amd_ryzen_7_7800x3d_package_temperature"
entity_id = "sensor.gaming_pc_amd_ryzen_7_7800x3d_package_temperature"
state = hass.states.get(entity_id)
@@ -200,6 +200,7 @@ async def _mock_orphaned_device(
previous_data = mock_lhm_client.get_data.return_value
mock_lhm_client.get_data.return_value = LibreHardwareMonitorData(
computer_name=mock_lhm_client.get_data.return_value.computer_name,
main_device_ids_and_names=MappingProxyType(
{
device_id: name
@@ -230,6 +231,7 @@ async def test_integration_does_not_log_new_devices_on_first_refresh(
) -> None:
"""Test that initial data update does not cause warning about new devices."""
mock_lhm_client.get_data.return_value = LibreHardwareMonitorData(
computer_name=mock_lhm_client.get_data.return_value.computer_name,
main_device_ids_and_names=MappingProxyType(
{
**mock_lhm_client.get_data.return_value.main_device_ids_and_names,