mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Small improvements to linkplay from reviews (#125766)
Small improvements
This commit is contained in:
parent
0c1a605693
commit
420bdedcb5
@ -4,4 +4,4 @@ from homeassistant.const import Platform
|
|||||||
|
|
||||||
DOMAIN = "linkplay"
|
DOMAIN = "linkplay"
|
||||||
PLATFORMS = [Platform.MEDIA_PLAYER]
|
PLATFORMS = [Platform.MEDIA_PLAYER]
|
||||||
CONF_SESSION = "session"
|
DATA_SESSION = "session"
|
||||||
|
@ -177,9 +177,8 @@ class LinkPlayMediaPlayerEntity(MediaPlayerEntity):
|
|||||||
]
|
]
|
||||||
|
|
||||||
manufacturer, model = get_info_from_project(bridge.device.properties["project"])
|
manufacturer, model = get_info_from_project(bridge.device.properties["project"])
|
||||||
if model == MANUFACTURER_GENERIC:
|
|
||||||
model_id = None
|
model_id = None
|
||||||
else:
|
if model != MANUFACTURER_GENERIC:
|
||||||
model_id = bridge.device.properties["project"]
|
model_id = bridge.device.properties["project"]
|
||||||
|
|
||||||
self._attr_device_info = dr.DeviceInfo(
|
self._attr_device_info = dr.DeviceInfo(
|
||||||
|
@ -8,7 +8,7 @@ from linkplay.utils import async_create_unverified_client_session
|
|||||||
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE
|
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE
|
||||||
from homeassistant.core import Event, HomeAssistant, callback
|
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_ARTSOUND: Final[str] = "ArtSound"
|
||||||
MANUFACTURER_ARYLIC: Final[str] = "Arylic"
|
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:
|
async def async_get_client_session(hass: HomeAssistant) -> ClientSession:
|
||||||
"""Get a ClientSession that can be used with LinkPlay devices."""
|
"""Get a ClientSession that can be used with LinkPlay devices."""
|
||||||
hass.data.setdefault(DOMAIN, {})
|
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()
|
clientsession: ClientSession = await async_create_unverified_client_session()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
@ -66,8 +66,8 @@ async def async_get_client_session(hass: HomeAssistant) -> ClientSession:
|
|||||||
clientsession.detach()
|
clientsession.detach()
|
||||||
|
|
||||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_CLOSE, _async_close_websession)
|
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
|
return clientsession
|
||||||
|
|
||||||
session: ClientSession = hass.data[DOMAIN][CONF_SESSION]
|
session: ClientSession = hass.data[DOMAIN][DATA_SESSION]
|
||||||
return session
|
return session
|
||||||
|
Loading…
x
Reference in New Issue
Block a user