def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Panasonic Viera TV platform."""
    from panasonic_viera import DEFAULT_PORT, RemoteControl

    name = config.get(CONF_NAME, 'Panasonic Viera TV')
    port = config.get(CONF_PORT, DEFAULT_PORT)

    if discovery_info:
        _LOGGER.debug('%s', discovery_info)
        vals = discovery_info.split(':')
        if len(vals) > 1:
            port = vals[1]

        host = vals[0]
        remote = RemoteControl(host, port)
        add_devices([PanasonicVieraTVDevice(name, remote)])
        return True

    # Validate that all required config options are given
    if not validate_config({DOMAIN: config}, {DOMAIN: [CONF_HOST]}, _LOGGER):
        return False

    host = config.get(CONF_HOST, None)

    remote = RemoteControl(host, port)
    try:
        remote.get_mute()
    except (socket.timeout, TimeoutError, __HOLE__):
        _LOGGER.error('Panasonic Viera TV is not available at %s:%d',
                      host, port)
        return False

    add_devices([PanasonicVieraTVDevice(name, remote)])
    return True


# pylint: disable=abstract-method
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/media_player/panasonic_viera.py/setup_platform