1
0
mirror of https://github.com/home-assistant/core.git synced 2026-07-04 21:25:26 +01:00

Add network MAC connection to PlayStation 4 devices (#173681)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jasonjhofmann
2026-06-15 23:11:25 -07:00
committed by GitHub
parent 36b74d6f05
commit c29aebd60e
3 changed files with 59 additions and 0 deletions
@@ -352,6 +352,8 @@ class PS4Device(MediaPlayerEntity):
for device in d_registry.devices.get_devices_for_config_entry_id(
self._entry_id
):
# Rebuilt from the existing device entry, which already carries
# the network MAC connection added by the live-status branch.
self._attr_device_info = DeviceInfo(
identifiers=device.identifiers,
manufacturer=device.manufacturer,
@@ -365,7 +367,9 @@ class PS4Device(MediaPlayerEntity):
_sw_version = status["system-version"]
_sw_version = _sw_version[1:4]
sw_version = f"{_sw_version[0]}.{_sw_version[1:]}"
# status["host-id"] is the console's network MAC address.
self._attr_device_info = DeviceInfo(
connections={(dr.CONNECTION_NETWORK_MAC, status["host-id"])},
identifiers={(DOMAIN, status["host-id"])},
manufacturer="Sony Interactive Entertainment Inc.",
model="PlayStation 4",
@@ -0,0 +1,36 @@
# serializer version: 1
# name: test_device_registry
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': None,
'connections': set({
tuple(
'mac',
'a0:00:0a:0a:a0:00',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'ps4',
'A0000A0AA000',
),
}),
'labels': set({
}),
'manufacturer': 'Sony Interactive Entertainment Inc.',
'model': 'PlayStation 4',
'model_id': None,
'name': 'Fake PS4',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': None,
'sw_version': '9.87',
'via_device_id': None,
})
# ---
+19
View File
@@ -6,6 +6,7 @@ from unittest.mock import MagicMock, patch
from pyps4_2ndscreen.credential import get_ddp_message
from pyps4_2ndscreen.ddp import DEFAULT_UDP_PORT
from pyps4_2ndscreen.media_art import TYPE_APP as PS_TYPE_APP
from syrupy.assertion import SnapshotAssertion
from homeassistant.components import ps4
from homeassistant.components.media_player import (
@@ -323,6 +324,24 @@ async def test_device_info_is_set_from_status_correctly(
assert mock_entry.identifiers == {(DOMAIN, MOCK_HOST_ID)}
async def test_device_registry(
hass: HomeAssistant,
patch_get_status: MagicMock,
device_registry: dr.DeviceRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test the device registry entry, including the network MAC connection."""
patch_get_status.return_value = MOCK_STATUS_STANDBY
await setup_mock_component(hass)
await hass.async_block_till_done()
device_entry = device_registry.async_get_device(
identifiers={(DOMAIN, MOCK_HOST_ID)}
)
assert device_entry == snapshot
async def test_device_info_is_assummed(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,