Set device entry type of minecraft_server to service (#188182)

This commit is contained in:
elmurato
2026-10-23 12:13:31 +00:00
committed by GitHub
parent 59dba32c75
commit 00df80d38b
2 changed files with 31 additions and 1 deletions
@@ -2,7 +2,7 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_TYPE
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .api import MinecraftServerType
@@ -26,6 +26,7 @@ class MinecraftServerEntity(CoordinatorEntity[MinecraftServerCoordinator]):
super().__init__(coordinator)
self._attr_device_info = DeviceInfo(
entry_type=DeviceEntryType.SERVICE,
identifiers={(DOMAIN, config_entry.entry_id)},
manufacturer=MANUFACTURER,
model=(
@@ -339,3 +339,32 @@ async def test_entry_migration_v3_failure(
assert v1_mock_config_entry.error_reason_translation_placeholders == {
"address": f"{TEST_HOST}:{TEST_PORT}"
}
async def test_device_entry_type(
hass: HomeAssistant,
java_mock_config_entry: MockConfigEntry,
device_registry: dr.DeviceRegistry,
) -> None:
"""Test the device entry type."""
java_mock_config_entry.add_to_hass(hass)
with (
patch(
"homeassistant.components.minecraft_server.api.JavaServer.async_lookup",
return_value=JavaServer(host=TEST_HOST, port=TEST_PORT),
),
patch(
"homeassistant.components.minecraft_server.api.JavaServer.async_status",
return_value=TEST_JAVA_STATUS_RESPONSE,
),
):
assert await hass.config_entries.async_setup(java_mock_config_entry.entry_id)
await hass.async_block_till_done()
device = device_registry.async_get_device_by_identifier(
(DOMAIN, java_mock_config_entry.entry_id),
java_mock_config_entry.entry_id,
)
assert device is not None
assert device.entry_type is dr.DeviceEntryType.SERVICE