Small improvements to linkplay from reviews (#125766)

Small improvements
This commit is contained in:
Simon Lamon 2024-09-11 18:38:06 +02:00 committed by GitHub
parent 0c1a605693
commit 420bdedcb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 8 deletions

View File

@ -4,4 +4,4 @@ from homeassistant.const import Platform
DOMAIN = "linkplay"
PLATFORMS = [Platform.MEDIA_PLAYER]
CONF_SESSION = "session"
DATA_SESSION = "session"

View File

@ -177,9 +177,8 @@ class LinkPlayMediaPlayerEntity(MediaPlayerEntity):
]
manufacturer, model = get_info_from_project(bridge.device.properties["project"])
if model == MANUFACTURER_GENERIC:
model_id = None
else:
model_id = None
if model != MANUFACTURER_GENERIC:
model_id = bridge.device.properties["project"]
self._attr_device_info = dr.DeviceInfo(

View File

@ -8,7 +8,7 @@ from linkplay.utils import async_create_unverified_client_session
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE
from homeassistant.core import Event, HomeAssistant, callback
from .const import CONF_SESSION, DOMAIN
from .const import DATA_SESSION, DOMAIN
MANUFACTURER_ARTSOUND: Final[str] = "ArtSound"
MANUFACTURER_ARYLIC: Final[str] = "Arylic"
@ -57,7 +57,7 @@ def get_info_from_project(project: str) -> tuple[str, str]:
async def async_get_client_session(hass: HomeAssistant) -> ClientSession:
"""Get a ClientSession that can be used with LinkPlay devices."""
hass.data.setdefault(DOMAIN, {})
if CONF_SESSION not in hass.data[DOMAIN]:
if DATA_SESSION not in hass.data[DOMAIN]:
clientsession: ClientSession = await async_create_unverified_client_session()
@callback
@ -66,8 +66,8 @@ async def async_get_client_session(hass: HomeAssistant) -> ClientSession:
clientsession.detach()
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_CLOSE, _async_close_websession)
hass.data[DOMAIN][CONF_SESSION] = clientsession
hass.data[DOMAIN][DATA_SESSION] = clientsession
return clientsession
session: ClientSession = hass.data[DOMAIN][CONF_SESSION]
session: ClientSession = hass.data[DOMAIN][DATA_SESSION]
return session