diff --git a/homeassistant/components/squeezebox/media_player.py b/homeassistant/components/squeezebox/media_player.py index 969a07f1fba3..54aa930e35de 100644 --- a/homeassistant/components/squeezebox/media_player.py +++ b/homeassistant/components/squeezebox/media_player.py @@ -160,7 +160,7 @@ async def async_setup_entry( model=model, manufacturer=manufacturer, model_id=model_id, - hw_version=player.firmware, + hw_version=str(player.firmware) if player.firmware is not None else None, sw_version=sw_version, via_device=(DOMAIN, coordinator.server_uuid), ) diff --git a/tests/components/squeezebox/test_init.py b/tests/components/squeezebox/test_init.py index 08004040ab15..d43e92582b1d 100644 --- a/tests/components/squeezebox/test_init.py +++ b/tests/components/squeezebox/test_init.py @@ -123,6 +123,25 @@ async def test_device_registry( assert reg_device == snapshot +async def test_device_registry_numeric_firmware( + hass: HomeAssistant, + device_registry: DeviceRegistry, + config_entry: MockConfigEntry, + lms: MagicMock, +) -> None: + """Test that numeric firmware values are stored as strings in the device registry.""" + players = await lms.async_get_players() + players[0].firmware = 137 + + with patch("homeassistant.components.squeezebox.Server", return_value=lms): + await hass.config_entries.async_setup(config_entry.entry_id) + await hass.async_block_till_done() + + reg_device = device_registry.async_get_device(identifiers={(DOMAIN, TEST_MAC[0])}) + assert reg_device is not None + assert reg_device.hw_version == "137" + + async def test_device_registry_server_merged( hass: HomeAssistant, device_registry: DeviceRegistry,