mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Add name option for Frontier Silicon devices (#32085)
* Added the option to specify the name of the device in confirguration.yaml * Adding missing default name parameter in auto-discovery FSAPIDevice constructor. * Fixed Black formatting. * Removed DEFAULT_NAME constant. * Apply suggestions from code review Co-Authored-By: springstan <46536646+springstan@users.noreply.github.com> Co-authored-by: springstan <46536646+springstan@users.noreply.github.com>
This commit is contained in:
parent
d22ee7179d
commit
458e47f981
@ -24,6 +24,7 @@ from homeassistant.components.media_player.const import (
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_HOST,
|
||||
CONF_NAME,
|
||||
CONF_PASSWORD,
|
||||
CONF_PORT,
|
||||
STATE_IDLE,
|
||||
@ -61,6 +62,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||
vol.Optional(CONF_PASSWORD, default=DEFAULT_PASSWORD): cv.string,
|
||||
vol.Optional(CONF_NAME): cv.string,
|
||||
}
|
||||
)
|
||||
|
||||
@ -69,17 +71,19 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||
"""Set up the Frontier Silicon platform."""
|
||||
if discovery_info is not None:
|
||||
async_add_entities(
|
||||
[AFSAPIDevice(discovery_info["ssdp_description"], DEFAULT_PASSWORD)], True
|
||||
[AFSAPIDevice(discovery_info["ssdp_description"], DEFAULT_PASSWORD, None)],
|
||||
True,
|
||||
)
|
||||
return True
|
||||
|
||||
host = config.get(CONF_HOST)
|
||||
port = config.get(CONF_PORT)
|
||||
password = config.get(CONF_PASSWORD)
|
||||
name = config.get(CONF_NAME)
|
||||
|
||||
try:
|
||||
async_add_entities(
|
||||
[AFSAPIDevice(DEVICE_URL.format(host, port), password)], True
|
||||
[AFSAPIDevice(DEVICE_URL.format(host, port), password, name)], True
|
||||
)
|
||||
_LOGGER.debug("FSAPI device %s:%s -> %s", host, port, password)
|
||||
return True
|
||||
@ -94,13 +98,13 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||
class AFSAPIDevice(MediaPlayerDevice):
|
||||
"""Representation of a Frontier Silicon device on the network."""
|
||||
|
||||
def __init__(self, device_url, password):
|
||||
def __init__(self, device_url, password, name):
|
||||
"""Initialize the Frontier Silicon API device."""
|
||||
self._device_url = device_url
|
||||
self._password = password
|
||||
self._state = None
|
||||
|
||||
self._name = None
|
||||
self._name = name
|
||||
self._title = None
|
||||
self._artist = None
|
||||
self._album_name = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user