Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions homeassistant/components/frontier_silicon/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
)
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
CONF_PASSWORD,
CONF_PORT,
STATE_OFF,
Expand Down Expand Up @@ -54,12 +55,14 @@
DEFAULT_PORT = 80
DEFAULT_PASSWORD = "1234"
DEVICE_URL = "http://{0}:{1}/device"
DEFAULT_NAME = ""
Comment thread
springstan marked this conversation as resolved.
Outdated

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, default=DEFAULT_NAME): cv.string,
}
)

Expand All @@ -68,17 +71,23 @@ 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, DEFAULT_NAME
)
],
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
Expand All @@ -93,13 +102,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
Expand Down